Debian Codegraph @

examples/debtags/reverse

raw
1 #!/usr/bin/python3
2
3 # debtags - Implement package tags support for Debian
4 #
5 # Copyright (C) 2003--2006 Enrico Zini <[email protected]>
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 import sys
21 from debian import debtags
22
23 input = sys.stdin
24 if len(sys.argv) > 1:
25 input = open(sys.argv[1],"r")
26
27 #db = read_tag_database(input)
28 #db = reverse(db)
29 db = debtags.read_tag_database_reversed(input)
30 #dummy, db = debtags.read_tag_database_both_ways(input)
31
32 for pkg, tags in db.items():
33 # Using % here seems awkward to me, but if I use calls to
34 # sys.stdout.write it becomes a bit slower
35 print("%s:" % (pkg), ", ".join(tags))