Example #1
0
def _vtranslate(code):
    if PYTHONJS:
        exe = os.path.expanduser('~/PythonJS/pythonjs/translator.py')
        assert os.path.isfile(exe)
        cmd = [exe]
        proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
        stdout, stderr = proc.communicate( code )
        print(stdout)
        if stderr:
            print(stderr)
            raise RuntimeError('pythonjs translation failed!')
        else:
            return stdout
    else:
        tree = parse(code)
        translator = Veloce()
        translator.visit(tree)
        return translator.writer.value()
Example #2
0
def _vtranslate(code):
    tree = parse(code)
    translator = Veloce()
    translator.visit(tree)
    return translator.writer.value()
def _vtranslate(code):
    tree = parse(code)
    translator = Veloce()
    translator.visit(tree)
    return translator.writer.value()