diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-10-16 22:55:16 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-10-16 22:55:16 +0300 |
commit | 7d50378d25c1b20e4418daa79cdd7c2bfc7e5421 (patch) | |
tree | 1a91d7855dc2ab37f9695713d56ebca36424ef7a /optinterpreter.py | |
parent | 07b7d63ccb69304610440970db4e52ba14e15643 (diff) | |
download | meson-7d50378d25c1b20e4418daa79cdd7c2bfc7e5421.zip meson-7d50378d25c1b20e4418daa79cdd7c2bfc7e5421.tar.gz meson-7d50378d25c1b20e4418daa79cdd7c2bfc7e5421.tar.bz2 |
Added combo options because why the hell not.
Diffstat (limited to 'optinterpreter.py')
-rw-r--r-- | optinterpreter.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/optinterpreter.py b/optinterpreter.py index e2f72d0..9d23536 100644 --- a/optinterpreter.py +++ b/optinterpreter.py @@ -38,8 +38,24 @@ class UserBooleanOption(UserOption): if not isinstance(self.value, bool): raise OptionException('Value of boolean option is not boolean.') +class UserComboOption(UserOption): + def __init__(self, kwargs): + super().__init__(kwargs) + if 'choices' not in kwargs: + raise OptionException('Combo option missing "choices" keyword.') + self.choices = kwargs['choices'] + if not isinstance(self.choices, list): + raise OptionException('Combo choices must be an array.') + for i in self.choices: + if not isinstance(i, str): + raise OptionException('Combo choice elements must be strings.') + self.value = kwargs.get('value', self.choices[0]) + if self.value not in self.choices: + raise OptionException('Combo value must be one of the choices.') + option_types = {'string' : UserStringOption, 'boolean' : UserBooleanOption, + 'combo' : UserComboOption, } class OptionInterpreter: |