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
b244f2c9
Commit
b244f2c9
authored
Nov 18, 2016
by
eric pellegrini
Browse files
Merge branch 'hotfix-1.0.3.e'
parents
a0efd1bf
bf2f8ec4
Pipeline
#1170
passed with stages
in 9 minutes and 51 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
b244f2c9
version 1.0.3.c:
version 1.0.3.e:
----------------
* bug fix relative to REGISTRY update
version 1.0.3.d:
----------------
* redirected the sys.stdout and sys.stderr to the LOGGER
* implemented a write method so as ConsoleHandler behaves as a file-like object
...
...
@@ -16,7 +20,7 @@ version 1.0.3.c:
* removed unused imports
* removed white spaces
version 1.0.3.
b
:
version 1.0.3.
c
:
----------------
* bug fix with JobControllerPanel in case of crashing jobs
* regression fixed due to trials to get rid of relative imports MDANSE/Externals/pubsub package
...
...
MDANSE/Core/ClassRegistry.py
View file @
b244f2c9
...
...
@@ -34,10 +34,24 @@ import glob
import
imp
import
inspect
import
os
import
sys
from
MDANSE.Core.Singleton
import
Singleton
def
path_to_module
(
path
,
stop
=
""
):
path
,
_
=
os
.
path
.
splitext
(
path
)
splittedPath
=
path
.
split
(
os
.
sep
)
try
:
idx
=
splittedPath
.
index
(
stop
)
except
ValueError
:
idx
=
0
finally
:
module
=
"."
.
join
(
splittedPath
[
idx
:])
return
module
class
ClassRegistry
(
object
):
'''
Metaclass that registers the classes that make the MDANSE framework.
...
...
@@ -87,7 +101,7 @@ class ClassRegistry(object):
return
self
.
_registry
.
get
(
name
,{})
def
update
(
self
,
packageDir
):
def
update
(
self
,
packageDir
,
macros
=
False
):
'''
Update the classes registry by importing all the modules contained in a given package.
...
...
@@ -103,19 +117,21 @@ class ClassRegistry(object):
if
moduleFile
==
'__init__.py'
:
continue
moduleName
,
_
=
os
.
path
.
splitext
(
moduleFile
)
# Any error that may occur here has to be caught. In such case the module is skipped.
try
:
filehandler
,
path
,
description
=
imp
.
find_module
(
moduleName
,
[
moduleDir
])
mod
=
imp
.
load_module
(
moduleName
,
filehandler
,
path
,
description
)
if
macros
:
moduleName
,
_
=
os
.
path
.
splitext
(
moduleFile
)
filehandler
,
path
,
description
=
imp
.
find_module
(
moduleName
,
[
moduleDir
])
imp
.
load_module
(
moduleName
,
filehandler
,
path
,
description
)
filehandler
.
close
()
else
:
moduleName
,
_
=
os
.
path
.
splitext
(
moduleFile
)
module
=
path_to_module
(
module
,
stop
=
"MDANSE"
)
__import__
(
module
)
except
:
continue
else
:
if
os
.
path
.
abspath
(
os
.
path
.
dirname
(
mod
.
__file__
))
!=
os
.
path
.
abspath
(
moduleDir
):
print
"A module with name %s is already present in your distribution with %s path."
%
(
moduleName
,
moduleDir
)
def
info
(
self
,
interface
):
'''
Returns informations about the subclasses of a given base class stored in the registry.
...
...
MDANSE/Framework/__init__.py
View file @
b244f2c9
...
...
@@ -2,8 +2,8 @@ import os
from
MDANSE
import
PLATFORM
,
REGISTRY
REGISTRY
.
update
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"*"
))
REGISTRY
.
update
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"*"
)
,
False
)
macrosDirectories
=
sorted
([
x
[
0
]
for
x
in
os
.
walk
(
PLATFORM
.
macros_directory
())][
0
:])
for
d
in
macrosDirectories
:
REGISTRY
.
update
(
d
)
REGISTRY
.
update
(
d
,
True
)
MDANSE/__pkginfo__.py
View file @
b244f2c9
__version__
=
"1.0.3.
d
"
__version__
=
"1.0.3.
e
"
__date__
=
"18-11-2016"
...
...
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