From 76e37aae4735a82ee488383cdf9dff921b7896e7 Mon Sep 17 00:00:00 2001 From: PyvesB Date: Wed, 17 Jul 2019 09:24:38 +0100 Subject: [PATCH 01/16] Switch to absolute imports and update PyXB command accordingly --- Makefile | 4 ++-- ebu_tt_live/bindings/_ebuttdt.py | 4 ++-- ebu_tt_live/bindings/_ebuttlm.py | 6 +++--- ebu_tt_live/bindings/_ebuttm.py | 2 +- ebu_tt_live/bindings/_ebuttp.py | 2 +- ebu_tt_live/bindings/_ebutts.py | 2 +- ebu_tt_live/bindings/_ttm.py | 2 +- ebu_tt_live/bindings/_ttp.py | 2 +- ebu_tt_live/bindings/_tts.py | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 2eca73d96..86ace226c 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ all: init ui init: pip install --upgrade -r requirements.txt - pyxbgen --binding-root=./ebu_tt_live/bindings -m __init__ --schema-root=./ebu_tt_live/xsd/ -r -u ebutt_all.xsd + pyxbgen --binding-root=. -m __init__ --schema-root=./ebu_tt_live/xsd/ -r -u ebutt_all.xsd --module-prefix=ebu_tt_live.bindings initnpm: ifeq ("$(wildcard node_modules)","") @@ -20,7 +20,7 @@ docs: python setup.py build_sphinx bindings: - pyxbgen --binding-root=./ebu_tt_live/bindings -m __init__ --schema-root=./ebu_tt_live/xsd/ -r -u ebutt_all.xsd + pyxbgen --binding-root=. -m __init__ --schema-root=./ebu_tt_live/xsd/ -r -u ebutt_all.xsd --module-prefix=ebu_tt_live.bindings ui: uiclean uibuild diff --git a/ebu_tt_live/bindings/_ebuttdt.py b/ebu_tt_live/bindings/_ebuttdt.py index 82d4dfb8b..e5aced3ce 100644 --- a/ebu_tt_live/bindings/_ebuttdt.py +++ b/ebu_tt_live/bindings/_ebuttdt.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from raw._ebuttdt import * -from raw import _ebuttdt as ebuttdt_raw +from ebu_tt_live.bindings.raw._ebuttdt import * +from ebu_tt_live.bindings.raw import _ebuttdt as ebuttdt_raw from datetime import timedelta from decimal import Decimal import re, logging diff --git a/ebu_tt_live/bindings/_ebuttlm.py b/ebu_tt_live/bindings/_ebuttlm.py index 66ec2d8b1..529382da7 100644 --- a/ebu_tt_live/bindings/_ebuttlm.py +++ b/ebu_tt_live/bindings/_ebuttlm.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from raw._ebuttlm import * -from raw import _ebuttlm as raw -from raw import _ebuttp as ebuttp +from ebu_tt_live.bindings.raw._ebuttlm import * +from ebu_tt_live.bindings.raw import _ebuttlm as raw +from ebu_tt_live.bindings.raw import _ebuttp as ebuttp from pyxb.utils.domutils import BindingDOMSupport diff --git a/ebu_tt_live/bindings/_ebuttm.py b/ebu_tt_live/bindings/_ebuttm.py index 095d403ea..1c3d9bffc 100644 --- a/ebu_tt_live/bindings/_ebuttm.py +++ b/ebu_tt_live/bindings/_ebuttm.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -from raw._ebuttm import * +from ebu_tt_live.bindings.raw._ebuttm import * diff --git a/ebu_tt_live/bindings/_ebuttp.py b/ebu_tt_live/bindings/_ebuttp.py index 891cf0c53..1fe1c1c60 100644 --- a/ebu_tt_live/bindings/_ebuttp.py +++ b/ebu_tt_live/bindings/_ebuttp.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -from raw._ebuttp import * +from ebu_tt_live.bindings.raw._ebuttp import * diff --git a/ebu_tt_live/bindings/_ebutts.py b/ebu_tt_live/bindings/_ebutts.py index 791501641..73494fc51 100644 --- a/ebu_tt_live/bindings/_ebutts.py +++ b/ebu_tt_live/bindings/_ebutts.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -from raw._ebutts import * +from ebu_tt_live.bindings.raw._ebutts import * diff --git a/ebu_tt_live/bindings/_ttm.py b/ebu_tt_live/bindings/_ttm.py index 5a4e38dcc..8c5347a94 100644 --- a/ebu_tt_live/bindings/_ttm.py +++ b/ebu_tt_live/bindings/_ttm.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -from raw._ttm import * +from ebu_tt_live.bindings.raw._ttm import * diff --git a/ebu_tt_live/bindings/_ttp.py b/ebu_tt_live/bindings/_ttp.py index 0d10a8339..c238a031f 100644 --- a/ebu_tt_live/bindings/_ttp.py +++ b/ebu_tt_live/bindings/_ttp.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -from raw._ttp import * +from ebu_tt_live.bindings.raw._ttp import * diff --git a/ebu_tt_live/bindings/_tts.py b/ebu_tt_live/bindings/_tts.py index 1e93d1080..8cd7e2c0c 100644 --- a/ebu_tt_live/bindings/_tts.py +++ b/ebu_tt_live/bindings/_tts.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -from raw._tts import * +from ebu_tt_live.bindings.raw._tts import * From d8213a82f11cb5020df2bf9e21cf99cf021b9b56 Mon Sep 17 00:00:00 2001 From: PyvesB Date: Wed, 17 Jul 2019 09:27:22 +0100 Subject: [PATCH 02/16] Replace usage of reserved async keyword --- ebu_tt_live/test/test_utils.py | 2 +- ebu_tt_live/utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ebu_tt_live/test/test_utils.py b/ebu_tt_live/test/test_utils.py index d583430ce..5c8dc6aea 100644 --- a/ebu_tt_live/test/test_utils.py +++ b/ebu_tt_live/test/test_utils.py @@ -75,7 +75,7 @@ class TestRotatingFileBufferSync(RFBCommon): def setUp(self): super(TestRotatingFileBufferSync, self).setUp() - self.instance = RotatingFileBuffer(maxlen=3, async=False) + self.instance = RotatingFileBuffer(maxlen=3, asynchronous=False) def test_one_file(self): file1 = self._create_a_file(1) diff --git a/ebu_tt_live/utils.py b/ebu_tt_live/utils.py index 000598249..0ef4a0ec7 100644 --- a/ebu_tt_live/utils.py +++ b/ebu_tt_live/utils.py @@ -114,12 +114,12 @@ class RotatingFileBuffer(RingBufferWithCallback): _deletion_thread = None _deletion_queue = None - def __init__(self, maxlen, async=True): + def __init__(self, maxlen, asynchronous=True): super(RotatingFileBuffer, self).__init__(maxlen=maxlen, callback=self.delete_file) # In this case threads make sense since it is I/O we are going to be waiting for and that is releasing the GIL. # Deletion is the means for us to send down files for deletion to the other thread(maybe process later).... self._deletion_queue = Queue.Queue() - if async is True: + if asynchronous is True: self._deletion_thread = StoppableThread( target=self._delete_thread_loop, kwargs={'q': self._deletion_queue} From be57ec4d18c02ca8389ea25987181da7e638ab85 Mon Sep 17 00:00:00 2001 From: PyvesB Date: Wed, 17 Jul 2019 09:31:31 +0100 Subject: [PATCH 03/16] Run 2to3 utility --- docs/source/conf.py | 18 ++++---- ebu_tt_live/adapters/base.py | 8 ++-- .../test/test_document_data_adapters.py | 2 +- ebu_tt_live/bindings/__init__.py | 6 +-- ebu_tt_live/bindings/_ebuttdt.py | 10 +---- .../bindings/converters/ebutt3_ebuttd.py | 2 +- ebu_tt_live/bindings/test/test_sizing.py | 44 +++++++++---------- ebu_tt_live/bindings/validation/content.py | 8 ++-- ebu_tt_live/bindings/validation/timing.py | 10 ++--- ebu_tt_live/carriage/interface.py | 3 +- .../carriage/test/test_base_carriage.py | 12 ++--- ebu_tt_live/config/adapters.py | 2 +- ebu_tt_live/config/carriage.py | 4 +- ebu_tt_live/config/common.py | 6 +-- ebu_tt_live/documents/ebutt3.py | 12 ++--- ...st_deduplicationReplaceStylesAndRegions.py | 2 +- .../documents/test/test_memory_profile.py | 4 +- ebu_tt_live/node/base.py | 2 +- ebu_tt_live/node/deduplicator.py | 10 ++--- ebu_tt_live/node/interface.py | 3 +- ebu_tt_live/node/producer.py | 2 +- ebu_tt_live/node/test/test_distributing.py | 2 +- ebu_tt_live/scripts/ebu_dummy_encoder.py | 4 +- ebu_tt_live/scripts/ebu_interactive_shell.py | 2 +- ebu_tt_live/scripts/ebu_simple_producer.py | 2 +- ebu_tt_live/scripts/test/test_scripts.py | 2 +- ebu_tt_live/twisted/__init__.py | 2 +- .../twisted/test/test_twisted_websocket.py | 42 +++++++++--------- ebu_tt_live/twisted/websocket.py | 2 +- ebu_tt_live/utils.py | 14 +++--- testing/bdd/test_handover.py | 2 +- testing/bdd/test_segmentation.py | 4 +- testing/test_integration.py | 2 +- 33 files changed, 119 insertions(+), 131 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 63747f37c..c58084f83 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -68,18 +68,18 @@ master_doc = 'index' # General information about the project. -project = u'EBU-TT-Live Toolkit' -copyright = u'2017, European Broadcasting Union' -author = u'European Broadcasting Union' +project = 'EBU-TT-Live Toolkit' +copyright = '2017, European Broadcasting Union' +author = 'European Broadcasting Union' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u'2.1.1' +version = '2.1.1' # The full version, including alpha/beta/rc tags. -release = u'2.1.1' +release = '2.1.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -279,8 +279,8 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'EBU-TT-LiveToolkit.tex', u'EBU-TT-Live Toolkit Documentation', - u'European Broadcasting Union', 'manual'), + (master_doc, 'EBU-TT-LiveToolkit.tex', 'EBU-TT-Live Toolkit Documentation', + 'European Broadcasting Union', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -315,7 +315,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'ebu-tt-livetoolkit', u'EBU-TT-Live Toolkit Documentation', + (master_doc, 'ebu-tt-livetoolkit', 'EBU-TT-Live Toolkit Documentation', [author], 1) ] @@ -330,7 +330,7 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'EBU-TT-LiveToolkit', u'EBU-TT-Live Toolkit Documentation', + (master_doc, 'EBU-TT-LiveToolkit', 'EBU-TT-Live Toolkit Documentation', author, 'EBU-TT-LiveToolkit', 'One line description of project.', 'Miscellaneous'), ] diff --git a/ebu_tt_live/adapters/base.py b/ebu_tt_live/adapters/base.py index 8e28b6336..0baf24164 100644 --- a/ebu_tt_live/adapters/base.py +++ b/ebu_tt_live/adapters/base.py @@ -9,11 +9,10 @@ # ========== -class IDocumentDataAdapter(object): +class IDocumentDataAdapter(object, metaclass=AutoRegisteringABCMeta): """ This adapter is used to do various conversions on the payload between the carriage and the node """ - __metaclass__ = AutoRegisteringABCMeta __impl_registry = {} _expects = AbstractStaticMember(validate_types_only) @@ -24,7 +23,7 @@ def auto_register_impl(cls, impl_class): impl_expects = impl_class.expects() provides_map = cls.__impl_registry.setdefault(impl_expects, weakref.WeakValueDictionary()) impl_provides = impl_class.provides() - if impl_provides in provides_map.keys(): + if impl_provides in list(provides_map.keys()): log.warning( '({} -> {}) adapter already registered: {}. Ignoring: {} '.format( impl_expects, @@ -83,14 +82,13 @@ def convert_data(self, data, **kwargs): raise NotImplementedError() -class INodeCarriageAdapter(object): +class INodeCarriageAdapter(object, metaclass=AutoRegisteringABCMeta): """ This adapter wraps the DocumentDataAdapter conversion logic and shows a dual interface. It responsibility is to facilitate direct communication between incompatible carriage mechanisms and processing nodes. This is a tricky business because this class does not have a hardcoded expects-provides interface contract. It works it out as it goes forward from the parameters. """ - __metaclass__ = AutoRegisteringABCMeta @abstractproperty def data_adapters(self): diff --git a/ebu_tt_live/adapters/test/test_document_data_adapters.py b/ebu_tt_live/adapters/test/test_document_data_adapters.py index b98601e45..d3b593bb8 100644 --- a/ebu_tt_live/adapters/test/test_document_data_adapters.py +++ b/ebu_tt_live/adapters/test/test_document_data_adapters.py @@ -91,7 +91,7 @@ def _assert_output_type(self, result): self.assertIsInstance(result, self._output_type) def _assert_kwargs_passtrough(self, result_kwargs, expected_keys): - self.assertEquals(set(result_kwargs.keys()), set(expected_keys)) + self.assertEqual(set(result_kwargs.keys()), set(expected_keys)) def _get_xml(self): with open(self._test_xml_path, 'r') as xml_file: diff --git a/ebu_tt_live/bindings/__init__.py b/ebu_tt_live/bindings/__init__.py index 4b1eb4347..379e270a2 100644 --- a/ebu_tt_live/bindings/__init__.py +++ b/ebu_tt_live/bindings/__init__.py @@ -101,7 +101,7 @@ class style_type(StyledElementMixin, IDMixin, SizingValidationMixin, SemanticVal _default_attrs = None def __repr__(self): - return u'