bundlewrap/libs/systemd.py
mwiegand a08b24dca5 wip
2021-06-24 23:47:45 +02:00

24 lines
606 B
Python

from mako.template import Template
template = '''
% for i, (segment, options) in enumerate(data.items()):
[${segment}]
% for option, value in options.items():
% if isinstance(value, dict):
% for k, v in value.items():
${option}=${k}=${v}
% endfor
% elif isinstance(value, (list, set, tuple)):
% for item in sorted(value):
${option}=${item}
% endfor
% elif isinstance(value, str):
${option}=${value}
% endif
% endfor
% endfor
'''
def generate_unitfile(data):
return Template(template).render(data=data).lstrip()