Ignore:
Timestamp:
Oct 14, 2009, 4:03:57 PM (15 years ago)
Author:
hmueller
Message:

parser in class gepackt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vanHelsing/trunk/src/resource.py

    r775 r798  
    77
    88class Resource(object):
     9    DIRECTIVE=""
    910
    10     def __init__(self):
     11    def __init__(self, level=0):
    1112        self.items = []
    1213        self.comments = []
     14        self._recurselevel = level
    1315   
    1416    def __str__(self):
    1517        s = "\n".join(self.comments)
    16         s += self.__name__ + "{\n"
     18        s += self.DIRECTIVE + "{\n"
    1719        for d in self.items:
    1820            s += "  " + str(d) + "\n"
     
    2426            comment = "# " + comment
    2527        self.comments.append(comment)
     28       
     29    def add_item(self, item):
     30        self.items.append(item)
    2631
    2732class Director(Resource):
     33    DIRECTIVE="Director"
    2834    pass
    2935
     
    5460
    5561class Messages(Resource):
    56     DIRECTIVE=""
     62    DIRECTIVE="Messages"
    5763
    5864class Console(Resource):
    59     DIRECTIVE=""
     65    DIRECTIVE="Console"
    6066
    6167class Counter(Resource):
    62     DIRECTIVE=""
     68    DIRECTIVE="Counter"
    6369
    6470class Device(Resource):
    65     DIRECTIVE=""
     71    DIRECTIVE="Device"
    6672
    6773class Autochanger(Resource):
    68     DIRECTIVE=""
     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 TracChangeset for help on using the changeset viewer.