]> git.decadent.org.uk Git - dak.git/blob - ashley
2004-04-01 James Troup <james@nocrew.org> * jennifer (get_changelog_versions):...
[dak.git] / ashley
1 #!/usr/bin/env python
2
3 # Dump variables from a .katie file to stdout
4 # Copyright (C) 2001, 2002, 2004  James Troup <james@nocrew.org>
5 # $Id: ashley,v 1.9 2004-04-01 17:14:25 troup Exp $
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 2 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,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU 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, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21 ################################################################################
22
23 # <elmo> ooooooooooooooohhhhhhhhhhhhhhhhhhhhhhhhh            dddddddddeeeeeeeaaaaaaaarrrrrrrrrrr
24 # <elmo> iiiiiiiiiiiii          tttttttttthhhhhhhhiiiiiiiiiiiinnnnnnnnnkkkkkkkkkkkkk              iiiiiiiiiiiiii       mmmmmmmmmmeeeeeeeesssssssssssssssseeeeeeeddd           uuuupppppppppppp       ttttttttthhhhhhhheeeeeeee          xxxxxxxssssssseeeeeeeeettttttttttttt             aaaaaaaarrrrrrrggggggsssssssss
25 #
26 # ['xset r rate 30 250' bad, mmkay]
27
28 ################################################################################
29
30 import sys;
31 import katie, utils;
32 import apt_pkg;
33
34
35 ################################################################################
36
37 def usage(exit_code=0):
38     print """Usage: ashley FILE...
39 Dumps the info in .katie FILE(s).
40
41   -h, --help                show this help and exit."""
42     sys.exit(exit_code)
43
44 ################################################################################
45
46 def main():
47     Cnf = utils.get_conf()
48     Arguments = [('h',"help","Ashley::Options::Help")];
49     for i in [ "help" ]:
50         if not Cnf.has_key("Ashley::Options::%s" % (i)):
51             Cnf["Ashley::Options::%s" % (i)] = "";
52
53     apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv);
54
55     Options = Cnf.SubTree("Ashley::Options")
56     if Options["Help"]:
57         usage();
58
59     k = katie.Katie(Cnf);
60     for arg in sys.argv[1:]:
61         arg = utils.validate_changes_file_arg(arg);
62         k.pkg.changes_file = arg;
63         print "%s:" % (arg);
64         k.init_vars();
65         k.update_vars();
66
67         changes = k.pkg.changes;
68         print " Changes:";
69         # Mandatory changes fields
70         for i in [ "source", "version", "maintainer", "urgency", "changedby822", "changedbyname", "maintainername", "maintaineremail", "fingerprint" ]:
71             print "  %s: %s" % (i.capitalize(), changes[i]);
72             del changes[i];
73         # Mandatory changes lists
74         for i in [ "distribution", "architecture", "closes" ]:
75             print "  %s: %s" % (i.capitalize(), " ".join(changes[i].keys()));
76             del changes[i];
77         # Optional changes fields
78         for i in [ "changed-by", "maintainer822", "filecontents", "format" ]:
79             if changes.has_key(i):
80                 print "  %s: %s" % (i.capitalize(), changes[i]);
81                 del changes[i];
82         print;
83         if changes:
84             utils.warn("changes still has following unrecognised keys: %s" % (changes.keys()));
85
86         dsc = k.pkg.dsc;
87         print " Dsc:";
88         for i in [ "source", "version", "maintainer", "fingerprint", "uploaders",
89                    "bts changelog" ]:
90             if dsc.has_key(i):
91                 print "  %s: %s" % (i.capitalize(), dsc[i]);
92                 del dsc[i];
93         print;
94         if dsc:
95             utils.warn("dsc still has following unrecognised keys: %s" % (dsc.keys()));
96
97         files = k.pkg.files;
98         print " Files:"
99         for file in files.keys():
100             print "  %s:" % (file);
101             for i in [ "package", "version", "architecture", "type", "size",
102                        "md5sum", "component", "location id", "source package",
103                        "source version", "maintainer", "dbtype", "files id",
104                        "new", "section", "priority" ]:
105                 if files[file].has_key(i):
106                     print "   %s: %s" % (i.capitalize(), files[file][i]);
107                     del files[file][i];
108             if files[file]:
109                 utils.warn("files[%s] still has following unrecognised keys: %s" % (file, files[file].keys()));
110         print;
111
112         dsc_files = k.pkg.dsc_files;
113         print " Dsc Files:";
114         for file in dsc_files.keys():
115             print "  %s:" % (file);
116             # Mandatory fields
117             for i in [ "size", "md5sum" ]:
118                 print "   %s: %s" % (i.capitalize(), dsc_files[file][i]);
119                 del dsc_files[file][i];
120             # Optional fields
121             for i in [ "files id" ]:
122                 if dsc_files[file].has_key(i):
123                     print "   %s: %s" % (i.capitalize(), dsc_files[file][i]);
124                     del dsc_files[file][i];
125             if dsc_files[file]:
126                 utils.warn("dsc_files[%s] still has following unrecognised keys: %s" % (file, dsc_files[file].keys()));
127
128 ################################################################################
129
130 if __name__ == '__main__':
131     main()
132