Merge branch 'mplegendre-multi_pkgsrc_roots' into develop
- This moves var/spack/packages to var/spack/repos/builtin/packages. - Packages that did not exist in the source branch, or were changed in develop, were moved into var/spack/repos/builtin/packages as part of the integration. Conflicts: lib/spack/spack/test/unit_install.py var/spack/repos/builtin/packages/clang/package.py
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
import re
|
||||
import sys
|
||||
import functools
|
||||
import collections
|
||||
import inspect
|
||||
|
||||
# Ignore emacs backups when listing modules
|
||||
@@ -167,16 +168,32 @@ def has_method(cls, name):
|
||||
return False
|
||||
|
||||
|
||||
def memoized(obj):
|
||||
class memoized(object):
|
||||
"""Decorator that caches the results of a function, storing them
|
||||
in an attribute of that function."""
|
||||
cache = obj.cache = {}
|
||||
@functools.wraps(obj)
|
||||
def memoizer(*args, **kwargs):
|
||||
if args not in cache:
|
||||
cache[args] = obj(*args, **kwargs)
|
||||
return cache[args]
|
||||
return memoizer
|
||||
def __init__(self, func):
|
||||
self.func = func
|
||||
self.cache = {}
|
||||
|
||||
|
||||
def __call__(self, *args):
|
||||
if not isinstance(args, collections.Hashable):
|
||||
# Not hashable, so just call the function.
|
||||
return self.func(*args)
|
||||
|
||||
if args not in self.cache:
|
||||
self.cache[args] = self.func(*args)
|
||||
return self.cache[args]
|
||||
|
||||
|
||||
def __get__(self, obj, objtype):
|
||||
"""Support instance methods."""
|
||||
return functools.partial(self.__call__, obj)
|
||||
|
||||
|
||||
def clear(self):
|
||||
"""Expunge cache so that self.func will be called again."""
|
||||
self.cache.clear()
|
||||
|
||||
|
||||
def list_modules(directory, **kwargs):
|
||||
|
@@ -63,35 +63,46 @@ def msg(message, *args):
|
||||
def info(message, *args, **kwargs):
|
||||
format = kwargs.get('format', '*b')
|
||||
stream = kwargs.get('stream', sys.stdout)
|
||||
wrap = kwargs.get('wrap', False)
|
||||
|
||||
cprint("@%s{==>} %s" % (format, cescape(str(message))), stream=stream)
|
||||
for arg in args:
|
||||
lines = textwrap.wrap(
|
||||
str(arg), initial_indent=indent, subsequent_indent=indent)
|
||||
for line in lines:
|
||||
stream.write(line + '\n')
|
||||
if wrap:
|
||||
lines = textwrap.wrap(
|
||||
str(arg), initial_indent=indent, subsequent_indent=indent)
|
||||
for line in lines:
|
||||
stream.write(line + '\n')
|
||||
else:
|
||||
stream.write(indent + str(arg) + '\n')
|
||||
|
||||
|
||||
def verbose(message, *args):
|
||||
def verbose(message, *args, **kwargs):
|
||||
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:
|
||||
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):
|
||||
info("Error: " + str(message), *args, format='*r', stream=sys.stderr)
|
||||
def error(message, *args, **kwargs):
|
||||
kwargs.setdefault('format', '*r')
|
||||
kwargs.setdefault('stream', sys.stderr)
|
||||
info("Error: " + str(message), *args, **kwargs)
|
||||
|
||||
|
||||
def warn(message, *args):
|
||||
info("Warning: " + str(message), *args, format='*Y', stream=sys.stderr)
|
||||
def warn(message, *args, **kwargs):
|
||||
kwargs.setdefault('format', '*Y')
|
||||
kwargs.setdefault('stream', sys.stderr)
|
||||
info("Warning: " + str(message), *args, **kwargs)
|
||||
|
||||
|
||||
def die(message, *args):
|
||||
error(message, *args)
|
||||
def die(message, *args, **kwargs):
|
||||
error(message, *args, **kwargs)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
@@ -210,6 +210,13 @@ def colify(elts, **options):
|
||||
|
||||
|
||||
def colify_table(table, **options):
|
||||
"""Version of colify() for data expressed in rows, (list of lists).
|
||||
|
||||
Same as regular colify but takes a list of lists, where each
|
||||
sub-list must be the same length, and each is interpreted as a
|
||||
row in a table. Regular colify displays a sequential list of
|
||||
values in columns.
|
||||
"""
|
||||
if table is None:
|
||||
raise TypeError("Can't call colify_table on NoneType")
|
||||
elif not table or not table[0]:
|
||||
|
Reference in New Issue
Block a user