Skip to content

Commit

Permalink
Merge pull request #13 from micropsi-industries/skip_non_python_modules
Browse files Browse the repository at this point in the history
Skip non-python files in the module loader
  • Loading branch information
cknd authored May 10, 2023
2 parents bf069cd + 95c1c46 commit 395a3e3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions micropsi_integration_sdk/robot_interface_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 395a3e3

Please sign in to comment.