Make text wrapping off by default in tty, add a kwarg for it.
This commit is contained in:
parent
b02faf5641
commit
05b30bf83e
@ -63,35 +63,46 @@ def msg(message, *args):
|
|||||||
def info(message, *args, **kwargs):
|
def info(message, *args, **kwargs):
|
||||||
format = kwargs.get('format', '*b')
|
format = kwargs.get('format', '*b')
|
||||||
stream = kwargs.get('stream', sys.stdout)
|
stream = kwargs.get('stream', sys.stdout)
|
||||||
|
wrap = kwargs.get('wrap', False)
|
||||||
|
|
||||||
cprint("@%s{==>} %s" % (format, cescape(str(message))), stream=stream)
|
cprint("@%s{==>} %s" % (format, cescape(str(message))), stream=stream)
|
||||||
for arg in args:
|
for arg in args:
|
||||||
|
if wrap:
|
||||||
lines = textwrap.wrap(
|
lines = textwrap.wrap(
|
||||||
str(arg), initial_indent=indent, subsequent_indent=indent)
|
str(arg), initial_indent=indent, subsequent_indent=indent)
|
||||||
for line in lines:
|
for line in lines:
|
||||||
stream.write(line + '\n')
|
stream.write(line + '\n')
|
||||||
|
else:
|
||||||
|
stream.write(indent + str(arg) + '\n')
|
||||||
|
|
||||||
|
|
||||||
def verbose(message, *args):
|
def verbose(message, *args, **kwargs):
|
||||||
if _verbose:
|
if _verbose:
|
||||||
info(message, *args, format='c')
|
kwargs.setdefault('format', 'c')
|
||||||
|
info(message, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def debug(message, *args):
|
def debug(message, *args, **kwargs):
|
||||||
if _debug:
|
if _debug:
|
||||||
info(message, *args, format='g', stream=sys.stderr)
|
kwargs.setdefault('format', 'g')
|
||||||
|
kwargs.setdefault('stream', sys.stderr)
|
||||||
|
info(message, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def error(message, *args):
|
def error(message, *args, **kwargs):
|
||||||
info("Error: " + str(message), *args, format='*r', stream=sys.stderr)
|
kwargs.setdefault('format', '*r')
|
||||||
|
kwargs.setdefault('stream', sys.stderr)
|
||||||
|
info("Error: " + str(message), *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def warn(message, *args):
|
def warn(message, *args, **kwargs):
|
||||||
info("Warning: " + str(message), *args, format='*Y', stream=sys.stderr)
|
kwargs.setdefault('format', '*Y')
|
||||||
|
kwargs.setdefault('stream', sys.stderr)
|
||||||
|
info("Warning: " + str(message), *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def die(message, *args):
|
def die(message, *args, **kwargs):
|
||||||
error(message, *args)
|
error(message, *args, **kwargs)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,8 +135,34 @@
|
|||||||
import spack.util.spack_yaml as syaml
|
import spack.util.spack_yaml as syaml
|
||||||
|
|
||||||
|
|
||||||
"""Dict from section names -> function to check section YAML format."""
|
"""Dict from section names -> schema for that section."""
|
||||||
valid_sections = ['compilers', 'mirrors', 'repos']
|
section_schemas = {
|
||||||
|
'compilers' : {
|
||||||
|
'$schema': 'http://json-schema.org/schema#',
|
||||||
|
'title' : 'Spack compiler configuration file schema',
|
||||||
|
'type' : 'object',
|
||||||
|
'properties' : {
|
||||||
|
'compilers' : {
|
||||||
|
'type' : 'map',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
'mirrors' : {
|
||||||
|
'$schema': 'http://json-schema.org/schema#',
|
||||||
|
'title' : 'Spack mirror configuration file schema',
|
||||||
|
'type' : 'map',
|
||||||
|
'properties' : {
|
||||||
|
'mirrors' : {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
'repos' : {
|
||||||
|
'$schema': 'http://json-schema.org/schema#',
|
||||||
|
'title' : 'Spack repository configuration file schema',
|
||||||
|
}}
|
||||||
|
|
||||||
"""OrderedDict of config scopes keyed by name.
|
"""OrderedDict of config scopes keyed by name.
|
||||||
Later scopes will override earlier scopes.
|
Later scopes will override earlier scopes.
|
||||||
@ -146,9 +172,9 @@
|
|||||||
|
|
||||||
def validate_section(section):
|
def validate_section(section):
|
||||||
"""Raise a ValueError if the section is not a valid section."""
|
"""Raise a ValueError if the section is not a valid section."""
|
||||||
if section not in valid_sections:
|
if section not in section_schemas:
|
||||||
raise ValueError("Invalid config section: '%s'. Options are %s."
|
raise ValueError("Invalid config section: '%s'. Options are %s."
|
||||||
% (section, valid_sections))
|
% (section, section_schemas))
|
||||||
|
|
||||||
|
|
||||||
class ConfigScope(object):
|
class ConfigScope(object):
|
||||||
@ -369,10 +395,12 @@ def update_config(section, update_data, scope=None):
|
|||||||
scope.write_section(section)
|
scope.write_section(section)
|
||||||
|
|
||||||
|
|
||||||
"""Print a configuration to stdout"""
|
|
||||||
def print_section(section):
|
def print_section(section):
|
||||||
|
"""Print a configuration to stdout."""
|
||||||
try:
|
try:
|
||||||
yaml.dump(get_config(section), stream=sys.stdout, default_flow_style=False)
|
data = syaml.syaml_dict()
|
||||||
|
data[section] = get_config(section)
|
||||||
|
syaml.dump(data, stream=sys.stdout, default_flow_style=False)
|
||||||
except (yaml.YAMLError, IOError) as e:
|
except (yaml.YAMLError, IOError) as e:
|
||||||
raise ConfigError("Error reading configuration: %s" % section)
|
raise ConfigError("Error reading configuration: %s" % section)
|
||||||
|
|
||||||
|
@ -858,7 +858,7 @@ def cleanup():
|
|||||||
tty.warn("Keeping install prefix in place despite error.",
|
tty.warn("Keeping install prefix in place despite error.",
|
||||||
"Spack will think this package is installed." +
|
"Spack will think this package is installed." +
|
||||||
"Manually remove this directory to fix:",
|
"Manually remove this directory to fix:",
|
||||||
self.prefix)
|
self.prefix, wrap=True)
|
||||||
|
|
||||||
|
|
||||||
def real_work():
|
def real_work():
|
||||||
|
Loading…
Reference in New Issue
Block a user