Ensure that only one of `options` are found in the section Parameters ---------- *options : list of str a list of options to be found in the section (``self.section``) Returns ------- str : the option that is uniquely found in
(self, *options)
| 791 | self.saved_results[self.__class__.__name__] = info |
| 792 | |
| 793 | def get_option_single(self, *options): |
| 794 | """ Ensure that only one of `options` are found in the section |
| 795 | |
| 796 | Parameters |
| 797 | ---------- |
| 798 | *options : list of str |
| 799 | a list of options to be found in the section (``self.section``) |
| 800 | |
| 801 | Returns |
| 802 | ------- |
| 803 | str : |
| 804 | the option that is uniquely found in the section |
| 805 | |
| 806 | Raises |
| 807 | ------ |
| 808 | AliasedOptionError : |
| 809 | in case more than one of the options are found |
| 810 | """ |
| 811 | found = [self.cp.has_option(self.section, opt) for opt in options] |
| 812 | if sum(found) == 1: |
| 813 | return options[found.index(True)] |
| 814 | elif sum(found) == 0: |
| 815 | # nothing is found anyways |
| 816 | return options[0] |
| 817 | |
| 818 | # Else we have more than 1 key found |
| 819 | if AliasedOptionError.__doc__ is None: |
| 820 | raise AliasedOptionError() |
| 821 | raise AliasedOptionError(AliasedOptionError.__doc__.format( |
| 822 | section=self.section, options='[{}]'.format(', '.join(options)))) |
| 823 | |
| 824 | |
| 825 | def has_info(self): |
no test coverage detected