Split function wrapper from a use() method
@@ -143,9 +143,7 @@ class FeatureNew:
for version in sorted(FeatureNew.min_feature_versions.keys()):
print('{}: {}'.format(version, FeatureNew.min_feature_versions[version]))
- def __call__(self, f):
- @wraps(f)
- def wrapped(*wrapped_args, **wrapped_kwargs):
+ def use(self):
self.add_called_feature()
tv = coredata.target_version
if tv == '':
@@ -154,6 +152,11 @@ class FeatureNew:
mlog.error(
'''Project targetting \'{}\' but tried to use feature introduced in \'{}\': {}'''
.format(tv, self.feature_version, self.feature_name))
+
+ def __call__(self, f):
+ @wraps(f)
+ def wrapped(*wrapped_args, **wrapped_kwargs):
+ self.use()
return f(*wrapped_args, **wrapped_kwargs)
return wrapped
@@ -176,10 +179,7 @@ class FeatureDeprecated:
for version in sorted(FeatureDeprecated.max_feature_versions.keys()):
print('{}: {}'.format(version, FeatureDeprecated.max_feature_versions[version]))
- def __call__(self, f):
- @wraps(f)
- def wrapped(*wrapped_args, **wrapped_kwargs):
- print('deprecated:', self.feature_name, self.feature_version)
+ def use(self):
self.add_called_feature()
tv = coredata.target_version
if tv == '':
@@ -188,6 +188,11 @@ class FeatureDeprecated:
mlog.error(
'''Project targetting \'{}\' but tried to use feature deprecated since \'{}\': {}'''
.format(tv, self.feature_version, self.feature_name))
+
+ def __call__(self, f):
+ @wraps(f)
+ def wrapped(*wrapped_args, **wrapped_kwargs):
+ self.use()
return f(*wrapped_args, **wrapped_kwargs)
return wrapped
