UBUNTU: [Packaging] annotations: Write out annotations with notes first
When writing the annotations file, separate them into two groups: With and without a note. Write the group with notes first and separate the other group with a visual marker. The idea is that all configs that are set/modified manually should have an annotation note and putting them at the top of the annotations file should make it easier to figure out what the config of this kernel is about. Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com> Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
This commit is contained in:
committed by
Paolo Pisati
parent
e011f2959f
commit
007607d60c
+18
-1
@@ -262,6 +262,17 @@ class Annotation(Config):
|
||||
if not self.config[conf]['policy']:
|
||||
del self.config[conf]
|
||||
|
||||
def _sorted(self, config):
|
||||
""" Sort configs alphabetically but return configs with a note first """
|
||||
w_note = []
|
||||
wo_note = []
|
||||
for c in sorted(config):
|
||||
if 'note' in config[c]:
|
||||
w_note.append(c)
|
||||
else:
|
||||
wo_note.append(c)
|
||||
return w_note + wo_note
|
||||
|
||||
def save(self, fname: str):
|
||||
""" Save annotations data to the annotation file """
|
||||
# Compact annotations structure
|
||||
@@ -284,7 +295,8 @@ class Annotation(Config):
|
||||
tmp_a = Annotation(fname)
|
||||
|
||||
# Only save local differences (preserve includes)
|
||||
for conf in sorted(self.config):
|
||||
marker = False
|
||||
for conf in self._sorted(self.config):
|
||||
new_val = self.config[conf]
|
||||
if 'policy' not in new_val:
|
||||
continue
|
||||
@@ -307,6 +319,11 @@ class Annotation(Config):
|
||||
# Separate policy and note lines,
|
||||
# followed by an empty line
|
||||
line += f'\n{conf : <47} note<{val}>\n'
|
||||
elif not marker:
|
||||
# Write out a marker indicating the start of annotations
|
||||
# without notes
|
||||
tmp.write('\n# ---- Annotations without notes ----\n\n')
|
||||
marker = True
|
||||
tmp.write(line + "\n")
|
||||
|
||||
# Replace annotations with the updated version
|
||||
|
||||
Reference in New Issue
Block a user