From 95c1c46be8a93009cbf049a8cf3206c44b24221d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Clemens=20Kornd=C3=B6rfer?= Date: Mon, 8 May 2023 16:26:54 +0200 Subject: [PATCH] Skip non-python files in the module loader --- .../robot_interface_collection.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/micropsi_integration_sdk/robot_interface_collection.py b/micropsi_integration_sdk/robot_interface_collection.py index f4bc292..688697f 100644 --- a/micropsi_integration_sdk/robot_interface_collection.py +++ b/micropsi_integration_sdk/robot_interface_collection.py @@ -73,12 +73,14 @@ def load_interface(self, filepath): spec = importlib.util.spec_from_file_location( name=module_id, location=str(filepath / '__init__.py'), submodule_search_locations=[str(filepath)]) - else: + elif filepath.suffix == ".py": spec = importlib.util.spec_from_file_location(name=module_id, location=str(filepath)) - module = importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) - for _, obj in inspect.getmembers(module): - self.register_interface(obj) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + for _, obj in inspect.getmembers(module): + self.register_interface(obj) + else: + logger.info("Skipping non-python file %s" % filepath) def load_interface_directory(self, path): """