modules : added configuration file with disable keyword

This commit is contained in:
alalazo 2016-03-23 15:43:16 +01:00
parent cc582dd4b4
commit 0fbdb3f65d
2 changed files with 35 additions and 5 deletions

View File

@ -237,7 +237,29 @@
'type' : 'object', 'type' : 'object',
'default' : {}, 'default' : {},
} }
},},},},},} },},},},},},
'modules': {
'$schema': 'http://json-schema.org/schema#',
'title': 'Spack module file configuration file schema',
'type': 'object',
'additionalProperties': False,
'patternProperties': {
r'modules:?': {
'type': 'object',
'default': {},
'additionalProperties': False,
'properties': {
'disable': {
'type': 'array',
'default': [],
'items': {
'type': 'string'
}
}
}
},
},
},
} }
"""OrderedDict of config scopes keyed by name. """OrderedDict of config scopes keyed by name.
@ -405,11 +427,11 @@ def _read_config_file(filename, schema):
validate_section(data, schema) validate_section(data, schema)
return data return data
except MarkedYAMLError, e: except MarkedYAMLError as e:
raise ConfigFileError( raise ConfigFileError(
"Error parsing yaml%s: %s" % (str(e.context_mark), e.problem)) "Error parsing yaml%s: %s" % (str(e.context_mark), e.problem))
except IOError, e: except IOError as e:
raise ConfigFileError( raise ConfigFileError(
"Error reading configuration file %s: %s" % (filename, str(e))) "Error reading configuration file %s: %s" % (filename, str(e)))

View File

@ -48,6 +48,7 @@
import llnl.util.tty as tty import llnl.util.tty as tty
import spack import spack
import spack.config
from llnl.util.filesystem import join_path, mkdirp from llnl.util.filesystem import join_path, mkdirp
from spack.environment import * from spack.environment import *
@ -57,6 +58,13 @@
module_types = {} module_types = {}
def read_configuration_file():
f = spack.config.get_config('modules')
f.setdefault('disable', []) # Default : disable nothing
return f
CONFIGURATION = read_configuration_file()
def print_help(): def print_help():
"""For use by commands to tell user how to activate shell support.""" """For use by commands to tell user how to activate shell support."""
@ -115,8 +123,8 @@ class EnvModule(object):
class __metaclass__(type): class __metaclass__(type):
def __init__(cls, name, bases, dict): def __init__(cls, name, bases, dict):
type.__init__(cls, name, bases, dict) type.__init__(cls, name, bases, dict)
if cls.name != 'env_module': if cls.name != 'env_module' and cls.name not in CONFIGURATION['disable']:
module_types[cls.name] = cls module_types[cls.name] = cls
def __init__(self, spec=None): def __init__(self, spec=None):
self.spec = spec self.spec = spec