Esempio n. 1
0
    def __init__(self, parser, parent, name, base_classes):
        HandlerBase.__init__(self, parser, parent)

        self.classobj = new.classobj(name.encode('ascii'), base_classes, {})
        self.locals = self.classobj.__dict__
        self.globals = self.parent.locals
        self.codestr = ""
Esempio n. 2
0
 def __init__(self, parser, parent, name, atts):
     HandlerBase.__init__(self, parser, parent)
     self.locals = parent.locals
     self.globals = parent.globals
     self.module = parent.module
     test = atts['test']
     self.element = IfNodeList(test)
Esempio n. 3
0
 def __init__(self, parser, parent, globals, name, atts):
     HandlerBase.__init__(self, parser, parent, globals)
     self.adder = globals['adder']        
     self.predicate = join(split(name, "^"), "")
     self.literal = 0
     self.anonymous_object = 0
     if atts.has_key("resource"):
         self.object = atts["resource"]
         self.object = absolutize(self.parser.GetBase(), self.object)                                                
         for att in atts.keys():
             if att == "resource":
                 pass
             else:
                 new_att = join(split(att, "^"), "")
                 self.adder(self.object, new_att, atts[att],
                            literal_object=1)
     elif atts.has_key(RESOURCE_ATTRIBUTE):
         self.object = atts[RESOURCE_ATTRIBUTE]
         self.object = absolutize(self.parser.GetBase(), self.object)
         for att in atts.keys():
             if att == RESOURCE_ATTRIBUTE:
                 pass
             else:
                 new_att = join(split(att, "^"), "")
                 self.adder(self.object, new_att,atts[att],
                            literal_object=1)
     else:
         self.object = ""
         self.literal = 1
Esempio n. 4
0
    def __init__(self, parser, parent, globals, atts):
        HandlerBase.__init__(self, parser, parent, globals)
        self.adder = globals['adder']
        self.subject = None
        self.anonymous = 0
        if atts.has_key("about"):
            self.subject = atts["about"]
        elif atts.has_key("ID"):
            self.subject = "#" + atts["ID"]
        elif atts.has_key(ABOUT_ATTRIBUTE):
            self.subject = atts[ABOUT_ATTRIBUTE]
        elif atts.has_key(ID_ATTRIBUTE):
            self.subject = "#" + atts[ID_ATTRIBUTE]
        else:
            self.subject = ANON + generate_uri()
            self.anonymous = 1

        self.subject = absolutize(self.parser.GetBase(), self.subject)

        for att in atts.keys():
            if att == "about" or att == "ID" or \
               att == ABOUT_ATTRIBUTE or att == ID_ATTRIBUTE:
                pass
            else:
                new_att = join(split(att, "^"), "")
                self.adder(self.subject, new_att, atts[att],
                           anonymous_subject=self.anonymous, literal_object=1)
Esempio n. 5
0
 def end(self, name):
     HandlerBase.end(self, name)
     self.codestr = "self.apply("
     if self.modules:
         self.codestr = self.codestr + "modules=(%s,), " % self.modules
     self.codestr = self.codestr + ")"
     code = __builtin__.compile(self.codestr, self.codestr, 'exec')
     self.element.code = code
Esempio n. 6
0
 def __init__(self, parser, parent, name, atts):
     HandlerBase.__init__(self, parser, parent)
     self.locals = self.parent.locals
     self.globals = self.parent.globals
     self.module = parent.module        
     item = atts['item']
     list = atts['list']
     code = __builtin__.compile(list, list, "eval")                
     self.element = ForNodeList(item, code)
Esempio n. 7
0
 def __init__(self, parser, parent, name, base_classes):
     HandlerBase.__init__(self, parser, parent)
     self.locals = {}
     self.locals['_RF_sub_modules'] = []
     self.globals = self.parent.locals
     self.codestr = ""
     self.name = name
     self.module = parent.module
     self.base_classes = base_classes
Esempio n. 8
0
 def __init__(self, parser, parent, name, atts):
     HandlerBase.__init__(self, parser, parent)
     self.locals = parent.locals
     self.globals = parent.globals
     self.module = parent.module
     e_atts = {}
     for key in atts.keys():
         e_atts[key] = parse_attribute(atts[key])
     self.element = ElementNode(name, e_atts)
