Commit a184b8a4 authored by eric pellegrini's avatar eric pellegrini

bug fix path_to_module function: the list of directories has to be parsed backwards

parent 2e716547
...@@ -42,13 +42,13 @@ def path_to_module(path,stop=""): ...@@ -42,13 +42,13 @@ def path_to_module(path,stop=""):
path, _ = os.path.splitext(path) path, _ = os.path.splitext(path)
splittedPath = path.split(os.sep) splittedPath = path.split(os.sep)
try: try:
idx = splittedPath.index(stop) idx = splittedPath[::-1].index(stop)
except ValueError: except ValueError:
idx = 0 idx = 0
finally: finally:
module = ".".join(splittedPath[idx:]) module = ".".join(splittedPath[len(splittedPath)-1-idx:])
return module return module
...@@ -110,14 +110,14 @@ class ClassRegistry(object): ...@@ -110,14 +110,14 @@ class ClassRegistry(object):
:param packageDir: the package for which all modules should be imported :param packageDir: the package for which all modules should be imported
:type packageDir: str :type packageDir: str
''' '''
for module in glob.glob(os.path.join(packageDir,'*.py')): for module in glob.glob(os.path.join(packageDir,'*.py')):
moduleDir, moduleFile = os.path.split(module) moduleDir, moduleFile = os.path.split(module)
if moduleFile == '__init__.py': if moduleFile == '__init__.py':
continue continue
# Any error that may occur here has to be caught. In such case the module is skipped. # Any error that may occur here has to be caught. In such case the module is skipped.
try: try:
if macros: if macros:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment