initial import for Open Source 🎉
This commit is contained in:
parent
1898c361f3
commit
9c0dd3b722
2048 changed files with 218743 additions and 0 deletions
29
features/__init__.py
Normal file
29
features/__init__.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
_FEATURES = {}
|
||||
|
||||
def import_features(config_dict):
|
||||
for feature, feature_val in config_dict.items():
|
||||
if feature.startswith('FEATURE_'):
|
||||
feature_name = feature[8:]
|
||||
_FEATURES[feature_name] = globals()[feature_name] = FeatureNameValue(feature_name, feature_val)
|
||||
|
||||
|
||||
def get_features():
|
||||
return {key: _FEATURES[key].value for key in _FEATURES}
|
||||
|
||||
|
||||
class FeatureNameValue(object):
|
||||
def __init__(self, name, value):
|
||||
self.value = value
|
||||
self.name = name
|
||||
|
||||
def __str__(self):
|
||||
return '%s => %s' % (self.name, self.value)
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.value)
|
||||
|
||||
def __cmp__(self, other):
|
||||
return self.value.__cmp__(other)
|
||||
|
||||
def __nonzero__(self):
|
||||
return self.value.__nonzero__()
|
Reference in a new issue