Add indentation to nested entries
This commit is contained in:
parent
0ba516cb6d
commit
a739ce985c
7
k2t.py
7
k2t.py
@ -11,6 +11,8 @@ from xml.etree import ElementTree
|
||||
DEFAULT_LINESTYLE = 'I0'
|
||||
DEFAULT_DITHER = 'I1'
|
||||
|
||||
INDENT = ' '
|
||||
|
||||
|
||||
def k2t(
|
||||
kfile: str,
|
||||
@ -187,9 +189,10 @@ class Entry:
|
||||
return el
|
||||
|
||||
def to_toml(self, depth: int = 0) -> str:
|
||||
indent = INDENT * depth
|
||||
parts = ('layers',) + ('members',) * depth
|
||||
|
||||
s = '[[' + '.'.join(parts) + ']]\n'
|
||||
s = indent + '[[' + '.'.join(parts) + ']]\n'
|
||||
for field in fields(self):
|
||||
val = getattr(self, field.name)
|
||||
if val == field.default:
|
||||
@ -205,7 +208,7 @@ class Entry:
|
||||
vstr = str(val)
|
||||
|
||||
key = field.name.replace('_', '-')
|
||||
s += f'{key} = {vstr}\n'
|
||||
s += f'{indent}{key} = {vstr}\n'
|
||||
|
||||
s += '\n'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user