def buildersConf(WGs=None): """ Return all the line builders in the module for a requested list of WG. """ _buildersConf = {} if not WGs: for wg in _strippingModules.keys(): for _sm in _strippingModules[wg]: duplicates = list( set(_buildersConf.keys()) & set(_getcon(_sm).keys())) if not duplicates: _buildersConf.update(_getcon(_sm)) else: print "The following names have already been used:" print ', '.join(duplicates) print "Please change the name of your configuration" sys.exit(1) elif any(WG for WG in _strippingModules.keys() if WG in WGs): for wg in WGs: for _sm in _strippingModules[wg]: duplicates = list( set(_buildersConf.keys()) & set(_getcon(_sm).keys())) if not duplicates: _buildersConf.update(_getcon(_sm)) else: print "The following names have already been used:" print ', '.join(duplicates) print "Please change the name of your configuration" sys.exit(1) else: raise Exception('The requested WG does not exists') return dict(_buildersConf)
from sys import modules as _modules _this = _modules[__name__] _strippingKeys = filter(lambda x: x[:9] == 'Stripping', locals().keys()) _strippingModules = [getattr(_this, _k) for _k in _strippingKeys] from StrippingUtils.Utils import getLineBuildersFromModule as _getter from StrippingUtils.Utils import getBuilderConfFromModule as _getcon _lineBuilders = {} _buildersConf = {} for _sm in _strippingModules: _lineBuilders.update(_getter(_sm)) _buildersConf.update(_getcon(_sm)) def lineBuilders(): """ Return all the line builders in the module. """ return dict(_lineBuilders) def buildersConf(): """ Return all the line builders in the module. """ return dict(_buildersConf)