jncramp / iniparse

Automatically exported from code.google.com/p/iniparse
Other
0 stars 0 forks source link

Compatibility: optionxform #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
From: Gavin Kinsey
Date: Thu, 08 Feb 2007 12:32:59 +0000
Subject: Bug report for cfgparse

I'm playing with your cfgparse python module, I've wanted a better
config parser for a while but it's your backwards compatibility with
ConfigParser that is the killer feature that allowed me to actually
switch.  So thanks for writing it :-).  Now on to the bug...

One of my programs derives a new class from ConfigParser and overrides
optionxform in order to have case-sensitive option names. Switching to
the cfgparse.compat module this code no longer works.

I've written a little workaround so it's not a major issue, but it would
be nice if I didn't have to make any change.

This is what I use for a workaround:
@@ -90,9 +93,8 @@

 class CaseSensitiveSafeConfigParser(ConfigParser):
    """Case Sensitive version of ConfigParser"""
-     def optionxform(self, option):
-        """Use str()"""
-        return str(option)
+     def __init__(self):
+        self.data = cfgparse.iniparser.ini_namespace(optionxform=str)

 def getAndType(self, section, option):
     rawVal = self.get(section, option)

Original issue reported on code.google.com by psobe...@gmail.com on 15 Jul 2007 at 11:28

GoogleCodeExporter commented 8 years ago
This should be rixed in rev 48

Original comment by psobe...@gmail.com on 17 Jul 2007 at 4:01