rewrite write_alias()

Instead of calling write_pair() (which is quite complex because it needs
to handle multiple rule types), write the alias rules directly in
write_alias().

This comes with minor code duplication, but makes the code much more
readable (3 instead of 7 %s)
This commit is contained in:
Christian Boltz 2018-05-06 20:07:28 +02:00
parent eca16ae6cf
commit 3ee6058050
Failed to generate hash of commit

View file

@ -2664,7 +2664,16 @@ def write_change_profile(prof_data, depth):
return data return data
def write_alias(prof_data, depth): def write_alias(prof_data, depth):
return write_pair(prof_data, depth, '', 'alias', 'alias ', ' -> ', ',', quote_if_needed) pre = ' ' * depth
data = []
if prof_data['alias']:
for key in sorted(prof_data['alias'].keys()):
data.append('%salias %s -> %s,' % (pre, quote_if_needed(key), quote_if_needed(prof_data['alias'][key])))
data.append('')
return data
def write_rlimits(prof_data, depth): def write_rlimits(prof_data, depth):
data = [] data = []