Ejemplo n.º 1
0
 def _getpluginconf(self, modname):
     '''Parse the plugin specific configuration file and return a
     IncludingConfigParser instance representing it. Returns None if there
     was an error reading or parsing the configuration file.
     '''
     for dir in self.pluginconfpath:
         conffilename = os.path.join(dir, modname + ".conf")
         if os.access(conffilename, os.R_OK):
             # Found configuration file
             break
         self.verbose_logger.log(
             logginglevels.INFO_2,
             _("Configuration file %s not found") % conffilename)
     else:  # for
         # Configuration files for the plugin not found
         self.verbose_logger.log(
             logginglevels.INFO_2,
             _("Unable to find configuration file for plugin %s") % modname)
         return None
     parser = ConfigParser.ConfigParser()
     confpp_obj = ConfigPreProcessor(conffilename)
     try:
         parser.readfp(confpp_obj)
     except ConfigParser.ParsingError, e:
         raise Errors.ConfigError("Couldn't parse %s: %s" %
                                  (conffilename, str(e)))
Ejemplo n.º 2
0
 def test_readline_configparser(self):
     for s in self.test_strings:
         fp = OnlyReadline(s)
         c = compat.ConfigParser()
         c.readfp(fp)
         ss = StringIO()
         c.write(ss)
         self.assertEqual(s, ss.getvalue())
Ejemplo n.º 3
0
 def test_assignment(self):
     c = compat.ConfigParser()
     c.optionxform = str
     c.add_section('foo')
     c.set('foo', 'bar', 'a')
     c.set('foo', 'Bar', 'b')
     self.assertEqual(c.get('foo', 'bar'), 'a')
     self.assertEqual(c.get('foo', 'Bar'), 'b')
Ejemplo n.º 4
0
 def test_dyanamic(self):
     c = compat.ConfigParser()
     c.optionxform = str
     c.add_section('foo')
     c.set('foo', 'bar', 'a')
     c.set('foo', 'Bar', 'b')
     c.set('foo', 'BAR', 'c')
     c.optionxform = str.upper
     self.assertEqual(c.get('foo', 'Bar'), 'c')
     c.optionxform = str.lower
     self.assertEqual(c.get('foo', 'Bar'), 'a')
     c.optionxform = str
     self.assertEqual(c.get('foo', 'Bar'), 'b')