]> git.decadent.org.uk Git - dak.git/blob - ashley
Add new top level directories
[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.11 2004-11-27 16:05:12 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,require_changes=-1);
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",
71                    "changedby2047", "changedbyname", "maintainer822",
72                    "maintainer2047", "maintainername", "maintaineremail",
73                    "fingerprint", "changes" ]:
74             print "  %s: %s" % (i.capitalize(), changes[i]);
75             del changes[i];
76         # Mandatory changes lists
77         for i in [ "distribution", "architecture", "closes" ]:
78             print "  %s: %s" % (i.capitalize(), " ".join(changes[i].keys()));
79             del changes[i];
80         # Optional changes fields
81         for i in [ "changed-by", "filecontents", "format" ]:
82             if changes.has_key(i):
83                 print "  %s: %s" % (i.capitalize(), changes[i]);
84                 del changes[i];
85         print;
86         if changes:
87             utils.warn("changes still has following unrecognised keys: %s" % (changes.keys()));
88
89         dsc = k.pkg.dsc;
90         print " Dsc:";
91         for i in [ "source", "version", "maintainer", "fingerprint", "uploaders",
92                    "bts changelog" ]:
93             if dsc.has_key(i):
94                 print "  %s: %s" % (i.capitalize(), dsc[i]);
95                 del dsc[i];
96         print;
97         if dsc:
98             utils.warn("dsc still has following unrecognised keys: %s" % (dsc.keys()));
99
100         files = k.pkg.files;
101         print " Files:"
102         for file in files.keys():
103             print "  %s:" % (file);
104             for i in [ "package", "version", "architecture", "type", "size",
105                        "md5sum", "component", "location id", "source package",
106                        "source version", "maintainer", "dbtype", "files id",
107                        "new", "section", "priority", "pool name" ]:
108                 if files[file].has_key(i):
109                     print "   %s: %s" % (i.capitalize(), files[file][i]);
110                     del files[file][i];
111             if files[file]:
112                 utils.warn("files[%s] still has following unrecognised keys: %s" % (file, files[file].keys()));
113         print;
114
115         dsc_files = k.pkg.dsc_files;
116         print " Dsc Files:";
117         for file in dsc_files.keys():
118             print "  %s:" % (file);
119             # Mandatory fields
120             for i in [ "size", "md5sum" ]:
121                 print "   %s: %s" % (i.capitalize(), dsc_files[file][i]);
122                 del dsc_files[file][i];
123             # Optional fields
124             for i in [ "files id" ]:
125                 if dsc_files[file].has_key(i):
126                     print "   %s: %s" % (i.capitalize(), dsc_files[file][i]);
127                     del dsc_files[file][i];
128             if dsc_files[file]:
129                 utils.warn("dsc_files[%s] still has following unrecognised keys: %s" % (file, dsc_files[file].keys()));
130
131 ################################################################################
132
133 if __name__ == '__main__':
134     main()
135