From 23eb7cafae51319ccb6b5286989e058d29c5c9af Mon Sep 17 00:00:00 2001 From: Deniz Ugur Date: Thu, 31 Aug 2023 22:28:49 -0700 Subject: [PATCH 1/2] Fixes for `boxes.py` checks > Check if type has inheritors, if so it may be abstract class > Convert warning to error --- src/construct/boxes.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/construct/boxes.py b/src/construct/boxes.py index 993a44a2..0b277293 100644 --- a/src/construct/boxes.py +++ b/src/construct/boxes.py @@ -211,11 +211,20 @@ def main(): for container in _box.containers: if isinstance(container, dict): if "type" in container: - if container["type"] not in [_box.type for _box in all_boxes]: - # Ignore '*' - if container["type"] == "*": - continue - buffer.append(f"{container['type']}") + # If type is already in all_boxes, skip + if container["type"] in [_box.type for _box in all_boxes]: + continue + + # If type is in TYPE_HIERARCHY, skip + if container["type"] in TYPE_HIERARCHY: + continue + + # If type is *, skip + if container["type"] == "*": + continue + + # Could not find the type + buffer.append(f"{container['type']}") if len(buffer) > 0: logger.error(f"Unknown types ({len(set(buffer))}): {set(sorted(buffer))}") @@ -260,9 +269,8 @@ def main(): if _box.type == "": buffer.append(f"{_box.fourcc} ({_box.type})") - # FIXME: This should be an error if len(buffer) > 0: - logger.warning( + logger.error( f"Boxes with empty type ({len(set(buffer))}): {set(sorted(buffer))}" ) From 021c230afcf6fb4669272b59d3f9081ff26e45bf Mon Sep 17 00:00:00 2001 From: Deniz Ugur Date: Fri, 1 Sep 2023 10:53:27 -0700 Subject: [PATCH 2/2] empty fourcc check --- src/construct/boxes.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/construct/boxes.py b/src/construct/boxes.py index 0b277293..5a6917ae 100644 --- a/src/construct/boxes.py +++ b/src/construct/boxes.py @@ -274,6 +274,17 @@ def main(): f"Boxes with empty type ({len(set(buffer))}): {set(sorted(buffer))}" ) + # Show boxes with empty fourcc + buffer = [] + for _box in all_boxes: + if _box.incomplete: + continue + if _box.fourcc == "": + buffer.append(f"{_box.fourcc} ({_box.type})") + + if len(buffer) > 0: + logger.error(f"There are {len(set(buffer))} box(es) with empty fourcc") + # Show duplicates (same fourcc) buffer = [] for _box in all_boxes: