diff options
-rw-r--r-- | io_sequencer_edl/__init__.py | 6 | ||||
-rw-r--r-- | io_sequencer_edl/import_edl.py | 8 | ||||
-rw-r--r-- | io_sequencer_edl/parse_edl.py | 55 |
3 files changed, 32 insertions, 37 deletions
diff --git a/io_sequencer_edl/__init__.py b/io_sequencer_edl/__init__.py index 1cc3bec7..cfab0b6e 100644 --- a/io_sequencer_edl/__init__.py +++ b/io_sequencer_edl/__init__.py @@ -54,7 +54,7 @@ class ReloadEDL(Operator): def execute(self, context): import os - from . import import_edl + from . import parse_edl scene = context.scene edl_import_info = scene.edl_import_info @@ -66,7 +66,7 @@ class ReloadEDL(Operator): self.report({'ERROR'}, "File Not Found %r" % filepath) return {'CANCELLED'} - elist = import_edl.EditList() + elist = parse_edl.EditList() if not elist.parse(filepath, dummy_fps): self.report({'ERROR'}, "Failed to parse EDL %r" % filepath) return {'CANCELLED'} @@ -79,7 +79,7 @@ class ReloadEDL(Operator): data_prev = {reel.name: (reel.filepath, reel.frame_offset) for reel in edl_import_info.reels} - reels = elist.getReels() + reels = elist.reels_as_dict() reels = [k for k in reels.keys() if k != "bw"] # re-create reels collection, keeping old values diff --git a/io_sequencer_edl/import_edl.py b/io_sequencer_edl/import_edl.py index 3d671209..65e4db4a 100644 --- a/io_sequencer_edl/import_edl.py +++ b/io_sequencer_edl/import_edl.py @@ -143,7 +143,7 @@ def load_edl(scene, filename, reel_files, reel_offsets): unedited_start = rec_start - src_start offset_start = src_start - int(src_start * scale) # works for scaling up AND down - if edit.transition_type == parse_edl.TRANSITION_CUT and (not elist.testOverlap(edit)): + if edit.transition_type == parse_edl.TRANSITION_CUT and (not elist.overlap_test(edit)): track = 1 strip = None @@ -272,7 +272,7 @@ def load_edl(scene, filename, reel_files, reel_offsets): if final_strips: for strip in final_strips: # strip.frame_duration = length - final_strip.name = edit.asName() + final_strip.name = edit.as_name() edit.custom_data[:] = final_strips # track = not track prev_edit = edit @@ -293,7 +293,7 @@ def _test(): _fps = 25 if not elist.parse(_filename, _fps): assert(0) - reels = elist.getReels() + reels = elist.reels_as_dict() print(list(reels.keys())) @@ -303,4 +303,4 @@ def _test(): {'tapec': "/fe/edl/cinesoft/rush/rushes3.avi"}, {'tapec': 0}) # /tmp/test.edl print(msg) -_test() +# _test() diff --git a/io_sequencer_edl/parse_edl.py b/io_sequencer_edl/parse_edl.py index 8e8893c1..3e6c3bc4 100644 --- a/io_sequencer_edl/parse_edl.py +++ b/io_sequencer_edl/parse_edl.py @@ -39,22 +39,22 @@ class TimeCode: def __init__(self, data, fps): self.fps = fps if type(data) == str: - self.fromString(data) - frame = self.asFrame() - self.fromFrame(frame) + self.from_string(data) + frame = self.as_frame() + self.from_frame(frame) else: - self.fromFrame(data) + self.from_frame(data) - def fromString(self, text): + def from_string(self, text): # hh:mm:ss:ff # No dropframe support yet if text.lower().endswith("mps"): # 5.2mps - return self.fromFrame(int(float(text[:-3]) * self.fps)) + return self.from_frame(int(float(text[:-3]) * self.fps)) elif text.lower().endswith("s"): # 5.2s - return self.fromFrame(int(float(text[:-1]) * self.fps)) + return self.from_frame(int(float(text[:-1]) * self.fps)) elif text.isdigit(): # 1234 - return self.fromFrame(int(text)) + return self.from_frame(int(text)) elif ":" in text: # hh:mm:ss:ff text = text.replace(";", ":").replace(",", ":").replace(".", ":") text = text.split(":") @@ -68,7 +68,7 @@ class TimeCode: print("ERROR: could not convert this into timecode %r" % text) return self - def fromFrame(self, frame): + def from_frame(self, frame): if frame < 0: frame = -frame @@ -107,7 +107,7 @@ class TimeCode: return self - def asFrame(self): + def as_frame(self): abs_frame = self.frame abs_frame += self.seconds * self.fps abs_frame += self.minutes * 60 * self.fps @@ -115,19 +115,19 @@ class TimeCode: return abs_frame - def asString(self): - self.fromFrame(int(self)) + def as_string(self): + self.from_frame(int(self)) return "%.2d:%.2d:%.2d:%.2d" % (self.hours, self.minutes, self.seconds, self.frame) def __repr__(self): - return self.asString() + return self.as_string() # Numeric stuff, may as well have this def __neg__(self): return TimeCode(-int(self), self.fps) def __int__(self): - return self.asFrame() + return self.as_frame() def __sub__(self, other): return TimeCode(int(self) - int(other), self.fps) @@ -145,13 +145,13 @@ class TimeCode: return TimeCode(abs(int(self)), self.fps) def __iadd__(self, other): - return self.fromFrame(int(self) + int(other)) + return self.from_frame(int(self) + int(other)) def __imul__(self, other): - return self.fromFrame(int(self) * int(other)) + return self.from_frame(int(self) * int(other)) def __idiv__(self, other): - return self.fromFrame(int(self) // int(other)) + return self.from_frame(int(self) // int(other)) # end timecode @@ -266,15 +266,6 @@ t /= 2 print t """ - -def editFlagsToText(flag): - items = [] - for item, val in EDIT_DICT.items(): - if val & flag: - items.append(item) - return "/".join(items) - - class EditDecision: __slots__ = ( "number", @@ -294,6 +285,10 @@ class EditDecision: "custom_data", ) + @staticmethod + def edit_flags_to_text(flag): + return "/".join([item for item, val in EDIT_DICT.items() if val & flag]) + def __init__(self, text=None, fps=25): # print text self.number = -1 @@ -320,7 +315,7 @@ class EditDecision: txt = "num: %d, " % self.number txt += "reel: %s, " % self.reel txt += "edit_type: " - txt += editFlagsToText(self.edit_type) + ", " + txt += EditDecision.edit_flags_to_text(self.edit_type) + ", " txt += "trans_type: " for item, val in TRANSITION_DICT.items(): @@ -424,7 +419,7 @@ class EditDecision: self.renumber() # TODO - def asName(self): + def as_name(self): cut_type = "nil" for k, v in TRANSITION_DICT.items(): if v == self.transition_type: @@ -547,7 +542,7 @@ class EditList: file.close() return True - def testOverlap(self, edit_test): + def overlap_test(self, edit_test): recIn = int(edit_test.recIn) recOut = int(edit_test.recOut) @@ -570,7 +565,7 @@ class EditList: return False - def getReels(self): + def reels_as_dict(self): reels = {} for edit in self.edits: reels.setdefault(edit.reel, []).append(edit) |