Skip to content

Commit

Permalink
Merge pull request #223 from remia/code-maintenance
Browse files Browse the repository at this point in the history
Code maintenance
remia authored Mar 2, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents b3a5fa6 + 5ad7496 commit 1789d30
Showing 5 changed files with 32 additions and 22 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
@@ -7,17 +7,17 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.6, 3.9]
python-version: [3.6, 3.11]
steps:
- name: Clone repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Clone tests data repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: Ymagis/ClairMeta_Data
path: tests/resources
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up environment
@@ -33,20 +33,20 @@ jobs:
pipenv run pytest --doctest-modules
test-macos:
runs-on: macos-10.15
runs-on: macos-11
strategy:
matrix:
python-version: [3.6, 3.9]
python-version: [3.6, 3.11]
steps:
- name: Clone repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Clone tests data repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: Ymagis/ClairMeta_Data
path: tests/resources
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up environment
@@ -65,17 +65,17 @@ jobs:
runs-on: windows-2019
strategy:
matrix:
python-version: [3.6, 3.9]
python-version: [3.6, 3.11]
steps:
- name: Clone repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Clone tests data repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: Ymagis/ClairMeta_Data
path: tests/resources
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up environment
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -109,6 +109,8 @@ template (actual content listed below is for demonstration purposes only):
name can be incomplete to quickly ignore a bunch of tests, *default* is
used if no other match where found.
- *bypass* key allow specific test bypass, incomplete names are not allowed.
- *allowed_foreign_files* key specify files that are allowed in the DCP
folder and should not trigger the foreign file check.

.. code-block:: python
@@ -120,7 +122,8 @@ template (actual content listed below is for demonstration purposes only):
"check_picture_cpl_avg_bitrate": "WARNING",
"check_picture_cpl_resolution": "WARNING"
},
"bypass": ["check_assets_pkl_hash"]
"bypass": ["check_assets_pkl_hash"],
"allowed_foreign_files": ["md5.md5"]
}
Custom profile check:
14 changes: 11 additions & 3 deletions clairmeta/dcp_check.py
Original file line number Diff line number Diff line change
@@ -26,7 +26,13 @@ class CheckerBase(object):

ERROR_NAME_RE = re.compile(r"^\w+$")

def __init__(self, dcp, ov_path=None, hash_callback=None, bypass_list=None, allowed_foreign_files=None):
def __init__(
self,
dcp,
ov_path=None,
hash_callback=None,
bypass_list=None,
allowed_foreign_files=None):
""" CheckerBase constructor.
Args:
@@ -35,15 +41,17 @@ def __init__(self, dcp, ov_path=None, hash_callback=None, bypass_list=None, allo
hash_callback (function, optional): Callback function to report
file hash progression.
bypass_list (list, optional): List of checks to bypass.
allowed_foreign_files (list, optional): List of files allowed
in the DCP folder (don't trigger foreign files check).
"""
self.dcp = dcp
self.log = get_log()
self.checks = []
self.errors = []
self.report = None
self.bypass_list = bypass_list if bypass_list else []
self.allowed_foreign_files = allowed_foreign_files if allowed_foreign_files else []
self.bypass_list = bypass_list or []
self.allowed_foreign_files = allowed_foreign_files or []
self.check_modules = {}
self.ov_path = ov_path
self.ov_dcp = None
5 changes: 3 additions & 2 deletions clairmeta/dcp_check_global.py
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
from clairmeta.dcp_check import CheckerBase
from clairmeta.utils.sys import all_keys_in_dict


class Checker(CheckerBase):
def __init__(self, dcp):
super(Checker, self).__init__(dcp)
@@ -59,14 +60,14 @@ def check_dcp_foreign_files(self):
list_asset_path += self.dcp._list_vol_path
list_asset_path += self.dcp._list_am_path

allowed_foreign_files_path = [
allowed_paths = [
os.path.join(self.dcp.path, a)
for a in self.allowed_foreign_files]

self.dcp.foreign_files = [
os.path.relpath(a, self.dcp.path)
for a in self.dcp._list_files
if a not in list_asset_path and a not in allowed_foreign_files_path]
if a not in list_asset_path and a not in allowed_paths]
if self.dcp.foreign_files:
self.error('\n'.join(self.dcp.foreign_files))

4 changes: 1 addition & 3 deletions clairmeta/profile.py
Original file line number Diff line number Diff line change
@@ -47,9 +47,7 @@
# Checker options
# Bypass is a list of check names (function names)
'bypass': [],

# Allowed foreign files
# Paths are relative to the DCP root
# Allowed foreign files, paths are relative to the DCP root
'allowed_foreign_files' : [],
}

0 comments on commit 1789d30

Please sign in to comment.