def add_option(self, name, value, label=None, desc=None, allowed_values=None, input_type=None, store=True): if name.lower() in self.lowerkeys(): raise AlreadyExistsKeyError(name) if label is None: label = name.strip().capitalize() option = ConfigOption(self.parser, value, label, desc, allowed_values, input_type) self.__setitem__(name, option) if store: self.parser.store() return option
def add_section(self, name, config=None, label=None, desc=None, store=None): 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.parser, config, label, desc) self.__setitem__(name, section) if store or (store is None and config): self.parser.store() return section