diff --git a/k2t.py b/k2t.py index ce70a5b..5263857 100644 --- a/k2t.py +++ b/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'