mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 17:00:46 +00:00
Type annotations
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from fractions import Fraction
|
from fractions import Fraction
|
||||||
from ptulsconv.broadcast_timecode import smpte_to_frame_count
|
from ptulsconv.broadcast_timecode import smpte_to_frame_count
|
||||||
|
from typing import Tuple, List
|
||||||
|
|
||||||
|
|
||||||
class SessionDescriptor:
|
class SessionDescriptor:
|
||||||
@@ -13,6 +14,16 @@ class SessionDescriptor:
|
|||||||
|
|
||||||
|
|
||||||
class HeaderDescriptor:
|
class HeaderDescriptor:
|
||||||
|
session_name: str
|
||||||
|
sample_rate: float
|
||||||
|
bit_depth: int
|
||||||
|
start_timecode: str
|
||||||
|
timecode_format: str
|
||||||
|
timecode_drop_frame: bool
|
||||||
|
count_audio_tracks: int
|
||||||
|
count_clips: int
|
||||||
|
count_files: int
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.session_name = kwargs['session_name']
|
self.session_name = kwargs['session_name']
|
||||||
self.sample_rate = kwargs['sample_rate']
|
self.sample_rate = kwargs['sample_rate']
|
||||||
@@ -49,7 +60,7 @@ class HeaderDescriptor:
|
|||||||
return self._get_tcformat_params[1]
|
return self._get_tcformat_params[1]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _get_tcformat_params(self):
|
def _get_tcformat_params(self) -> Tuple[int, Fraction]:
|
||||||
frame_rates = {"23.976": (24, Fraction(1001, 24_000)),
|
frame_rates = {"23.976": (24, Fraction(1001, 24_000)),
|
||||||
"24": (24, Fraction(1, 24)),
|
"24": (24, Fraction(1, 24)),
|
||||||
"29.97": (30, Fraction(1001, 30_000)),
|
"29.97": (30, Fraction(1001, 30_000)),
|
||||||
@@ -65,6 +76,13 @@ class HeaderDescriptor:
|
|||||||
|
|
||||||
|
|
||||||
class TrackDescriptor:
|
class TrackDescriptor:
|
||||||
|
name: str
|
||||||
|
comments: str
|
||||||
|
user_delay_samples: int
|
||||||
|
state: List[str]
|
||||||
|
plugins: List[str]
|
||||||
|
clips: List["TrackClipDescriptor"]
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.name = kwargs['name']
|
self.name = kwargs['name']
|
||||||
self.comments = kwargs['comments']
|
self.comments = kwargs['comments']
|
||||||
@@ -79,12 +97,21 @@ class FileDescriptor(dict):
|
|||||||
|
|
||||||
|
|
||||||
class TrackClipDescriptor:
|
class TrackClipDescriptor:
|
||||||
|
channel: int
|
||||||
|
event: int
|
||||||
|
clip_name: str
|
||||||
|
start_time: str
|
||||||
|
finish_time: str
|
||||||
|
duration: str
|
||||||
|
timestamp: str
|
||||||
|
state: str
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.channel = kwargs['channel']
|
self.channel = kwargs['channel']
|
||||||
self.event = kwargs['event']
|
self.event = kwargs['event']
|
||||||
self.clip_name = kwargs['clip_name']
|
self.clip_name = kwargs['clip_name']
|
||||||
self.start_time = kwargs['start_time']
|
self.start_time = kwargs['start_time']
|
||||||
self.end_time = kwargs['end_time']
|
self.finish_time = kwargs['finish_time']
|
||||||
self.duration = kwargs['duration']
|
self.duration = kwargs['duration']
|
||||||
self.timestamp = kwargs['timestamp']
|
self.timestamp = kwargs['timestamp']
|
||||||
self.state = kwargs['state']
|
self.state = kwargs['state']
|
||||||
@@ -99,6 +126,13 @@ class PluginDescriptor(dict):
|
|||||||
|
|
||||||
|
|
||||||
class MarkerDescriptor:
|
class MarkerDescriptor:
|
||||||
|
number: int
|
||||||
|
location: str
|
||||||
|
time_reference: int
|
||||||
|
units: str
|
||||||
|
name: str
|
||||||
|
comments: str
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.number = kwargs['number']
|
self.number = kwargs['number']
|
||||||
self.location = kwargs['location']
|
self.location = kwargs['location']
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class DocParserVisitor(NodeVisitor):
|
|||||||
event=visited_children[3],
|
event=visited_children[3],
|
||||||
clip_name=visited_children[6],
|
clip_name=visited_children[6],
|
||||||
start_time=visited_children[8],
|
start_time=visited_children[8],
|
||||||
end_time=visited_children[10],
|
finish_time=visited_children[10],
|
||||||
duration=visited_children[12],
|
duration=visited_children[12],
|
||||||
timestamp=timestamp,
|
timestamp=timestamp,
|
||||||
state=visited_children[15])
|
state=visited_children[15])
|
||||||
|
|||||||
Reference in New Issue
Block a user