editing a config file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike Zupan

    editing a config file

    I need to edit the value(s) of a config file via a GUI interface. I'm
    trying to use ConfigParser but set() doesn't seem to write.

    Here are my reading and writing functions

    def getConfig(self, value=None):
    config = ConfigParser.Co nfigParser()
    config.readfp(o pen('config.inf '))
    return config.defaults ()[value]

    def setConfig(self, option, value):
    config = ConfigParser.Co nfigParser()
    config.readfp(o pen('config.inf ', 'a'))
    config.set("DEF AULT", option, value)

    The values are getting passed ok it just won't set the value to the
    new value i have selected.

    can anyone offer any hints?
  • Mathias Waack

    #2
    Re: editing a config file

    Mike Zupan wrote:
    [color=blue]
    > I need to edit the value(s) of a config file via a GUI interface.
    > I'm trying to use ConfigParser but set() doesn't seem to write.
    >
    > Here are my reading and writing functions
    >
    > def getConfig(self, value=None):
    > config = ConfigParser.Co nfigParser()
    > config.readfp(o pen('config.inf '))
    > return config.defaults ()[value]
    >
    > def setConfig(self, option, value):
    > config = ConfigParser.Co nfigParser()
    > config.readfp(o pen('config.inf ', 'a'))
    > config.set("DEF AULT", option, value)
    >
    > The values are getting passed ok it just won't set the value to the
    > new value i have selected.
    >
    > can anyone offer any hints?[/color]

    Maybe you're simply missing a config.write('c onfig.inf')?

    Mathias

    Comment

    Working...