diff --git a/conformance-search/package-lock.json b/conformance-search/package-lock.json index 64f8954..d9194e7 100644 --- a/conformance-search/package-lock.json +++ b/conformance-search/package-lock.json @@ -1,12 +1,12 @@ { "name": "conformance-search", - "version": "0.0.0", + "version": "1.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "conformance-search", - "version": "0.0.0", + "version": "1.0.1", "dependencies": { "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", @@ -41,7 +41,7 @@ "copyfiles": "^2.4.1", "eslint": "^8.46.0", "eslint-config-airbnb": "^19.0.4", - "eslint-config-prettier": "^8.10.0", + "eslint-config-prettier": "^9.0.0", "eslint-import-resolver-typescript": "^3.5.5", "eslint-plugin-import": "^2.28.0", "eslint-plugin-jest": "^27.2.3", @@ -5106,9 +5106,9 @@ } }, "node_modules/eslint-config-prettier": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.10.0.tgz", - "integrity": "sha512-SM8AMJdeQqRYT9O9zguiruQZaN7+z+E4eAP9oiLNGKMtomwaB1E9dcgUD6ZAn/eQAb52USbvezbiljfZUhbJcg==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.0.0.tgz", + "integrity": "sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw==", "dev": true, "bin": { "eslint-config-prettier": "bin/cli.js" diff --git a/conformance-search/package.json b/conformance-search/package.json index 9412baa..9a9497b 100644 --- a/conformance-search/package.json +++ b/conformance-search/package.json @@ -52,7 +52,7 @@ "copyfiles": "^2.4.1", "eslint": "^8.46.0", "eslint-config-airbnb": "^19.0.4", - "eslint-config-prettier": "^8.10.0", + "eslint-config-prettier": "^9.0.0", "eslint-import-resolver-typescript": "^3.5.5", "eslint-plugin-import": "^2.28.0", "eslint-plugin-jest": "^27.2.3", diff --git a/src/construct/boxes.py b/src/construct/boxes.py index a33bdc9..993a44a 100644 --- a/src/construct/boxes.py +++ b/src/construct/boxes.py @@ -3,12 +3,14 @@ import json from glob import glob from loguru import logger +from functools import cache from dataclasses import dataclass, field from common import get_mp4ra_boxes BOXES = {} EXTENSIONS = {} +TYPE_HIERARCHY = {} @dataclass @@ -43,6 +45,22 @@ def serialize(self): } +@cache +def get_all_inheritors(cls): + """ + Get all inheritors of a class. Skip subclasses that are not in TYPE_HIERARCHY. + If requested class is not in TYPE_HIERARCHY, return a set with only the requested class. + """ + if cls not in TYPE_HIERARCHY: + return set([cls]) + subclasses = set(sc for sc in TYPE_HIERARCHY[cls] if sc in TYPE_HIERARCHY) + return ( + set([cls]) + | subclasses + | set(s for c in subclasses for s in get_all_inheritors(c)) + ) + + def get_all_boxes(json_file): with open(json_file, "r") as f: data = json.load(f) @@ -114,7 +132,8 @@ def update_container(_spec, _box): {"fourcc": container_box.fourcc, "type": container_box.type} ) else: - _box.containers.append({"fourcc": "*", "type": container_box["type"]}) + for inheritor in get_all_inheritors(container_box["type"]): + _box.containers.append({"fourcc": "*", "type": inheritor}) for container_box in [_box for _box in container_boxes if isinstance(_box, Box)]: if container_box.incomplete: @@ -135,6 +154,25 @@ def main(): for file in files: get_all_boxes(file) + # Get all available syntaxes + extract_syntax = re.compile( + r"(?:[Cc]lass\s*([a-zA-Z0-9]+).*extends\s*([a-zA-Z0-9]+)).*{", + flags=re.MULTILINE | re.DOTALL, + ) + syntaxes = set() + for value in BOXES.values(): + for _box in value: + matches = extract_syntax.findall(_box.syntax) + for match in matches: + syntaxes.add(match) + + # Extract type hierarchy + for cls, ext in syntaxes: + if ext not in TYPE_HIERARCHY: + TYPE_HIERARCHY[ext] = set() + TYPE_HIERARCHY[ext].add(cls) + + # Update containers for spec, boxes in BOXES.items(): for _box in boxes: update_container(spec, _box) diff --git a/src/poetry.lock b/src/poetry.lock index e8b6ee7..0302201 100644 --- a/src/poetry.lock +++ b/src/poetry.lock @@ -1,10 +1,9 @@ -# This file is automatically @generated by Poetry 1.4.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. [[package]] name = "attrs" version = "23.1.0" description = "Classes Without Boilerplate" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -23,7 +22,6 @@ tests-no-zope = ["cloudpickle", "hypothesis", "mypy (>=1.1.1)", "pympler", "pyte name = "beautifulsoup4" version = "4.12.2" description = "Screen-scraping library" -category = "main" optional = false python-versions = ">=3.6.0" files = [ @@ -42,7 +40,6 @@ lxml = ["lxml"] name = "certifi" version = "2023.7.22" description = "Python package for providing Mozilla's CA Bundle." -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -54,7 +51,6 @@ files = [ name = "charset-normalizer" version = "3.2.0" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." -category = "main" optional = false python-versions = ">=3.7.0" files = [ @@ -139,7 +135,6 @@ files = [ name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." -category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ @@ -151,7 +146,6 @@ files = [ name = "et-xmlfile" version = "1.1.0" description = "An implementation of lxml.xmlfile for the standard library" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -163,7 +157,6 @@ files = [ name = "gitdb" version = "4.0.10" description = "Git Object Database" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -178,7 +171,6 @@ smmap = ">=3.0.1,<6" name = "gitpython" version = "3.1.32" description = "GitPython is a Python library used to interact with Git repositories" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -193,7 +185,6 @@ gitdb = ">=4.0.1,<5" name = "idna" version = "3.4" description = "Internationalized Domain Names in Applications (IDNA)" -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -205,7 +196,6 @@ files = [ name = "iniconfig" version = "2.0.0" description = "brain-dead simple config-ini parsing" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -215,14 +205,13 @@ files = [ [[package]] name = "jsonschema" -version = "4.18.6" +version = "4.19.0" description = "An implementation of JSON Schema validation for Python" -category = "main" optional = false python-versions = ">=3.8" files = [ - {file = "jsonschema-4.18.6-py3-none-any.whl", hash = "sha256:dc274409c36175aad949c68e5ead0853aaffbe8e88c830ae66bb3c7a1728ad2d"}, - {file = "jsonschema-4.18.6.tar.gz", hash = "sha256:ce71d2f8c7983ef75a756e568317bf54bc531dc3ad7e66a128eae0d51623d8a3"}, + {file = "jsonschema-4.19.0-py3-none-any.whl", hash = "sha256:043dc26a3845ff09d20e4420d6012a9c91c9aa8999fa184e7efcfeccb41e32cb"}, + {file = "jsonschema-4.19.0.tar.gz", hash = "sha256:6e1e7569ac13be8139b2dd2c21a55d350066ee3f80df06c608b398cdc6f30e8f"}, ] [package.dependencies] @@ -239,7 +228,6 @@ format-nongpl = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339- name = "jsonschema-specifications" version = "2023.7.1" description = "The JSON Schema meta-schemas and vocabularies, exposed as a Registry" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -254,7 +242,6 @@ referencing = ">=0.28.0" name = "loguru" version = "0.7.0" description = "Python logging made (stupidly) simple" -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -273,7 +260,6 @@ dev = ["Sphinx (==5.3.0)", "colorama (==0.4.5)", "colorama (==0.4.6)", "freezegu name = "lxml" version = "4.9.3" description = "Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API." -category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, != 3.4.*" files = [ @@ -381,7 +367,6 @@ source = ["Cython (>=0.29.35)"] name = "openpyxl" version = "3.1.2" description = "A Python library to read/write Excel 2010 xlsx/xlsm files" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -396,7 +381,6 @@ et-xmlfile = "*" name = "packaging" version = "23.1" description = "Core utilities for Python packages" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -408,7 +392,6 @@ files = [ name = "pluggy" version = "1.2.0" description = "plugin and hook calling mechanisms for python" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -424,7 +407,6 @@ testing = ["pytest", "pytest-benchmark"] name = "pytest" version = "7.4.0" description = "pytest: simple powerful testing with Python" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -445,7 +427,6 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no name = "pytest-check" version = "2.2.0" description = "A pytest plugin that allows multiple failures per test." -category = "main" optional = false python-versions = ">3.7" files = [ @@ -460,7 +441,6 @@ pytest = "*" name = "pytest-dependency" version = "0.5.1" description = "Manage dependencies of tests" -category = "main" optional = false python-versions = "*" files = [ @@ -474,7 +454,6 @@ pytest = ">=3.6.0" name = "python-docx" version = "0.8.11" description = "Create and update Microsoft Word .docx files." -category = "main" optional = false python-versions = "*" files = [ @@ -488,7 +467,6 @@ lxml = ">=2.3.2" name = "referencing" version = "0.30.1" description = "JSON Referencing + Python" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -504,7 +482,6 @@ rpds-py = ">=0.7.0" name = "requests" version = "2.31.0" description = "Python HTTP for Humans." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -526,7 +503,6 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] name = "rpds-py" version = "0.9.2" description = "Python bindings to Rust's persistent data structures (rpds)" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -633,7 +609,6 @@ files = [ name = "smmap" version = "5.0.0" description = "A pure Python implementation of a sliding window memory map manager" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -645,7 +620,6 @@ files = [ name = "soupsieve" version = "2.4.1" description = "A modern CSS selector implementation for Beautiful Soup." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -657,7 +631,6 @@ files = [ name = "tqdm" version = "4.65.0" description = "Fast, Extensible Progress Meter" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -678,7 +651,6 @@ telegram = ["requests"] name = "urllib3" version = "2.0.4" description = "HTTP library with thread-safe connection pooling, file post, and more." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -696,7 +668,6 @@ zstd = ["zstandard (>=0.18.0)"] name = "win32-setctime" version = "1.1.0" description = "A small Python utility to set file creation time on Windows" -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -711,7 +682,6 @@ dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"] name = "xmltodict" version = "0.13.0" description = "Makes working with XML feel like you are working with JSON" -category = "main" optional = false python-versions = ">=3.4" files = [ @@ -722,4 +692,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "ef354c7444651fc7662a941ea780da98a1810e234383006a5428c80b392ba1a4" +content-hash = "b0822ba2320cc50373b702edcc5bda6470fcf6ee39c976cca028611adf0a17a7" diff --git a/src/pyproject.toml b/src/pyproject.toml index f11d86d..a230bda 100644 --- a/src/pyproject.toml +++ b/src/pyproject.toml @@ -19,7 +19,7 @@ python-docx = "^0.8.11" tqdm = "^4.65.0" loguru = "^0.7.0" gitpython = "^3.1.32" -jsonschema = "^4.18.4" +jsonschema = "^4.19.0" pytest-check = "^2.2.0" pytest-dependency = "^0.5.1" requests = "^2.31.0"