Skip to content

Commit

Permalink
Flake8 for docs, test, bin
Browse files Browse the repository at this point in the history
  • Loading branch information
iluvcapra committed Jan 5, 2025
1 parent 2adff6d commit 2be779f
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
per-file-ignores =
pycmx/__init__.py: F401

tests/__init__.py: F401

21 changes: 13 additions & 8 deletions bin/edl2scenelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def output_cmx(outfile, out_list):
outfile.write("TITLE: SCENE LIST\r\n")
outfile.write("FCM: NON-DROP FRAME\r\n")

for o in out_list:
line = "%03i AX V C 00:00:00:00 00:00:00:00 %s %s\r\n" % (
0, o['start'], o['end'])
for i, o in enumerate(out_list):
line = '%03i AX V C ' % (i)
line += '00:00:00:00 00:00:00:00 %s %s\r\n' % (o['start'], o['end'])
outfile.write(line)
outfile.write("* FROM CLIP NAME: %s\r\n" % (o['scene']))

Expand Down Expand Up @@ -85,15 +85,20 @@ def scene_list(infile, outfile, out_format, pattern):

def scene_list_cli():
parser = argparse.ArgumentParser(
description='Read video events from an input CMX EDL and output events merged into scenes.')
parser.add_argument('-o', '--outfile', default=sys.stdout, type=argparse.FileType('w'),
description='Read video events from an input CMX EDL and output '
'events merged into scenes.')
parser.add_argument('-o', '--outfile', default=sys.stdout,
type=argparse.FileType('w'),
help='Output file. Default is stdout.')
parser.add_argument('-f', '--format', default='cmx', type=str,
help='Output format. Options are cols and cmx, cmx is the default.')
help='Output format. Options are cols and cmx, cmx '
'is the default.')
parser.add_argument('-p', '--pattern', default='V?([A-Z]*[0-9]+)',
help='RE pattern for extracting scene name from clip name. The default is "V?([A-Z]*[0-9]+)". ' +
help='RE pattern for extracting scene name from clip '
'name. The default is "V?([A-Z]*[0-9]+)". ' +
'This pattern will be matched case-insensitively.')
parser.add_argument('input_edl', default=sys.stdin, type=argparse.FileType('r'), nargs='?',
parser.add_argument('input_edl', default=sys.stdin,
type=argparse.FileType('r'), nargs='?',
help='Input file. Default is stdin.')
args = parser.parse_args()

Expand Down
6 changes: 2 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,20 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#

import os
import sys
sys.path.insert(0, os.path.abspath('../..'))

import pycmx

# -- Project information -----------------------------------------------------

project = u'pycmx'
copyright = u'(c) 2023, Jamie Hardt'
copyright = u'(c) 2025, Jamie Hardt'
author = u'Jamie Hardt'

# The short X.Y version
version = pycmx.__version__
# The full version, including alpha/beta/rc tags
release = pycmx.__version__


# -- General configuration ---------------------------------------------------
Expand Down
148 changes: 75 additions & 73 deletions tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,112 +2,114 @@

import pycmx


class TestParse(TestCase):

files = ["INS4_R1_010417.edl" ,
"INS4_R1_DX_092117.edl",
"STP R1 v082517.edl",
"ToD_R4_LOCK3.1_030618_Video.edl",
"TEST.edl",
"test_edl_cdl.edl",
"INS4_R1_DX_092117.edl"
]
files = ["INS4_R1_010417.edl",
"INS4_R1_DX_092117.edl",
"STP R1 v082517.edl",
"ToD_R4_LOCK3.1_030618_Video.edl",
"TEST.edl",
"test_edl_cdl.edl",
"INS4_R1_DX_092117.edl"
]

def test_event_counts(self):

counts = [ 287, 466, 250 , 376, 120 , 3 , 466 ]
counts = [287, 466, 250, 376, 120, 3, 466]

for fn, count in zip(type(self).files, counts):
with open("tests/edls/" + fn ,'r') as f:
with open("tests/edls/" + fn, 'r') as f:
edl = pycmx.parse_cmx3600(f)
actual = len( list( edl.events ))
self.assertTrue( actual == count ,
"expected %i in file %s but found %i" % (count, fn, actual))
actual = len(list(edl.events))
self.assertTrue(actual == count,
"expected %i in file %s but found %i"
% (count, fn, actual))

def test_list_sanity(self):
for fn in type(self).files:
with open("tests/edls/" + fn ,'r') as f:
with open("tests/edls/" + fn, 'r') as f:
edl = pycmx.parse_cmx3600(f)
self.assertTrue( type(edl.title) is str )
self.assertTrue( len(edl.title) > 0 )

self.assertTrue(type(edl.title) is str)
self.assertTrue(len(edl.title) > 0)

def test_event_sanity(self):
for fn in type(self).files:
path = "tests/edls/" + fn
with open(path ,'r') as f:
with open(path, 'r') as f:
edl = pycmx.parse_cmx3600(f)
for index, event in enumerate(edl.events):
self.assertTrue( len(event.edits) > 0 )
self.assertTrue( event.number == index + 1 )


self.assertTrue(len(event.edits) > 0)
self.assertTrue(event.number == index + 1)

def test_events(self):
with open("tests/edls/TEST.edl",'r') as f:
with open("tests/edls/TEST.edl", 'r') as f:
edl = pycmx.parse_cmx3600(f)
events = list( edl.events )

self.assertEqual( events[0].number , 1)
self.assertEqual( events[0].edits[0].source , "OY_HEAD_")
self.assertEqual( events[0].edits[0].clip_name , "HEAD LEADER MONO")
self.assertEqual( events[0].edits[0].source_file , "OY_HEAD_LEADER.MOV")
self.assertEqual( events[0].edits[0].source_in , "00:00:00:00")
self.assertEqual( events[0].edits[0].source_out , "00:00:00:00")
self.assertEqual( events[0].edits[0].record_in , "01:00:00:00")
self.assertEqual( events[0].edits[0].record_out , "01:00:08:00")
self.assertTrue( events[0].edits[0].transition.kind == pycmx.Transition.Cut)
events = list(edl.events)

self.assertEqual(events[0].number, 1)
self.assertEqual(events[0].edits[0].source, "OY_HEAD_")
self.assertEqual(events[0].edits[0].clip_name, "HEAD LEADER MONO")
self.assertEqual(
events[0].edits[0].source_file, "OY_HEAD_LEADER.MOV")
self.assertEqual(events[0].edits[0].source_in, "00:00:00:00")
self.assertEqual(events[0].edits[0].source_out, "00:00:00:00")
self.assertEqual(events[0].edits[0].record_in, "01:00:00:00")
self.assertEqual(events[0].edits[0].record_out, "01:00:08:00")
self.assertTrue(
events[0].edits[0].transition.kind == pycmx.Transition.Cut)

def test_channel_map(self):
with open("tests/edls/TEST.edl",'r') as f:
with open("tests/edls/TEST.edl", 'r') as f:
edl = pycmx.parse_cmx3600(f)
events = list( edl.events )
self.assertFalse( events[0].edits[0].channels.video)
self.assertFalse( events[0].edits[0].channels.a1)
self.assertTrue( events[0].edits[0].channels.a2)
self.assertTrue( events[2].edits[0].channels.get_audio_channel(7) )
self.assertTrue( events[2].edits[0].channels.audio)

events = list(edl.events)
self.assertFalse(events[0].edits[0].channels.video)
self.assertFalse(events[0].edits[0].channels.a1)
self.assertTrue(events[0].edits[0].channels.a2)
self.assertTrue(events[2].edits[0].channels.get_audio_channel(7))
self.assertTrue(events[2].edits[0].channels.audio)

def test_multi_edit_events(self):
with open("tests/edls/TEST.edl",'r') as f:
with open("tests/edls/TEST.edl", 'r') as f:
edl = pycmx.parse_cmx3600(f)
events = list( edl.events )

self.assertEqual( events[42].number , 43)
self.assertEqual( len(events[42].edits), 2)

self.assertEqual( events[42].edits[0].source , "TC_R1_V1")
self.assertEqual( events[42].edits[0].clip_name , "TC R1 V1.2 TEMP1 FX ST.WAV")
self.assertEqual( events[42].edits[0].source_in , "00:00:00:00")
self.assertEqual( events[42].edits[0].source_out , "00:00:00:00")
self.assertEqual( events[42].edits[0].record_in , "01:08:56:09")
self.assertEqual( events[42].edits[0].record_out , "01:08:56:09")
self.assertTrue( events[42].edits[0].transition.kind == pycmx.Transition.Cut)

self.assertEqual( events[42].edits[1].source , "TC_R1_V6")
self.assertEqual( events[42].edits[1].clip_name , "TC R1 V6 TEMP2 ST FX.WAV")
self.assertEqual( events[42].edits[1].source_in , "00:00:00:00")
self.assertEqual( events[42].edits[1].source_out , "00:00:00:00")
self.assertEqual( events[42].edits[1].record_in , "01:08:56:09")
self.assertEqual( events[42].edits[1].record_out , "01:08:56:11")
self.assertTrue( events[42].edits[1].transition.kind == pycmx.Transition.Dissolve)
events = list(edl.events)

self.assertEqual(events[42].number, 43)
self.assertEqual(len(events[42].edits), 2)

self.assertEqual(events[42].edits[0].source, "TC_R1_V1")
self.assertEqual(events[42].edits[0].clip_name,
"TC R1 V1.2 TEMP1 FX ST.WAV")
self.assertEqual(events[42].edits[0].source_in, "00:00:00:00")
self.assertEqual(events[42].edits[0].source_out, "00:00:00:00")
self.assertEqual(events[42].edits[0].record_in, "01:08:56:09")
self.assertEqual(events[42].edits[0].record_out, "01:08:56:09")
self.assertTrue(
events[42].edits[0].transition.kind == pycmx.Transition.Cut)

self.assertEqual(events[42].edits[1].source, "TC_R1_V6")
self.assertEqual(events[42].edits[1].clip_name,
"TC R1 V6 TEMP2 ST FX.WAV")
self.assertEqual(events[42].edits[1].source_in, "00:00:00:00")
self.assertEqual(events[42].edits[1].source_out, "00:00:00:00")
self.assertEqual(events[42].edits[1].record_in, "01:08:56:09")
self.assertEqual(events[42].edits[1].record_out, "01:08:56:11")
self.assertTrue(
events[42].edits[1].transition.kind ==
pycmx.Transition.Dissolve)

def test_line_numbers(self):
with open("tests/edls/ToD_R4_LOCK3.1_030618_Video.edl") as f:
edl = pycmx.parse_cmx3600(f)

events = list( edl.events )
self.assertEqual( events[0].edits[0].line_number, 2)
self.assertEqual( events[14].edits[0].line_number, 45)
self.assertEqual( events[180].edits[0].line_number, 544)
events = list(edl.events)
self.assertEqual(events[0].edits[0].line_number, 2)
self.assertEqual(events[14].edits[0].line_number, 45)
self.assertEqual(events[180].edits[0].line_number, 544)

def test_transition_name(self):
with open("tests/edls/test_25.edl","r") as f:
with open("tests/edls/test_25.edl", "r") as f:
edl = pycmx.parse_cmx3600(f)
events = list(edl.events)
self.assertEqual( events[4].edits[1].transition.name , "CROSS DISSOLVE" )


# add test for edit_list.channels

self.assertEqual(
events[4].edits[1].transition.name, "CROSS DISSOLVE")

0 comments on commit 2be779f

Please sign in to comment.