-
Notifications
You must be signed in to change notification settings - Fork 0
/
fdl-run
executable file
·37 lines (35 loc) · 991 Bytes
/
fdl-run
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
#!/usr/bin/env python3
import turtle
import sys
import os
from turtles.resizingturtle import ResizingTurtle
from turtles.turtle3d import Turtle3D
from fdl import run, parse
def runner(file):
file = "files/"+file
parsed = parse(file)
trtl = Turtle3D() if parsed["3d"] else ResizingTurtle()
trtl.speed(0)
turtle.tracer(100)
run(trtl, file)
turtle.update()
turtle.mainloop()
if sys.argv[-1] != __file__:
file = sys.argv[-1]
if file[-4:] != ".fdl":
file = file + ".fdl"
runner(file)
else:
cwd = os.getcwd()
n = 1
d = {}
cwd = cwd + "/files"
print(str("Type integers between 1-") + str(len(os.listdir(cwd))) + str(" to draw the following fdl files"))
for filename in os.listdir(cwd):
if filename.endswith(".fdl"):
print(str(n) + " : " + os.path.join(filename))
d[str(n)] = str(os.path.join(filename))
n += 1
invar = str(input())
file = d.get(invar)
runner(file)