Beispiel #1
0
def eval_(ast):
    if isinstance(ast, str):
        ast = parse(ast, '<eval>')

    if isinstance(ast, Quote):
        ast = ast.body

    return Sequence(*config.instance.eval(ast))
Beispiel #2
0
def eval_(ast):
    if isinstance(ast, str):
        ast = parse(ast, '<eval>')

    if isinstance(ast, Quote):
        ast = ast.body

    return Sequence(*config.instance.eval(ast, first=True))
Beispiel #3
0
 def run(self, context, args, kwargs, opargs):
     if len(args) == 0:
         raise CommandException(_("Please provide a filename. For help see 'help <command>'"))
     else:
         for arg in args:
             arg = os.path.expanduser(arg)
             if os.path.isfile(arg):
                 try:
                     with open(arg, 'rb') as f:
                         ast = parse(f.read().decode('utf8'), arg)
                         context.eval_block(ast)
                 except UnicodeDecodeError as e:
                     raise CommandException(_(
                         "Incorrect filetype, cannot parse file: {0}".format(str(e))
                     ))
             else:
                 raise CommandException(_("File {0} does not exist.".format(arg)))
Beispiel #4
0
 def parse(self, code):
     return dump_ast(parse(code, '<remote eval>'))
Beispiel #5
0
 def eval_code(self, code, user):
     ast = parse(code, '<remote eval>')
     return self.context.ml.eval(ast)
Beispiel #6
0
def eval_(line):
    return config.instance.eval(parse(line, '<stdin>'))
Beispiel #7
0
 def parse(self, code):
     return dump_ast(parse(code, '<remote eval>'))
Beispiel #8
0
 def eval_code(self, code, user):
     ast = parse(code, '<remote eval>')
     return self.context.ml.eval(ast)
def eval_(line):
    return config.instance.eval(parse(line, '<stdin>'))