source: vanHelsing/trunk/src/resource.py@ 798

Last change on this file since 798 was 798, checked in by hmueller, on Oct 14, 2009 at 4:03:57 PM

parser in class gepackt

  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-python
File size: 1.5 KB
Line 
1'''
2Resource Objects
3Created on 30.06.2009
4
5@author: hmueller
6'''
7
8class Resource(object):
9 DIRECTIVE=""
10
11 def __init__(self, level=0):
12 self.items = []
13 self.comments = []
14 self._recurselevel = level
15
16 def __str__(self):
17 s = "\n".join(self.comments)
18 s += self.DIRECTIVE + "{\n"
19 for d in self.items:
20 s += " " + str(d) + "\n"
21 s += "}\n"
22 return s
23
24 def add_comment(self, comment):
25 if not comment.lstrip().startswith("#"):
26 comment = "# " + comment
27 self.comments.append(comment)
28
29 def add_item(self, item):
30 self.items.append(item)
31
32class Director(Resource):
33 DIRECTIVE="Director"
34 pass
35
36class Job(Resource):
37 DIRECTIVE="Job"
38
39class JobDefs(Resource):
40 DIRECTIVE="JobDefs"
41
42class Schedule(Resource):
43 DIRECTIVE="Schedule"
44
45class FileSet(Resource):
46 DIRECTIVE="FileSet"
47
48class Client(Resource):
49 DIRECTIVE="Client"
50
51class Storage(Resource):
52 DIRECTIVE="Storage"
53
54class Pool(Resource):
55 DIRECTIVE="Pool"
56
57class Catalog(Resource):
58 # ITEMS_DIRD = cdef.dird_cat_items
59 DIRECTIVE="Catalog"
60
61class Messages(Resource):
62 DIRECTIVE="Messages"
63
64class Console(Resource):
65 DIRECTIVE="Console"
66
67class Counter(Resource):
68 DIRECTIVE="Counter"
69
70class Device(Resource):
71 DIRECTIVE="Device"
72
73class Autochanger(Resource):
74 DIRECTIVE="Autochanger"
75
76__cls = locals().copy()
77
78directives = [v.DIRECTIVE for k,v in __cls.iteritems()
79 if k != "Resource" and getattr(v, "DIRECTIVE", None)]
Note: See TracBrowser for help on using the repository browser.