I am attempting to use ConfigObj
to write to a config file with a function.
#!/usr/bin/evn python3.5
import configobj
def createConfig(path):
config = configobj.ConfigObj()
config.filename = path
config[REFNAME] = {}
config[REFNAME]['URL'] = URL
config.write()
REFNAME = input("Enter a reference name :")
URL= input("Enter a URL :")
createConfig('server.ini')
When the function createConfig()
is called the config file is written, however, if the script runs again it overwrites the config file created previously. I want to preserve the previous entires and only add to the file, or overwrite if the same REFNAME
is provided.
I'm having trouble understanding how to do this from the docs:
https://configobj.readthedocs.io/en/latest/configobj.html
Any help would be appreciated.