diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aff863b..61c0144 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,7 +33,7 @@ repos: - id: trailing-whitespace # Leave black at the bottom so all touchups are done before it is run. - repo: https://github.com/ambv/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black language_version: python3 diff --git a/README.md b/README.md index dc52689..2dc04e8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ +[![VFX Platform](https://img.shields.io/badge/vfxplatform-2024%20%7C%202023%20%7C%202022%20%7C%202021-blue.svg)](http://www.vfxplatform.com/) +[![Python](https://img.shields.io/badge/python-3.11%20%7C%203.10%20%7C%203.9%20%7C%203.7-blue.svg)](https://www.python.org/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +[![Linting](https://img.shields.io/badge/PEP8%20by-Hound%20CI-a873d1.svg)](https://houndci.com) ## Documentation This repository is a part of the Flow Production Tracking Toolkit. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a35e2d3..78c2311 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -41,4 +41,4 @@ variables: jobs: - template: build-pipeline.yml@templates parameters: - has_unit_tests: false + has_unit_tests: true diff --git a/python/edl/edl.py b/python/edl/edl.py index e359fab..e503758 100644 --- a/python/edl/edl.py +++ b/python/edl/edl.py @@ -37,7 +37,7 @@ class EditProcessor(object): """ def __init__(self, shot_regexp=None): - super(EditProcessor, self).__init__() + super().__init__() self._previous_edit = None self._shot_regexp = shot_regexp @@ -579,7 +579,7 @@ def read_cmx_edl(self, path, fps=24, visitor=None): self._edits = [] # And read the file self.__logger.info("Parsing EDL %s" % path) - with open(path, "rU") as handle: + with open(path, "r", encoding="utf-8") as handle: edit = None id_offset = 0 try: diff --git a/python/edl/errors.py b/python/edl/errors.py index ae34737..9bdf142 100644 --- a/python/edl/errors.py +++ b/python/edl/errors.py @@ -29,9 +29,7 @@ def __init__(self, frame_value, frame_rate, *args, **kwargs): :param frame_rate: An integer, the frame rate for which the frame value caused the error. """ - super(BadFrameRateError, self).__init__( - self.__ERROR_MSG % (frame_value, frame_rate), *args, **kwargs - ) + super().__init__(self.__ERROR_MSG % (frame_value, frame_rate), *args, **kwargs) # Store value internally, in case some apps want to retrieve them self._frame_value = frame_value self._frame_rate = frame_rate @@ -80,7 +78,7 @@ def __init__(self, timecode_str, drop_frame, valid_delimiters, *args, **kwargs): with timecode string format. :param valid_delimiters: List of valid delimiters for drop frame notation. """ - super(BadDropFrameError, self).__init__( + super().__init__( self.__ERROR_MSG % (timecode_str, drop_frame, valid_delimiters), *args, **kwargs @@ -133,9 +131,7 @@ def __init__(self, edl_name, *args, **kwargs): :param edl_name: A string, the EDL file name. """ - super(UnsupportedEDLFeature, self).__init__( - self._error_message() % edl_name, *args, **kwargs - ) + super().__init__(self._error_message() % edl_name, *args, **kwargs) def _error_message(self): """ @@ -157,7 +153,7 @@ class BadBLError(UnsupportedEDLFeature): """ def _error_message(self): - """" + """ Return a standard error message to use as the exception message. :returns: A string @@ -172,7 +168,7 @@ class BadFCMError(UnsupportedEDLFeature): """ def _error_message(self): - """" + """ Return a standard error message to use as the exception message. :returns: A string diff --git a/python/edl/logger.py b/python/edl/logger.py index 7820351..71c748b 100644 --- a/python/edl/logger.py +++ b/python/edl/logger.py @@ -18,7 +18,7 @@ def __init__(self, framework, *args, **kwargs): :param framework: A Toolkit framework """ - super(FrameworkLogHandler, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self._framework = framework def emit(self, record): diff --git a/tests/README.md b/tests/README.md index d95f5c7..1ff29f9 100644 --- a/tests/README.md +++ b/tests/README.md @@ -4,8 +4,6 @@ Readme for Editorial framework tests Required packages ----------------- -* unittest2 -* mock * coverage (only if coverage option is used) Running the test suite diff --git a/tests/run_tests.py b/tests/run_tests.py index 64b3d43..b7b3d16 100644 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -4,11 +4,10 @@ # provided at the time of installation or download, or which otherwise accompanies # this software in either electronic or hard copy form. # -from __future__ import print_function import sys import os from optparse import OptionParser -import unittest2 as unittest +import unittest import logging logging.basicConfig(level=logging.INFO) @@ -38,9 +37,9 @@ def __init__(self): def setup_suite(self, test_name): # args used to specify specific module.TestCase.test if test_name: - self.suite = unittest.loader.TestLoader().loadTestsFromName(test_name) + self.suite = unittest.TestLoader().loadTestsFromName(test_name) else: - self.suite = unittest.loader.TestLoader().discover(self.test_path) + self.suite = unittest.TestLoader().discover(self.test_path) def run_tests_with_coverage(self, test_name): import coverage diff --git a/tests/test_read.py b/tests/test_read.py index 7078423..c3ea6ab 100644 --- a/tests/test_read.py +++ b/tests/test_read.py @@ -4,9 +4,16 @@ # provided at the time of installation or download, or which otherwise accompanies # this software in either electronic or hard copy form. # -import os import decimal -import unittest2 as unittest +import os +import sys +import unittest +import logging +import re + +repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +sys.path.insert(0, os.path.join(repo_root, "python")) + from edl import edl from edl import ( timecode, @@ -16,13 +23,11 @@ BadFrameRateError, BadFCMError, ) -import logging -import re class TestRead(unittest.TestCase): def __init__(self, *args, **kwargs): - super(TestRead, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self._edl_examples = [] self._unsupported_examples = [] self._resources_dir = None @@ -152,7 +157,10 @@ def test_advanced_visitor(self): # Check we are able to extract expected information from a well known # example path = os.path.join(self._multiple_tests_dir, "scan_request_test.edl") - tc = edl.EditList(file_path=path, visitor=self.advanced_visitor,) + tc = edl.EditList( + file_path=path, + visitor=self.advanced_visitor, + ) for edit in tc.edits: self.assertIsNotNone(edit._shot_name) self.assertIsNotNone(edit._name) @@ -302,7 +310,8 @@ def test_accessor_overrides(self): with self.assertRaises(AttributeError) as cm: for f in self._edl_examples: edl.EditList( - file_path=f, visitor=self.failing_property_override, + file_path=f, + visitor=self.failing_property_override, ) def test_tc_round_trip(self):