source: vanHelsing/trunk/src/directive.py@ 797

Last change on this file since 797 was 775, checked in by hmueller, on Jul 6, 2009 at 3:21:47 PM
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-python
File size: 1.3 KB
RevLine 
[775]1'''
2Directive Objects
3
4Created on 30.06.2009
5
6@author: hmueller
7'''
8
9PrettyNames = {}
10
11#
12# Type definitions
13#
14class Path(str):
15 pass
16
17class Time(str):
18 pass
19
20class Acl(str):
21 pass
22
23class Password(str):
24 pass
25
26class Res(str):
27 pass
28#
29# The Resource Item
30#
31
32class 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.