Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -174,7 +174,11 @@ def version(pkg, ver, checksum=None, **kwargs): ...@@ -174,7 +174,11 @@ def version(pkg, ver, checksum=None, **kwargs):
def _depends_on(pkg, spec, when=None): 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 = pkg.name
when_spec = parse_anonymous_spec(when, pkg.name) when_spec = parse_anonymous_spec(when, pkg.name)
......
...@@ -193,10 +193,11 @@ def install(self, prefix): ...@@ -193,10 +193,11 @@ def install(self, prefix):
platform-specific versions. There's not much we can do to get platform-specific versions. There's not much we can do to get
around this because of the way decorators work. around this because of the way decorators work.
""" """
class when(object):
def __init__(self, spec): def __init__(self, spec):
pkg = get_calling_module_name() 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): def __call__(self, method):
# Get the first definition of the method in the calling scope # Get the first definition of the method in the calling scope
...@@ -207,7 +208,9 @@ def __call__(self, method): ...@@ -207,7 +208,9 @@ def __call__(self, method):
if not type(original_method) == SpecMultiMethod: if not type(original_method) == SpecMultiMethod:
original_method = SpecMultiMethod(original_method) 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 return original_method
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment