Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cigale
CIGALE
Commits
95d06ea1
Commit
95d06ea1
authored
Aug 26, 2013
by
Yannick Roehlly
Browse files
Use importlib.import_module for dynamic import
parent
941eecb0
Changes
2
Hide whitespace changes
Inline
Side-by-side
pcigale/sed/modules/common.py
View file @
95d06ea1
...
...
@@ -6,6 +6,7 @@ Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt
@author: Yannick Roehlly <yannick.roehlly@oamp.fr>
"""
from
importlib
import
import_module
def
complete_parameters
(
given_parameters
,
parameter_list
):
...
...
@@ -175,9 +176,7 @@ def get_module(name, **kwargs):
module_name
=
name
.
split
(
'.'
)[
0
]
try
:
# TODO Find a better way to do dynamic import
import_string
=
'from . import '
+
module_name
+
' as module'
exec
import_string
module
=
import_module
(
"."
+
module_name
,
'pcigale.sed.modules'
)
return
module
.
Module
(
name
=
name
,
**
kwargs
)
except
ImportError
:
print
(
'Module '
+
module_name
+
' does not exists!'
)
...
...
pcigale/stats/common.py
View file @
95d06ea1
...
...
@@ -6,6 +6,7 @@ Licensed under the CeCILL-v2 licence - see Licence_CeCILL_V2-en.txt
@author: Yannick Roehlly <yannick.roehlly@oamp.fr>
"""
from
importlib
import
import_module
class
AnalysisModule
(
object
):
...
...
@@ -152,9 +153,7 @@ def get_module(module_name):
"""
try
:
# TODO Find a better way to do dynamic import
import_string
=
'from . import '
+
module_name
+
' as module'
exec
import_string
module
=
import_module
(
'.'
+
module_name
,
'pcigale.stats'
)
return
module
.
Module
()
except
ImportError
:
print
(
'Module '
+
module_name
+
' does not exists!'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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