File: Args.py

package info (click to toggle)
aap 1.072-1.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 4,976 kB
  • ctags: 2,160
  • sloc: python: 15,113; makefile: 62; sh: 13
file content (54 lines) | stat: -rw-r--r-- 1,759 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Part of the A-A-P recipe executive: store the command line arguments.

# Copyright (C) 2002-2003 Stichting NLnet Labs
# Permission to copy and use this file is specified in the file COPYING.
# If this file is missing you can find it here: http://www.a-a-p.org/COPYING


# An Args object contains the processed command line arguments.
# It consists of these items:
#  options   -  dictionary of options
#               the key is the long name of the option
#               each item is a number or a string
#               "aap -f foo" -> options["recipe"] = "foo"
#  values    -  dictionary of variables assigned a value
#               each item is a string
#               "aap bar=asdf" -> values["bar"] = "asdf"
#  targets   -  list of targets
#               each item is a string
#               "aap clean" -> "clean" target

import types
import string

class Args:
    def __init__(self):
        self.options = {}
        self.values = {}
        self.targets = []

    def has_option(self, name):
        return self.options.has_key(name)

    def printit(self):
        """print the contents of the attributes (for debugging)"""

        print "Options:"
        for o in self.options.keys():
            if self.options[o]:
                if type(self.options[o]) is types.ListType:
                    print "    " + o + ": " + string.join(self.options[o], ", ")
                else:
                    print "    " + o + ": " + str(self.options[o])
            else:
                print "    " + o

        print "Values:"
        for v in self.values.keys():
            print "    " + v + "=" + self.values[v]

        print "Targets:"
        for t in self.targets:
            print "    " + t

# vim: set sw=4 et sts=4 tw=79 fo+=l: