summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTom Scogland <scogland1@llnl.gov>2016-08-24 11:56:33 -0700
committerTom Scogland <scogland1@llnl.gov>2016-08-24 11:56:33 -0700
commit2b6833cb80b27e1b78730828a650ae86c2694a7c (patch)
treecdcc4dcd13b3cd67903a39a94b5557db56479047 /lib
parent73620fe868779841b6eb4ef5c2c2ebb92fbc28a2 (diff)
downloadspack-2b6833cb80b27e1b78730828a650ae86c2694a7c.tar.gz
spack-2b6833cb80b27e1b78730828a650ae86c2694a7c.tar.bz2
spack-2b6833cb80b27e1b78730828a650ae86c2694a7c.tar.xz
spack-2b6833cb80b27e1b78730828a650ae86c2694a7c.zip
appeasing flake8, also cleaning up header
The header append lines were too long, so I just converted it into a multi-line string template so it's all one piece now instead of a bunch of appends.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/modules.py81
1 files changed, 43 insertions, 38 deletions
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
index 042481aa1d..70c3c35d8c 100644
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -549,11 +549,13 @@ class TclModule(EnvModule):
def header(self):
timestamp = datetime.datetime.now()
# TCL Modulefile header
- header = '#%Module1.0\n'
- header += '## Module file created by spack (https://github.com/LLNL/spack) on %s\n' % timestamp
- header += '##\n'
- header += '## %s\n' % self.spec.short_spec
- header += '##\n'
+ header = """\
+#%%Module1.0
+## Module file created by spack (https://github.com/LLNL/spack) on %s
+##
+## %s
+##
+""" % (timestamp, self.spec.short_spec)
# TODO : category ?
# Short description
@@ -569,39 +571,42 @@ class TclModule(EnvModule):
return header
def process_environment_command(self, env):
- environment_modifications_formats_colon = {
- PrependPath: 'prepend-path {name} \"{value}\"\n',
- AppendPath: 'append-path {name} \"{value}\"\n',
- RemovePath: 'remove-path {name} \"{value}\"\n',
- SetEnv: 'setenv {name} \"{value}\"\n',
- UnsetEnv: 'unsetenv {name}\n'
- }
- environment_modifications_formats_general = {
- PrependPath: 'prepend-path --delim "{separator}" {name} \"{value}\"\n',
- AppendPath: 'append-path --delim "{separator}" {name} \"{value}\"\n',
- RemovePath: 'remove-path --delim "{separator}" {name} \"{value}\"\n',
- SetEnv: 'setenv {name} \"{value}\"\n',
- UnsetEnv: 'unsetenv {name}\n'
- }
- for command in env:
- # Token expansion from configuration file
- name = command.args.get('name', '').format(**self.upper_tokens)
- value = str(command.args.get('value', '')).format(**self.tokens)
- command.update_args(name=name, value=value)
- # Format the line int the module file
- try:
- if command.args.get('separator', ':') == ':':
- yield environment_modifications_formats_colon[type(
- command)].format(**command.args)
- else:
- yield environment_modifications_formats_general[type(
- command)].format(**command.args)
- except KeyError:
- message = ('Cannot handle command of type {command}: '
- 'skipping request')
- details = '{context} at {filename}:{lineno}'
- tty.warn(message.format(command=type(command)))
- tty.warn(details.format(**command.args))
+ environment_modifications_formats_colon = {
+ PrependPath: 'prepend-path {name} \"{value}\"\n',
+ AppendPath: 'append-path {name} \"{value}\"\n',
+ RemovePath: 'remove-path {name} \"{value}\"\n',
+ SetEnv: 'setenv {name} \"{value}\"\n',
+ UnsetEnv: 'unsetenv {name}\n'
+ }
+ environment_modifications_formats_general = {
+ PrependPath:
+ 'prepend-path --delim "{separator}" {name} \"{value}\"\n',
+ AppendPath:
+ 'append-path --delim "{separator}" {name} \"{value}\"\n',
+ RemovePath:
+ 'remove-path --delim "{separator}" {name} \"{value}\"\n',
+ SetEnv: 'setenv {name} \"{value}\"\n',
+ UnsetEnv: 'unsetenv {name}\n'
+ }
+ for command in env:
+ # Token expansion from configuration file
+ name = command.args.get('name', '').format(**self.upper_tokens)
+ value = str(command.args.get('value', '')).format(**self.tokens)
+ command.update_args(name=name, value=value)
+ # Format the line int the module file
+ try:
+ if command.args.get('separator', ':') == ':':
+ yield environment_modifications_formats_colon[type(
+ command)].format(**command.args)
+ else:
+ yield environment_modifications_formats_general[type(
+ command)].format(**command.args)
+ except KeyError:
+ message = ('Cannot handle command of type {command}: '
+ 'skipping request')
+ details = '{context} at {filename}:{lineno}'
+ tty.warn(message.format(command=type(command)))
+ tty.warn(details.format(**command.args))
def module_specific_content(self, configuration):
naming_tokens = self.tokens