You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
651 B
20 lines
651 B
from typing import Optional |
|
|
|
class Segment: |
|
''' |
|
Used for segment manipulation instead of { 'from': ..., 'to': ... } dict |
|
''' |
|
|
|
def __init__(self, from_timestamp: int, to_timestamp: int, message: str = None): |
|
if to_timestamp < from_timestamp: |
|
raise ValueError(f'Can`t create segment with to < from: {to_timestamp} < {from_timestamp}') |
|
self.from_timestamp = from_timestamp |
|
self.to_timestamp = to_timestamp |
|
self.message = message |
|
|
|
def to_json(self): |
|
return { |
|
'from': self.from_timestamp, |
|
'to': self.to_timestamp, |
|
'message': self.message |
|
}
|
|
|