From 7b4a76448e4c7d3d7eec39c8dfbf97dd2f641303 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Thu, 3 Jan 2019 19:28:48 -0800 Subject: [PATCH] Changed a format string in the tests so 3.5 should build --- .travis.yml | 1 + pycmx/channel_map.py | 8 ++++++++ pycmx/edit_list.py | 15 +++++++++++++++ setup.py | 3 ++- tests/test_parse.py | 11 ++++++++--- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 55e8777..d23d520 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: python python: - "3.6" + - "3.5" script: - "python3 setup.py test" install: diff --git a/pycmx/channel_map.py b/pycmx/channel_map.py index c32dcea..fea8d3c 100644 --- a/pycmx/channel_map.py +++ b/pycmx/channel_map.py @@ -96,3 +96,11 @@ class ChannelMap: self.a3 = ext.audio3 self.a4 = ext.audio4 + def __or__(self, other): + """ + Return the logical union of this channel map with another + """ + out_v = self.video | other.video + out_a = self._audio_channel_set | other._audio_channel_set + + return ChannelMap(v=out_v,audio_channels = out_a) diff --git a/pycmx/edit_list.py b/pycmx/edit_list.py index 0d1577d..8a7908d 100644 --- a/pycmx/edit_list.py +++ b/pycmx/edit_list.py @@ -3,6 +3,7 @@ from .parse_cmx_statements import (StmtUnrecognized, StmtFCM, StmtEvent, StmtSourceUMID) from .event import Event +from .channel_map import ChannelMap class EditList: """ @@ -35,6 +36,20 @@ class EditList: return 'unknown' + @property + def channels(self): + """ + Return the union of every channel channel. + """ + + retval = ChannelMap() + for event in self.events: + for edit in event.edits: + retval = retval | edit.channels + + return retval + + @property def title(self): """ diff --git a/setup.py b/setup.py index 1a10a2d..fb21321 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ setup(name='pycmx', 'Topic :: Multimedia :: Video', 'Topic :: Text Processing', 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.6' + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6' ], packages=['pycmx']) diff --git a/tests/test_parse.py b/tests/test_parse.py index 564eacd..52b1ef3 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -21,7 +21,8 @@ class TestParse(TestCase): with open(f"tests/edls/{fn}" ,'r') as f: edl = pycmx.parse_cmx3600(f) actual = len( list( edl.events )) - self.assertTrue( actual == count , f"expected {count} in file {fn} but found {actual}") + 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: @@ -29,7 +30,7 @@ class TestParse(TestCase): edl = pycmx.parse_cmx3600(f) self.assertTrue( type(edl.title) is str ) self.assertTrue( len(edl.title) > 0 ) - + def test_event_sanity(self): for fn in type(self).files: @@ -45,7 +46,7 @@ class TestParse(TestCase): 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") @@ -104,3 +105,7 @@ class TestParse(TestCase): 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 +