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
|
Rev | Line | |
---|
[775] | 1 | '''
|
---|
| 2 | Resource Objects
|
---|
| 3 | Created on 30.06.2009
|
---|
| 4 |
|
---|
| 5 | @author: hmueller
|
---|
| 6 | '''
|
---|
| 7 |
|
---|
| 8 | class Resource(object):
|
---|
[798] | 9 | DIRECTIVE=""
|
---|
[775] | 10 |
|
---|
[798] | 11 | def __init__(self, level=0):
|
---|
[775] | 12 | self.items = []
|
---|
| 13 | self.comments = []
|
---|
[798] | 14 | self._recurselevel = level
|
---|
[775] | 15 |
|
---|
| 16 | def __str__(self):
|
---|
| 17 | s = "\n".join(self.comments)
|
---|
[798] | 18 | s += self.DIRECTIVE + "{\n"
|
---|
[775] | 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)
|
---|
[798] | 28 |
|
---|
| 29 | def add_item(self, item):
|
---|
| 30 | self.items.append(item)
|
---|
[775] | 31 |
|
---|
| 32 | class Director(Resource):
|
---|
[798] | 33 | DIRECTIVE="Director"
|
---|
[775] | 34 | pass
|
---|
| 35 |
|
---|
| 36 | class Job(Resource):
|
---|
| 37 | DIRECTIVE="Job"
|
---|
| 38 |
|
---|
| 39 | class JobDefs(Resource):
|
---|
| 40 | DIRECTIVE="JobDefs"
|
---|
| 41 |
|
---|
| 42 | class Schedule(Resource):
|
---|
| 43 | DIRECTIVE="Schedule"
|
---|
| 44 |
|
---|
| 45 | class FileSet(Resource):
|
---|
| 46 | DIRECTIVE="FileSet"
|
---|
| 47 |
|
---|
| 48 | class Client(Resource):
|
---|
| 49 | DIRECTIVE="Client"
|
---|
| 50 |
|
---|
| 51 | class Storage(Resource):
|
---|
| 52 | DIRECTIVE="Storage"
|
---|
| 53 |
|
---|
| 54 | class Pool(Resource):
|
---|
| 55 | DIRECTIVE="Pool"
|
---|
| 56 |
|
---|
| 57 | class Catalog(Resource):
|
---|
| 58 | # ITEMS_DIRD = cdef.dird_cat_items
|
---|
| 59 | DIRECTIVE="Catalog"
|
---|
| 60 |
|
---|
| 61 | class Messages(Resource):
|
---|
[798] | 62 | DIRECTIVE="Messages"
|
---|
[775] | 63 |
|
---|
| 64 | class Console(Resource):
|
---|
[798] | 65 | DIRECTIVE="Console"
|
---|
[775] | 66 |
|
---|
| 67 | class Counter(Resource):
|
---|
[798] | 68 | DIRECTIVE="Counter"
|
---|
[775] | 69 |
|
---|
| 70 | class Device(Resource):
|
---|
[798] | 71 | DIRECTIVE="Device"
|
---|
[775] | 72 |
|
---|
| 73 | class Autochanger(Resource):
|
---|
[798] | 74 | DIRECTIVE="Autochanger"
|
---|
| 75 |
|
---|
| 76 | __cls = locals().copy()
|
---|
| 77 |
|
---|
| 78 | directives = [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.