Esempio n. 9
0
 def __init__(self, parser, name):
     HandlerBase.__init__(self, parser, None)
     self.name = name
     from redfoot.rednode import RedNode
     uri = 'tmp'
     self.rednode = RedNode(uri)
     self.rednode.local.location = "TODOtmplocation"
     self.rednode.local.uri = uri
     self.globals = {'adder': self.rednode.local.add_statement}
Esempio n. 10
0
 def end(self, name):
     HandlerBase.end(self, name)
     self._exec(adjust_indent(self.codestr)+"\n")
     classobj = new.classobj(self.name.encode('ascii'), self.base_classes, self.locals )
     classobj.sub_modules = sub_modules
     module = self.module
     classobj.__module__ = module.__name__
     module.__dict__[classobj.__name__] = classobj
     module.__dict__['_RF_APP'] = classobj
     module.__dict__['_RF_get_app'] = lambda uri, app_class=classobj: app_class(uri)
Esempio n. 11
0
 def __init__(self, parser, parent, globals, atts):
     HandlerBase.__init__(self, parser, parent, globals)
     self.literal = 0
     if atts.has_key("resource"):
         self.value = atts["resource"]
         self.value = absolutize(self.parser.GetBase(), self.value)                
     elif atts.has_key(RESOURCE_ATTRIBUTE):
         self.value = atts[RESOURCE_ATTRIBUTE]
         self.value = absolutize(self.parser.GetBase(), self.value)
     else:
         self.value = ""
         self.literal = 1
Esempio n. 12
0
 def __init__(self, parser, parent, atts={}):
     HandlerBase.__init__(self, parser, parent)
     self.locals = self.parent.locals
     self.globals = self.parent.globals
     self.codestr = ""
     encode = atts.get("encode", None)
     if encode:
         encode = __builtin__.eval(encode, self.globals, self.locals)
     else:
         encode = encode_character_data
     # TODO: add supoprt for EvalNode without Encoding?
     self.element = EncodedEvalNode(None, encode)
Esempio n. 13
0
 def __init__(self, parser, parent, atts):
     HandlerBase.__init__(self, parser, parent)
     if not atts.has_key('instance'):
         msg = "sub-module is missing required instance attribute"
         raise SyntaxError, msg
     instance_name = atts['instance']
     if not atts.has_key('class'):
         msg = "sub-module is missing required class attribute"
         raise SyntaxError, msg
     class_name = atts['class']
     from_str = atts.get('from', None)
     if from_str:
         self.module = self.parent.module
         self.globals = self.module.__dict__
         self.locals = self.globals
         self._exec("from %s import %s" % (from_str, class_name))
     parent.locals['_RF_sub_modules'].append((instance_name, class_name))
Esempio n. 14
0
 def __init__(self, parser, name):
     HandlerBase.__init__(self, parser, None)
     self.name = name
Esempio n. 15
0
 def __init__(self, parser, parent, globals):
     HandlerBase.__init__(self, parser, parent, globals)
Esempio n. 16
0
 def end(self, name):
     self.adder(self.parent.subject, self.predicate, self.object,
                literal_object=self.literal, anonymous_object=self.anonymous_object)
     HandlerBase.end(self, name)
Esempio n. 17
0
 def end(self, name):
     self.parent.add_li(self.value, self.literal)
     HandlerBase.end(self, name)
Esempio n. 18
0
 def end(self, name):
     HandlerBase.end(self, name)
     exec self.codestr+"\n" in self.globals, self.locals
Esempio n. 19
0
 def __init__(self, parser, parent, name):
     HandlerBase.__init__(self, parser, parent)
     self.module = new.module(name)
     self.globals = self.module.__dict__
     self.locals = self.globals
     self.codestr = ""
Esempio n. 20
0
 def __init__(self, parser):
     HandlerBase.__init__(self, parser, None)
Esempio n. 21
0
 def end(self, name):
     HandlerBase.end(self, name)
     self._exec(adjust_indent(self.codestr)+"\n")
Esempio n. 22
0
 def end(self, name):
     HandlerBase.end(self, name)
     self.codestr = adjust_indent(self.codestr)
     code = __builtin__.compile(self.codestr, self.codestr, self.kind())
     self.element.code = code
Esempio n. 23
0
 def __init__(self, parser, parent, modules):
     HandlerBase.__init__(self, parser, parent)
     self.locals = self.parent.locals
     self.globals = self.parent.globals
     self.modules = modules
     self.element = EvalNode()