sort units

This commit is contained in:
mwiegand 2022-03-27 13:30:07 +02:00
parent 8b3f9d7736
commit dab554473e

View file

@ -7,7 +7,7 @@ template = '''
# ${segment.split('#', 2)[1]}
% endif
[${segment.split('#')[0]}]
% for option, value in options.items():
% for option, value in sorted(options.items()):
% if isinstance(value, dict):
% for k, v in value.items():
${option}=${k}=${v}
@ -16,6 +16,7 @@ ${option}=${k}=${v}
% for item in sorted(value):
${option}=${item}
% endfor
% elif isinstance(value, type(None)):
% else:
${option}=${str(value)}
% endif
@ -39,7 +40,6 @@ def segment_order(segment):
def generate_unitfile(data):
return Template(template).render(
data=dict(sorted(data.items(), key=segment_order)),
order=order
).lstrip()
# wip