Line | |
---|
1 | '''
|
---|
2 | Directive Objects
|
---|
3 |
|
---|
4 | Created on 30.06.2009
|
---|
5 |
|
---|
6 | @author: hmueller
|
---|
7 | '''
|
---|
8 |
|
---|
9 | PrettyNames = {}
|
---|
10 |
|
---|
11 | #
|
---|
12 | # Type definitions
|
---|
13 | #
|
---|
14 | class Path(str):
|
---|
15 | pass
|
---|
16 |
|
---|
17 | class Time(str):
|
---|
18 | pass
|
---|
19 |
|
---|
20 | class Acl(str):
|
---|
21 | pass
|
---|
22 |
|
---|
23 | class Password(str):
|
---|
24 | pass
|
---|
25 |
|
---|
26 | class Res(str):
|
---|
27 | pass
|
---|
28 | #
|
---|
29 | # The Resource Item
|
---|
30 | #
|
---|
31 |
|
---|
32 | class Item(object):
|
---|
33 | def __init__(self, name, default=None, type=None, required=False):
|
---|
34 | self.name = name
|
---|
35 | self.default = default
|
---|
36 | if default:
|
---|
37 | self.value = default
|
---|
38 | else:
|
---|
39 | self.value = None
|
---|
40 | self.type = type
|
---|
41 | self.required = required
|
---|
42 |
|
---|
43 | def __repr__(self):
|
---|
44 | return "Item(%s, %s, %s, %s)" % (self.name,
|
---|
45 | str(self.default),
|
---|
46 | str(self.type),
|
---|
47 | self.required)
|
---|
48 |
|
---|
49 | def __lt__(self, other):
|
---|
50 | return self.name < other.name
|
---|
51 |
|
---|
52 | def __str__(self):
|
---|
53 | if PrettyNames.has_key(self.name):
|
---|
54 | return '%s = "%s"' % (self.prettyName(), str(self.value))
|
---|
55 | else:
|
---|
56 | return '%s = "%s" # Warning: No pretty name' % (
|
---|
57 | self.name, str(self.value))
|
---|
58 | def prettyName(self):
|
---|
59 | return PrettyNames.get(self.name, self.name)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.