Skip to content

Commit

Permalink
Merge 6e9bc1f into feae1e5
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnbk committed Oct 15, 2015
2 parents feae1e5 + 6e9bc1f commit 1168786
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions cdl_convert/parse.py
Expand Up @@ -469,16 +469,15 @@ def parse_cmx(input_file): # pylint: disable=R0912,R0914
cdls = []

with open(input_file, 'rb') as edl:
lines = edl.readlines()
lines = '\n'.join(edl.readlines())

filename = os.path.basename(input_file).split('.')[0]

def parse_cmx_clip(cmx_tuple):
"""Parses a three line cmx clip tuple."""
if len(cmx_tuple) != 3:
print(cmx_tuple)
return
title = cmx_tuple[0].split()[1]
title = cmx_tuple[0].split(': ')[1]

sop = re.match(
r'^\*ASC_SOP \(([\d\. -]+)\)\(([\d\. -]+)\)\(([\d\. -]+)\)',
Expand All @@ -500,17 +499,27 @@ def parse_cmx_clip(cmx_tuple):

return cc

for i, line in enumerate(lines):
if line != '\r\n':
# We only care about newlines when reading CMX, because
# we use those to kick off parsing the next take.
continue
if i + 3 <= len(lines):
cc = parse_cmx_clip(lines[i + 1:i + 4])
#This regex will avoid caring about extra stuff between the important lines we care about as long as the
#important lines we care about are in the right order
ccMatcher = re.compile(r'(\d*.+)(\n*.*)(\*\ *FROM.+)(\n*.*)(\*\ *ASC_(SOP|SAT).+)(\n*.*)(\*\ *ASC_(SOP|SAT).+)')
clipEntries = ccMatcher.findall(lines)
for entry in clipEntries:
clip = entry[2]
sop = None
sat = None
i=0
for group in entry:
if group == 'SOP':
sop = entry[i-1]
if group == 'SAT':
sat = entry[i-1]
i += 1
if clip is not None and sop is not None and sat is not None:
cc = parse_cmx_clip((clip, sop, sat))
cdls.append(cc)
else:
continue

cdls.append(cc)

ccc = collection.ColorCollection()
ccc.file_in = input_file
Expand Down

0 comments on commit 1168786

Please sign in to comment.