示例#1
0
 def _setup_type(self, input_type):
     if input_type is None:
         self.type = self.DEFAULT_TYPE
     elif input_type in InputType:
         self.type = input_type
     else:
         raise InvalidValueError(input_type)
示例#2
0
 def _set_type(self, input_type):
     if not input_type:
         input_type = self.DEFAULT_TYPE
     if input_type in InputType:
         self.type = input_type
     else:
         raise InvalidValueError(input_type)
示例#3
0
 def set(self, value, store=False):
     norm_value = self._normalize_value(value)
     if self.allowed_values and norm_value not in self.allowed_values:
         raise InvalidValueError(value)
     if self.value == norm_value:
         return
     self.value = norm_value
     if store:
         self.parser.store()
示例#4
0
    def add_section(self,
                    name,
                    config=None,
                    label=None,
                    desc=None,
                    store=None):

        if name.lower() == self.DEFAULTSECT.lower():
            raise InvalidValueError(name)
        if self.SEPARATOR in name:
            raise InvalidValueError(name)
        if name.lower() in self.lowerkeys():
            raise AlreadyExistsKeyError(name)
        if label is None:
            label = name.strip().capitalize()

        section = ConfigSection(self, config, label, desc)
        self.__setitem__(name, section)

        if store or (store is None and config):
            self.store()

        return section
示例#5
0
 def get_option(self, name):
     if self.is_section(name):
         raise InvalidValueError(name)
     return self.__getitem__(name)