Commit 187ccca2 authored by Gerion Entrup's avatar Gerion Entrup
Browse files

first draft of config file writer

parent 9f986588
#!/usr/bin/env python3
import settings
import configparser
class PFile():
def __init__(self, orig):
self._orig = orig
self._before_comment = True
def write(self, s):
s = s.split('\n')
print("1", s)
for idx, line in enumerate(s):
if len(line) > 0 and line[0] != '#':
self._before_comment = True
if line.startswith('#') and self._before_comment:
s[idx] = '\n' + line
self._before_comment = False
print("2", s)
root = 'settings'
config = configparser.ConfigParser(allow_no_value=True)
for opt, value in settings.get_options():
doc = settings.get_doc(opt).split('\n')
for line in doc:
if len(line) > 0:
line = ' ' + line
config.set(root, '#' + line)
config.set(root, opt, str(value))
with open('example.ini', 'w') as c_file:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment