-
-
Save developerinlondon/b4692afd34896ed98192 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, glob, pdb, re | |
from functools import wraps | |
from fabric.api import task as _task | |
def fix_boolean(f): | |
true_values = ("yes", "true", "1") | |
false_values = ("no", "false", "0") | |
def fix_bool(value): | |
if isinstance(value, basestring): | |
if value.lower() in false_values: | |
return False | |
if value.lower() in true_values: | |
return True | |
return value | |
@wraps(f) | |
def wrapper(*args, **kwargs): | |
args_ = [fix_bool(arg) for arg in args] | |
kwargs_ = {k: fix_bool(v) for k,v in kwargs.iteritems()} | |
return f(*args_, **kwargs_) | |
return wrapper | |
def task(f): | |
return _task(fix_boolean(f)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment