Ejemplo n.º 1
0
    def _import(self, receiver, context, m, name):
        name = name.name if name.value is None else unicode(name.eval(context))

        # In case we're importing from inside a module.
        if context.type == "Module" and receiver is context:
            m = parse(tokenize("""Importer import("{0:s}")""".format(name)))
            return m.eval(receiver, context, m)

        if name == "*":
            context.attrs.update(receiver.attrs)
        else:
            context[name] = receiver[name]

        return runtime.find("None")
Ejemplo n.º 2
0
def parse(s):
    return parser.parse(lexer.tokenize(s))
Ejemplo n.º 3
0
 def parse(self, receiver, context, m, code):
     code = str(code.eval(context))
     return parse(tokenize(code))
Ejemplo n.º 4
0
def tokenize(code):
    return " ".join(map(attrgetter("value"), lexer.tokenize(code)))