modules : turned category into a property (logic can be extended later)

This commit is contained in:
alalazo 2016-03-18 15:41:14 +01:00
parent 67ca2c704b
commit ccd90df62f

View file

@ -122,10 +122,6 @@ def __init__(self, spec=None):
self.spec = spec
self.pkg = spec.package # Just stored for convenience
# category in the modules system
# TODO: come up with smarter category names.
self.category = "spack"
# short description default is just the package + version
# packages can provide this optional attribute
self.short_description = spec.format("$_ $@")
@ -137,6 +133,17 @@ def __init__(self, spec=None):
if self.spec.package.__doc__:
self.long_description = re.sub(r'\s+', ' ', self.spec.package.__doc__)
@property
def category(self):
# Anything defined at the package level takes precedence
if hasattr(self.pkg, 'category'):
return self.pkg.category
# Extensions
for extendee in self.pkg.extendees:
return '{extendee} extension'.format(extendee=extendee)
# Not very descriptive fallback
return 'spack installed package'
# @property
# def paths(self):
# # Add python path unless it's an actual python installation