Debian Codegraph @

examples/deb822/grep-maintainer

raw
1 #!/usr/bin/python3
2
3 # grep-maintainer
4 # Copyright (C) 2007 Stefano Zacchiroli <[email protected]>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10
11 """Dumb maintainer-based grep for the dpkg status file."""
12
13 import re
14 import sys
15 from debian import deb822
16
17 try:
18 maint_RE = re.compile(sys.argv[1])
19 except IndexError:
20 print("Usage: grep-maintainer REGEXP", file=sys.stderr)
21 sys.exit(1)
22 except re.error as e:
23 print("Error in the regexp: %s" % (e,), file=sys.stderr)
24 sys.exit(1)
25
26 for pkg in deb822.Packages.iter_paragraphs(open('/var/lib/dpkg/status')):
27 if 'Maintainer' in pkg and maint_RE.search(pkg['maintainer']):
28 print(pkg['package'])
29