Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
MDANSE
Commits
a184b8a4
Commit
a184b8a4
authored
Nov 22, 2016
by
eric pellegrini
Browse files
bug fix path_to_module function: the list of directories has to be parsed backwards
parent
2e716547
Changes
1
Hide whitespace changes
Inline
Side-by-side
MDANSE/Core/ClassRegistry.py
View file @
a184b8a4
...
...
@@ -42,13 +42,13 @@ def path_to_module(path,stop=""):
path
,
_
=
os
.
path
.
splitext
(
path
)
splittedPath
=
path
.
split
(
os
.
sep
)
try
:
idx
=
splittedPath
.
index
(
stop
)
idx
=
splittedPath
[::
-
1
]
.
index
(
stop
)
except
ValueError
:
idx
=
0
finally
:
module
=
"."
.
join
(
splittedPath
[
idx
:])
module
=
"."
.
join
(
splittedPath
[
len
(
splittedPath
)
-
1
-
idx
:])
return
module
...
...
@@ -110,14 +110,14 @@ class ClassRegistry(object):
:param packageDir: the package for which all modules should be imported
:type packageDir: str
'''
for
module
in
glob
.
glob
(
os
.
path
.
join
(
packageDir
,
'*.py'
)):
moduleDir
,
moduleFile
=
os
.
path
.
split
(
module
)
if
moduleFile
==
'__init__.py'
:
continue
# Any error that may occur here has to be caught. In such case the module is skipped.
try
:
if
macros
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment