diff --git a/edl/__init__.py b/edl/__init__.py index 533537c..69e5cf8 100644 --- a/edl/__init__.py +++ b/edl/__init__.py @@ -8,7 +8,7 @@ import pprint import timecode -__version__ = '0.1.11' +from .version import __version__ class List(object): @@ -126,6 +126,7 @@ def matches(self, line): def apply(self, stack, line): sys.stderr.write("Skipping:" + line) + class FCMMatcher(Matcher): """Matches the FCM attribute """ @@ -139,6 +140,7 @@ def apply(self, stack, line): except (IndexError, AttributeError): pass + class TitleMatcher(Matcher): """Matches the EDL Title attribute """ @@ -198,7 +200,26 @@ def apply(self, stack, line): if m: stack[-1].clip_name = m.group(2).strip() +class ToNameMatcher(Matcher): + """ + Identifies TO CLIP NAME as the destination clip for the transition. + Pushes FROM CLIP NAME value to the previous entry (the source). + """ + + def __init__(self): + # Following similar convention to NameMatcher, finds destination name + Matcher.__init__(self, '\*\s*TO CLIP NAME:(\s+)(.+)') + def apply(self, stack, line): + m = re.search(self.regex, line) + #print line + if len(stack) > 0: + if m: + # this "From" is the name from previous Clip + stack[-2].clip_name = stack[-1].clip_name + # this "To" is the name we want to keep for this event + stack[-1].clip_name = m.group(2).strip() + class SourceMatcher(Matcher): """No documentation for this class yet. """ @@ -219,7 +240,13 @@ class EffectMatcher(Matcher): """ def __init__(self): - Matcher.__init__(self, 'EFFECTS NAME IS(\s+)(.+)') + """ + Matches + * EFFECT NAME: CROSS DISSOLVE (Toon boom Storyboard Pro Edl) + or + EFFECTS NAME IS CROSS DISSOLVE (Adobe Premiere Edl) + """ + Matcher.__init__(self, '.*EFFECT.*(?:IS|:)(\s+)(.+)') def apply(self, stack, line): m = re.search(self.regex, line) @@ -273,9 +300,11 @@ def apply(self, stack, line): values = map(self.stripper, matches) evt = Event(dict(zip(keys, values))) t = evt.tr_code - if t == 'C': - if len(stack) > 0: + + if len(stack) > 0: stack[-1].next_event = evt + + if t == 'C': evt.transition = Cut() elif t == 'D': evt.transition = Dissolve() @@ -557,8 +586,8 @@ def __init__(self, fps=None): def get_matchers(self): return [TitleMatcher(), EventMatcher(self.fps), EffectMatcher(), - NameMatcher(), SourceMatcher(), TimewarpMatcher(self.fps), - CommentMatcher(), FCMMatcher()] + NameMatcher(), ToNameMatcher(), SourceMatcher(), + TimewarpMatcher(self.fps), CommentMatcher()] def parse(self, input_): stack = None diff --git a/edl/version.py b/edl/version.py new file mode 100644 index 0000000..13b7089 --- /dev/null +++ b/edl/version.py @@ -0,0 +1 @@ +__version__ = '0.1.11' diff --git a/setup.py b/setup.py index 7b0f615..2a0aa35 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from distutils.core import setup -import edl +exec(open('edl/version.py').read()) requires = [ 'timecode' @@ -9,7 +9,7 @@ setup( name='edl', - version=edl.__version__, + version=__version__, description='Simple EDL reading library', author='Simon Hargreaves', author_email='simon@simon-hargreaves.com',