1 from regexes import re_parse_lintian
3 def parse_lintian_output(output):
5 Parses Lintian output and returns a generator with the data.
7 >>> list(parse_lintian_output('W: pkgname: some-tag path/to/file'))
8 [('W', 'pkgname', 'some-tag', 'path/to/file')]
11 for line in output.split('\n'):
12 m = re_parse_lintian.match(line)
16 def generate_reject_messages(parsed_tags, tag_definitions, log=lambda *args: args):
18 Generates package reject messages by comparing parsed lintian output with
19 tag definitions. Returns a generator containing the reject messages.
23 for values in tag_definitions.values():
24 for tag_name in values:
27 for tag in parsed_tags:
30 if tag_name not in tags:
34 if tag['level'] == 'O':
36 if tag_name in tag_definitions['nonfatal']:
37 # Overriding this tag is allowed.
40 elif tag_name in tag_definitions['fatal']:
41 # Overriding this tag is NOT allowed.
43 log('ftpmaster does not allow tag to be overridable', tag_name)
44 yield "%(package)s: Overriden tag %(tag)s found, but this " \
45 "tag may not be overridden." % tag
48 # Tag is known and not overridden; reject
49 yield "%(package)s: lintian output: '%(tag)s %(description)s', " \
50 "automatically rejected package." % tag
52 # Now tell if they *might* override it.
53 if tag_name in tag_definitions['nonfatal']:
54 log("auto rejecting", "overridable", tag_name)
55 yield "%(package)s: If you have a good reason, you may " \
56 "override this lintian tag." % tag
58 log("auto rejecting", "not overridable", tag_name)