Commit 7176e5ef authored by becker33's avatar becker33
Browse files

Merge pull request #299 from epfl-scitas/enhancement/os_detection

enhancement proposal : boolean support for when=<arg>
parents 0d23ff92 0cf03518
......@@ -174,7 +174,11 @@ def version(pkg, ver, checksum=None, **kwargs):
def _depends_on(pkg, spec, when=None):
if when is None:
# If when is False do nothing
if when is False:
return
# If when is None or True make sure the condition is always satisfied
if when is None or when is True:
when = pkg.name
when_spec = parse_anonymous_spec(when, pkg.name)
......
......@@ -193,10 +193,11 @@ def install(self, prefix):
platform-specific versions. There's not much we can do to get
around this because of the way decorators work.
"""
class when(object):
def __init__(self, spec):
pkg = get_calling_module_name()
self.spec = parse_anonymous_spec(spec, pkg)
if spec is True:
spec = pkg
self.spec = parse_anonymous_spec(spec, pkg) if spec is not False else None
def __call__(self, method):
# Get the first definition of the method in the calling scope
......@@ -207,7 +208,9 @@ def __call__(self, method):
if not type(original_method) == SpecMultiMethod:
original_method = SpecMultiMethod(original_method)
original_method.register(self.spec, method)
if self.spec is not None:
original_method.register(self.spec, method)
return original_method
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment