diff options
author | Salamandar <felix@piedallu.me> | 2018-04-27 12:03:03 +0200 |
---|---|---|
committer | Salamandar <felix@piedallu.me> | 2018-06-01 14:23:24 +0200 |
commit | 00c4cf7d45c79be871295d0d77c42c92537ed387 (patch) | |
tree | 35d804cb522428bf0a0201e7d6cbc885d76f5217 | |
parent | dd91f96867831f1025f9b3e70314355815862f96 (diff) | |
download | meson-00c4cf7d45c79be871295d0d77c42c92537ed387.zip meson-00c4cf7d45c79be871295d0d77c42c92537ed387.tar.gz meson-00c4cf7d45c79be871295d0d77c42c92537ed387.tar.bz2 |
Add Feature{New,Deprecated}Kwargs decorators
-rw-r--r-- | mesonbuild/interpreterbase.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 649476d..f80d46a 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -199,6 +199,36 @@ class FeatureDeprecated: return f(*wrapped_args, **wrapped_kwargs) return wrapped +class FeatureNewKwargs: + def __init__(self, feature_name, feature_version, kwargs): + self.feature_name = feature_name + self.feature_version = feature_version + self.kwargs = kwargs + + def __call__(self, f): + @wraps(f) + def wrapped(*wrapped_args, **wrapped_kwargs): + for arg in self.kwargs: + if arg in wrapped_kwargs: + FeatureNew(arg + ' arg in ' + self.feature_name, self.feature_version).use() + return f(*wrapped_args, **wrapped_kwargs) + return wrapped + +class FeatureDeprecatedKwargs: + def __init__(self, feature_name, feature_version, kwargs): + self.feature_name = feature_name + self.feature_version = feature_version + self.kwargs = kwargs + + def __call__(self, f): + @wraps(f) + def wrapped(*wrapped_args, **wrapped_kwargs): + for arg in self.kwargs: + if arg in wrapped_kwargs: + FeatureDeprecated(arg + ' arg in ' + self.feature_name, self.feature_version).use() + return f(*wrapped_args, **wrapped_kwargs) + return wrapped + class InterpreterException(mesonlib.MesonException): pass |