forked from DenerosArmy/pythonscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs.py
More file actions
30 lines (22 loc) · 660 Bytes
/
js.py
File metadata and controls
30 lines (22 loc) · 660 Bytes
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
from notebook import convert
import getopt
import sys
import os
import ast
from notebook import convert
if __name__ == '__main__':
if len(sys.argv) not in (2,3):
print "Need exactly one argument, the filename, and one option -n"
exit(1)
semis = True
try:
opts, args = getopt.getopt(sys.argv[2:], "n", ["no_semicolons"])
except getopt.GetoptError:
sys.exit(2)
for opt, arg in opts:
if opt in ("-n", "--no_semicolons"):
semis = False
filename = sys.argv[1]
with open(os.path.abspath(filename)) as f:
t = ast.parse(f.read(), filename)
print convert(t, semis)