From 15a0d4318070ef9bd11620ac88a12150148e928b Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 28 Feb 2025 11:50:23 +0500 Subject: [PATCH] fix for glob pattern in 62d53ba62d --- src/ifcpatch/ifcpatch/__init__.py | 19 ++++++++++++++----- src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/ifcpatch/ifcpatch/__init__.py b/src/ifcpatch/ifcpatch/__init__.py index 51f37eacb8..3fb6573b2b 100644 --- a/src/ifcpatch/ifcpatch/__init__.py +++ b/src/ifcpatch/ifcpatch/__init__.py @@ -215,11 +215,18 @@ def _extract_docs(cls: type, method_name: str, boilerplate_args: Union[Sequence[ doc = inspect.getdoc(method) def is_valid_param_name(param_name: str) -> bool: - if param_name not in inputs: - print( - f"WARNING. Unexpected param name '{param_name}' in {cls.__name__} docstring (missing from signature)." - ) + assert ( + param_name in inputs + ), f"Unexpected param name '{param_name}' in {cls.__name__} docstring (missing from signature)." + return True + + def is_valid_filter_glob(filter_glob: str) -> bool: + # e.g. '*.ifc;*.ifczip;*.ifcxml' + if len(filter_glob) < 3: return False + for pattern in filter_glob.split(";"): + if not re.fullmatch(r"\*\.\w+", pattern): + return False return True if doc is None: @@ -238,7 +245,9 @@ def _extract_docs(cls: type, method_name: str, boilerplate_args: Union[Sequence[ for param_name in docstring_data["filter_glob"]: if not is_valid_param_name(param_name): continue - inputs[param_name]["filter_glob"] = docstring_data["filter_glob"][param_name] + filter_glob = docstring_data["filter_glob"][param_name] + assert is_valid_filter_glob(filter_glob), f"Invalid filter_glob pattern: '{filter_glob}'." + inputs[param_name]["filter_glob"] = filter_glob for param_name in inputs: if "description" not in inputs[param_name]: diff --git a/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py b/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py index 3eeeeb1f47..4df753cc5d 100644 --- a/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py +++ b/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py @@ -83,7 +83,7 @@ class Patcher: :param database: Database path to save the SQL database to (already existing or not). Could also be a directory, then the database will be stored using default filename (e.g. 'database.db'). - :filter_glob database: *.db,*.sqlite + :filter_glob database: *.db;*.sqlite :param full_schema: if True, will create tables for all IFC classes, regardless if they are used or not in the dataset. If False, will only create tables for classes in the dataset.