From 32da584363f87f1e316699803970c1157417d7fd Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Wed, 26 Dec 2018 15:48:56 -0800 Subject: [PATCH] Update parse_cmx_events.py Added unrecognized_statements properties to EditList and Events classes --- pycmx/parse_cmx_events.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/pycmx/parse_cmx_events.py b/pycmx/parse_cmx_events.py index e1148a1..9fcfd37 100644 --- a/pycmx/parse_cmx_events.py +++ b/pycmx/parse_cmx_events.py @@ -2,7 +2,7 @@ # (c) 2018 Jamie Hardt from .parse_cmx_statements import (parse_cmx3600_statements, - StmtEvent, StmtFCM, StmtTitle, StmtClipName, StmtSourceFile, StmtAudioExt) + StmtEvent, StmtFCM, StmtTitle, StmtClipName, StmtSourceFile, StmtAudioExt, StmtUnrecognized) from .channel_map import ChannelMap @@ -40,6 +40,17 @@ class EditList: 'The title of the edit list' return self.title_statement.title + + @property + def unrecognized_statements(self): + """ + A generator for all the unrecognized statements in the list. + """ + for s in self.event_statements: + if type(s) is StmtUnrecognized: + yield s + + @property def events(self): 'A generator for all the events in the edit list' @@ -82,10 +93,8 @@ class Edit: this edit. Line numbers a zero-indexed, such that the "TITLE:" record is line zero. """ - return self.edit_statement.line_number - @property def channels(self): """ @@ -171,6 +180,10 @@ class Edit: class Event: + """ + Represents a collection of :obj:`Edit`s, all with the same event number. + """ + def __init__(self, statements): self.statements = statements @@ -218,7 +231,14 @@ class Event: return [ Edit(e1[0],e1[1],n1,s1) for (e1,n1,s1) in zip(*the_zip) ] - + @property + def unrecognized_statements(self): + """ + A generator for all the unrecognized statements in the event. + """ + for s in self.statements: + if type(s) is StmtUnrecognized: + yield s def _edit_statements(self): return [s for s in self.statements if type(s) is StmtEvent]