|
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 | '''
|
|---|
| 2 | Resource Objects
|
|---|
| 3 | Created on 30.06.2009
|
|---|
| 4 |
|
|---|
| 5 | @author: hmueller
|
|---|
| 6 | '''
|
|---|
| 7 |
|
|---|
| 8 | class 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 |
|
|---|
| 32 | class Director(Resource):
|
|---|
| 33 | DIRECTIVE="Director"
|
|---|
| 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):
|
|---|
| 62 | DIRECTIVE="Messages"
|
|---|
| 63 |
|
|---|
| 64 | class Console(Resource):
|
|---|
| 65 | DIRECTIVE="Console"
|
|---|
| 66 |
|
|---|
| 67 | class Counter(Resource):
|
|---|
| 68 | DIRECTIVE="Counter"
|
|---|
| 69 |
|
|---|
| 70 | class Device(Resource):
|
|---|
| 71 | DIRECTIVE="Device"
|
|---|
| 72 |
|
|---|
| 73 | class Autochanger(Resource):
|
|---|
| 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.