From 989d52aaee7b9295688f2aa31fd1c3cceb5c2f33 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Sat, 1 Dec 2018 15:15:09 -0800 Subject: [PATCH] CmxEvent and CmxTransition implementation --- pycmx/cmx_event.py | 77 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 6 deletions(-) diff --git a/pycmx/cmx_event.py b/pycmx/cmx_event.py index 6571711..5639875 100644 --- a/pycmx/cmx_event.py +++ b/pycmx/cmx_event.py @@ -1,6 +1,8 @@ class CmxEvent: - def __init__(self,title,number,clip_name,source_name,channels, transition,source_start,source_finish, - record_start, record_finish, fcm_drop, remarks = [] , unrecognized = []): + def __init__(self,title,number,clip_name,source_name,channels, + transition,source_start,source_finish, + record_start, record_finish, fcm_drop, remarks = [] , + unrecognized = []): self.title = title self.number = number self.clip_name = clip_name @@ -14,12 +16,75 @@ class CmxEvent: self.fcm_drop = fcm_drop self.remarks = remarks self.unrecgonized = unrecognized + self.black = (source_name == 'BL') + self.aux_source = (source_name == 'AX') + def accept_statement(statement): - return + atement_type = type(statement).__name__ + if statement_type == 'AudioExt': + self.channels.appendExt(statement) + elif statement_type == 'Remark': + self.remarks.append(statement.text) + elif statement_type == 'SourceFile': + self.source_name = statement.filename + elif statement_type == 'ClipName': + self.clip_name = statement.name + elif statement_type == 'EffectsName': + self.transition.name = statement.name + + def __repr__(self): + return f"""CmxEvent(title="{self.title}",number="{self.number}",\ +clip_name="{self.clip_name}",source_name="{self.source_name}",\ +channels={self.channels},transition={self.transition},\ +source_start="{self.source_start}",source_finish="{self.source_finish}",\ +record_start="{self.source_start}",record_finish="{self.record_finish}",\ +fcm_drop={self.fcm_drop},remarks={self.remarks})""" class CmxTransition: - def __init__(self, transition, transition_operand): - self.transition = "" - self.transition_operand = transition_operand + def __init__(self, transition, operand): + self.transition = transition + self.operand = operand + self.name = '' + + @property + def cut(self): + return self.transition == 'C' + + @property + def dissolve(self): + return self.transition == 'D' + + + @property + def wipe(self): + return self.transition.startswith('W') + + + @property + def effect_duration(self): + return int(self.operand) + + @property + def wipe_number(self): + if self.wipe: + return int(self.transition[1:]) + else: + return None + + @property + def key_background(self): + return self.transition == 'KB' + + @property + def key_foreground(self): + return self.transition == 'K' + + @property + def key_out(self): + return self.transition == 'KO' + + def __repr__(self): + return f"""CmxTransition(transition="{self.transition}",operand="{self.operand}")""" +