Example #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))
Example #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))
Example #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)))
Example #4
0
 def parse(self, code):
     return dump_ast(parse(code, '<remote eval>'))
Example #5
0
 def eval_code(self, code, user):
     ast = parse(code, '<remote eval>')
     return self.context.ml.eval(ast)
Example #6
0
def eval_(line):
    return config.instance.eval(parse(line, '<stdin>'))
Example #7
0
 def parse(self, code):
     return dump_ast(parse(code, '<remote eval>'))
Example #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>'))