]> git.decadent.org.uk Git - dak.git/blob - dak/decode_dot_dak.py
Now it works :)
[dak.git] / dak / decode_dot_dak.py
1 #!/usr/bin/env python
2
3 """ Dump variables from a .dak file to stdout """
4 # Copyright (C) 2001, 2002, 2004, 2006  James Troup <james@nocrew.org>
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 2 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
20 ################################################################################
21
22 # <elmo> ooooooooooooooohhhhhhhhhhhhhhhhhhhhhhhhh            dddddddddeeeeeeeaaaaaaaarrrrrrrrrrr
23 # <elmo> iiiiiiiiiiiii          tttttttttthhhhhhhhiiiiiiiiiiiinnnnnnnnnkkkkkkkkkkkkk              iiiiiiiiiiiiii       mmmmmmmmmmeeeeeeeesssssssssssssssseeeeeeeddd           uuuupppppppppppp       ttttttttthhhhhhhheeeeeeee          xxxxxxxssssssseeeeeeeeettttttttttttt             aaaaaaaarrrrrrrggggggsssssssss
24 #
25 # ['xset r rate 30 250' bad, mmkay]
26
27 ################################################################################
28
29 import sys
30 import apt_pkg
31 from daklib.changes import Changes
32 from daklib import utils
33
34 ################################################################################
35
36 def usage(exit_code=0):
37     print """Usage: dak decode-dot-dak FILE...
38 Dumps the info in .dak FILE(s).
39
40   -h, --help                show this help and exit."""
41     sys.exit(exit_code)
42
43 ################################################################################
44
45 def main():
46     Cnf = utils.get_conf()
47     Arguments = [('h',"help","Decode-Dot-Dak::Options::Help")]
48     for i in [ "help" ]:
49         if not Cnf.has_key("Decode-Dot-Dak::Options::%s" % (i)):
50             Cnf["Decode-Dot-Dak::Options::%s" % (i)] = ""
51
52     apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
53
54     Options = Cnf.SubTree("Decode-Dot-Dak::Options")
55     if Options["Help"]:
56         usage()
57
58
59     for arg in sys.argv[1:]:
60         arg = utils.validate_changes_file_arg(arg,require_changes=-1)
61         k = Changes()
62         k.load_dot_dak(arg)
63         print arg
64         print k
65
66 ################################################################################
67
68 if __name__ == '__main__':
69     main()