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")
def parse(s): return parser.parse(lexer.tokenize(s))
def parse(self, receiver, context, m, code): code = str(code.eval(context)) return parse(tokenize(code))
def tokenize(code): return " ".join(map(attrgetter("value"), lexer.tokenize(code)))