Esempio n. 1
0
 def raw_value(cls, app, section, option):
     config_parser = CaseSensitiveConfigParser()
     with open(app.get_ini_file(), 'r') as f:
         config_parser.readfp(f)
     try:
         return config_parser.get(section, option)
     except (NoSectionError, NoOptionError):
         return None
Esempio n. 2
0
 def get_values(self, app, keys, warn=True):
     config_parser = CaseSensitiveConfigParser()
     with open(app.get_ini_file(), 'r') as f:
         config_parser.readfp(f)
     for section, key in keys:
         search_section = section or 'Application'
         found = False
         for config_section in config_parser.sections():
             if _match(config_section, search_section):
                 for name, value in config_parser.items(config_section):
                     if _match(name, key):
                         for attr in app._attrs:
                             ini_attr_name = attr.name.replace('_', '')
                             if ini_attr_name == name.lower():
                                 value = attr.get(value, app.get_ini_file())
                         found = True
                         result_section = section and config_section
                         yield result_section, name, value
         if not found:
             try:
                 value = getattr(app, key)
                 if callable(value):
                     raise AttributeError(key)
             except AttributeError:
                 if warn:
                     self.warn('Could not find option %s:%s' %
                               (search_section, key))
             else:
                 yield None, key, value