Exemple #1
0
 def as_dict(self, raw=False, vars=None):
     """Convert an INI file to a dictionary"""
     # Load INI file into a dict
     result = {}
     for section in self.sections():
         if section not in result:
             result[section] = {}
         for option in self.options(section):
             value = self.get(section, option, raw, vars)
             try:
                 value = unrepr(value)
             except Exception as x:
                 msg = ("Config error in section: %r, option: %r, "
                        "value: %r. Config values must be valid Python." %
                        (section, option, value))
                 raise ValueError(msg, x.__class__.__name__, x.args)
             result[section][option] = value
     return result
Exemple #2
0
 def as_dict(self, raw=False, vars=None):
     """Convert an INI file to a dictionary"""
     # Load INI file into a dict
     result = {}
     for section in self.sections():
         if section not in result:
             result[section] = {}
         for option in self.options(section):
             value = self.get(section, option, raw, vars)
             try:
                 value = unrepr(value)
             except Exception as x:
                 msg = ("Config error in section: %r, option: %r, "
                        "value: %r. Config values must be valid Python." %
                        (section, option, value))
                 raise ValueError(msg, x.__class__.__name__, x.args)
             result[section][option] = value
     return result
Exemple #3
0
def read_input(filename):
    return unrepr(open(filename).read())