-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathtranslator.py
More file actions
executable file
·50 lines (41 loc) · 1.31 KB
/
Copy pathtranslator.py
File metadata and controls
executable file
·50 lines (41 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
import sys
from python_to_pythonjs import main as python_to_pythonjs
from pythonjs import main as pythonjs_to_javascript
from pythonjs_to_dart import main as pythonjs_to_dart
from pythonjs_to_coffee import main as pythonjs_to_coffee
from pythonjs_to_lua import main as pythonjs_to_lua
from pythonjs_to_luajs import main as pythonjs_to_luajs
def main(script):
if '--visjs' in sys.argv:
import python_to_visjs
return python_to_visjs.main( script )
else:
a = python_to_pythonjs(script)
if '--dart' in sys.argv:
return pythonjs_to_dart( a )
elif '--coffee' in sys.argv:
return pythonjs_to_coffee( a )
elif '--lua' in sys.argv:
return pythonjs_to_lua( a )
elif '--luajs' in sys.argv:
return pythonjs_to_luajs( a )
else:
return pythonjs_to_javascript( a )
def command():
scripts = []
if len(sys.argv) > 1:
for arg in sys.argv[1:]:
if arg.endswith('.py'):
scripts.append( arg )
if len(scripts):
a = []
for script in scripts:
a.append( open(script, 'rb').read() )
data = '\n'.join( a )
else:
data = sys.stdin.read()
js = main(data)
print(js)
if __name__ == '__main__':
command()