From 7329f4be775b4a585ee811d3347207db3d8b93c6 Mon Sep 17 00:00:00 2001 From: Juerg Haefliger Date: Mon, 6 Feb 2023 08:14:48 +0100 Subject: [PATCH] UBUNTU: [Packaging] annotations: Preserve single-line annotation rules Currently, rules with notes are written out as separate lines, i. e., one line for the policy and one line for the note, followed by an empty line. The parser now supports single line rules so preserve that style when writting out the rules. Signed-off-by: Juerg Haefliger Signed-off-by: Andrea Righi --- debian/scripts/misc/kconfig/annotations.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/debian/scripts/misc/kconfig/annotations.py b/debian/scripts/misc/kconfig/annotations.py index cb73232b01e7..dd9c05fbb8e4 100644 --- a/debian/scripts/misc/kconfig/annotations.py +++ b/debian/scripts/misc/kconfig/annotations.py @@ -82,6 +82,7 @@ class Annotation(Config): m = re.match(r'.* note<(.*?)>', line) if m: + entry['oneline'] = match match = True entry['note'] = "'" + m.group(1).replace("'", '') + "'" @@ -284,11 +285,16 @@ class Annotation(Config): if 'policy' in new_val: val = dict(sorted(new_val['policy'].items())) line = f"{conf : <47} policy<{val}>" - tmp.write(line + "\n") if 'note' in new_val: val = new_val['note'] - line = f"{conf : <47} note<{val}>" - tmp.write(line + "\n\n") + if new_val.get('oneline', False): + # Single line + line += f' note<{val}>' + else: + # Separate policy and note lines, + # followed by an empty line + line += f'\n{conf : <47} note<{val}>\n' + tmp.write(line + "\n") # Replace annotations with the updated version tmp.flush()