Commit b244f2c9 authored by eric pellegrini's avatar eric pellegrini

Merge branch 'hotfix-1.0.3.e'

parents a0efd1bf bf2f8ec4
Pipeline #1170 passed with stages
in 9 minutes and 51 seconds
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
......
......@@ -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.
......@@ -104,17 +118,19 @@ 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:
if macros:
moduleName,_ = os.path.splitext(moduleFile)
filehandler,path,description = imp.find_module(moduleName, [moduleDir])
mod = imp.load_module(moduleName,filehandler,path,description)
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):
'''
......
......@@ -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)
__version__ = "1.0.3.d"
__version__ = "1.0.3.e"
__date__ = "18-11-2016"
......
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