Exemplo n.º 1
0
 def override(self, section, **values):
     if self.allow_override:
         if section in self._configs:
             self._configs[section].override(**values)
         else:
             logger.debug('Tried to override values in nonexistent section'
                          ' %s' % section)
Exemplo n.º 2
0
 def override_defaults(self, section, **defaults):
     if self.allow_override:
         if section in self._configs:
             self._configs[section].set_defaults(defaults)
         else:
             msg = 'Tried to override defaults in nonexistent section "{}"'
             logger.debug(msg.format(section))
Exemplo n.º 3
0
 def create(self, section, defaults):
     config = Configuration(defaults)
     if self._allow_files:
         try:
             file_config = dict(self.config_parser.items(section))
             config.set_file_config(file_config)
         except configparser.NoSectionError as e:
             logger.debug('configparser: ' + str(e))
         except configparser.Error as e:
             logger.error('configparser: ' + str(e))
     return config
Exemplo n.º 4
0
Arquivo: write.py Projeto: tek/pytek
def write_pkg_config(_dir, outfile, alias):
    sys.path[:0] = [_dir]
    Config.allow_files = False
    Config.allow_override = False
    Config.clear_metadata()
    for name in config_names(_dir):
        try:
            Config.load_config(name)
        except Exception as e:
            logger.debug(e)
    Config.reset(files=False, alias=[alias])
    Config.write_config(outfile)
Exemplo n.º 5
0
    def notify_clients(cls, name):
        ''' Connects clients to Configuration 'name' that have been
        registered before their target and clear the client dict item.

        '''
        if name in cls._configs:
            if name in cls._pending_clients:
                for client in cls._pending_clients[name]:
                    client.connect(cls._configs[name])
                del cls._pending_clients[name]
        else:
            logger.debug('Configurations.notify clients called for'
                         ' Configuration \'%s\' which hasn\'t been added yet' %
                         name)
Exemplo n.º 6
0
Arquivo: options.py Projeto: tek/pytek
 def set(self, args):
     """ Assign args as the config object's value.
     If args is not of the value_type of the config object, it is
     passed to value_type.__init__. args may be a tuple of
     parameters.
     """
     try:
         if isinstance(args, tuple):
             if len(args) != 1:
                 logger.debug('TypedConfigOption: len > 1')
                 self.value = self.value_type(*args)
                 return
             else:
                 args = args[0]
         if isinstance(args, self.value_type):
             self.value = args
         elif self._factory is not None:
             self.value = self._factory(args)
         else:
             self.value = self.value_type(args)
     except ValueError:
         raise ConfigValueError(self.__class__, args)
Exemplo n.º 7
0
 def cleanup(self):
     try:
         shutil.rmtree(self.temp_dir)
     except Exception as e:
         logger.debug('Error while cleaning up: {}'.format(e))