migrate ignored directories from old config file to new configparser format
This commit is contained in:
parent
256aaf5dc3
commit
1f8f6f8781
1 changed files with 23 additions and 3 deletions
|
@ -69,9 +69,29 @@ def upgradeConfigFile(configFile):
|
||||||
|
|
||||||
oldConfig = os.path.join(os.path.expanduser('~'), '.wakatime.conf')
|
oldConfig = os.path.join(os.path.expanduser('~'), '.wakatime.conf')
|
||||||
try:
|
try:
|
||||||
with open(oldConfig) as infile:
|
configs = {
|
||||||
with open(configFile, 'w') as outfile:
|
'ignore': [],
|
||||||
outfile.write("[settings]\n%s" % infile.read().strip())
|
}
|
||||||
|
|
||||||
|
with open(oldConfig) as fh:
|
||||||
|
for line in fh.readlines():
|
||||||
|
line = line.split('=', 1)
|
||||||
|
if len(line) == 2 and line[0].strip() and line[1].strip():
|
||||||
|
if line[0].strip() == 'ignore':
|
||||||
|
configs['ignore'].append(line[1].strip())
|
||||||
|
else:
|
||||||
|
configs[line[0].strip()] = line[1].strip()
|
||||||
|
|
||||||
|
with open(configFile, 'w') as fh:
|
||||||
|
fh.write("[settings]\n")
|
||||||
|
for name, value in configs.items():
|
||||||
|
if isinstance(value, list):
|
||||||
|
fh.write("%s=\n" % name)
|
||||||
|
for item in value:
|
||||||
|
fh.write(" %s\n" % item)
|
||||||
|
else:
|
||||||
|
fh.write("%s = %s\n" % (name, value))
|
||||||
|
|
||||||
os.remove(oldConfig)
|
os.remove(oldConfig)
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue