diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-06-20 13:32:31 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-06-20 13:32:31 +0300 |
commit | 214a6b5c0a457880f162ca0a064e9e338315f824 (patch) | |
tree | 992800ad1010fd8e866b5aaffc80a10946f3cbcd /optinterpreter.py | |
parent | 790fe206e6a2404d2e346482125d7fdc21568a91 (diff) | |
download | meson-214a6b5c0a457880f162ca0a064e9e338315f824.zip meson-214a6b5c0a457880f162ca0a064e9e338315f824.tar.gz meson-214a6b5c0a457880f162ca0a064e9e338315f824.tar.bz2 |
Set option name in constructor. Closes #164.
Diffstat (limited to 'optinterpreter.py')
-rw-r--r-- | optinterpreter.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/optinterpreter.py b/optinterpreter.py index 312427e..1fbb6fc 100644 --- a/optinterpreter.py +++ b/optinterpreter.py @@ -37,16 +37,17 @@ class OptionException(coredata.MesonException): optname_regex = re.compile('[^a-zA-Z0-9_-]') class UserOption: - def __init__(self, kwargs): + def __init__(self, name, kwargs): super().__init__() self.description = kwargs.get('description', '') + self.name = name def parse_string(self, valuestring): return valuestring class UserStringOption(UserOption): - def __init__(self, kwargs): - super().__init__(kwargs) + def __init__(self, name, kwargs): + super().__init__(name, kwargs) self.set_value(kwargs.get('value', '')) def set_value(self, newvalue): @@ -55,8 +56,8 @@ class UserStringOption(UserOption): self.value = newvalue class UserBooleanOption(UserOption): - def __init__(self, kwargs): - super().__init__(kwargs) + def __init__(self, name, kwargs): + super().__init__(name, kwargs) self.set_value(kwargs.get('value', 'true')) def set_value(self, newvalue): @@ -72,8 +73,8 @@ class UserBooleanOption(UserOption): raise OptionException('Value "%s" for boolean option "%s" is not a boolean.' % (valuestring, self.name)) class UserComboOption(UserOption): - def __init__(self, kwargs): - super().__init__(kwargs) + def __init__(self, name, kwargs): + super().__init__(name, kwargs) if 'choices' not in kwargs: raise OptionException('Combo option missing "choices" keyword.') self.choices = kwargs['choices'] @@ -173,8 +174,7 @@ class OptionInterpreter: raise OptionException('Option name %s is reserved.' % opt_name) if self.subproject != '': opt_name = self.subproject + ':' + opt_name - opt = option_types[opt_type](kwargs) - opt.name = opt_name + opt = option_types[opt_type](opt_name, kwargs) if opt.description == '': opt.description = opt_name if opt_name in self.cmd_line_options: |