Hi Petter, On 11.11.2016 11:03, Petter Reinholdtsen wrote: > [Ole Streicher] >> I updated all tasks of debian-edu to be RFC834 compliant: continuation >> with indentation, no backslashes, no duplicated keywords. The diff looks >> OK for me; you should however double check. >> >> If you don't like it, revert and discuss it. > This is not going to fly. The Debian Edu task files in git are > processed automatically several times a day to build the ISOs on a > machine running Jessie, so depending on a non-released version of the > blends package is not a viable option at the moment.
OK, I committed another version, with backslashes everywhere. Adjusted tool is attached. > I believe the only change we should do to the git version before the new > blend version is in stable is to drop the double > Depends/Recommends/Suggests lines. Otherwise we break the ISO builds. > > The whitespace changes make it harder to track the history of the > tasks. Can you avoid whitespace changes? > I tried as much as possible. However, trailing spaces are still removed, and the backslash now always is preceded by a space. Cheers Ole
#!/usr/bin/env python3 from __future__ import print_function from glob import glob from collections import OrderedDict import re def format_section(s): return "\n".join(l[1] for l in s.values()) + "\n" def format_task(sections): return "\n".join(format_section(s) for s in sections) def get_task(f, eol=""): key = "" items = OrderedDict() sections = [] for l in f.readlines(): backslash = "\\" in l l = l.replace("\\","").rstrip() if not l and not backslash: if items: sections.append(items) items = OrderedDict() key = "" continue m = re.match(r"^(\S+):(\s*)(.*)", l) if m is not None: key = m.group(1) if key in items: if key in ("Depends", "Ignore", "Avoid", "Recommends", "Suggests"): items[key][1] += "," + eol items[key][1] += "\n " + " " * items[key][0] + m.group(3).strip() else: if key in ("Depends", "Ignore", "Avoid", "Recommends", "Suggests", "Why"): indent = len(key) + len(m.group(2)) else: indent = 0 items[key] = [indent, m.group(0).strip()] else: if items: if key in ("Depends", "Ignore", "Avoid", "Recommends", "Suggests"): items[key][1] += eol items[key][1] += "\n" + l sections.append(items) return sections for taskname in glob("tasks/*"): with open(taskname) as taskfile: s = format_task(get_task(taskfile, " \\")) with open(taskname, "w") as taskfile: taskfile.write(s)