This repository was archived by the owner on Mar 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathjr.py
80 lines (65 loc) · 2.13 KB
/
jr.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import curses
import glob
import sys
import time
width = 80
height = 30
def init():
stdscr = curses.initscr()
term_height,term_width = stdscr.getmaxyx()
curses.noecho() # don't echo the keys on the screen
curses.cbreak() # don't wait enter for input
window = curses.newwin(width, height, 0, 0) # create a window
if term_height <= height or term_width <= width:
destruct(stdscr, window)
print("\x1b[8;" + str(height + 1) + ";" + str(width + 1) + "t")
time.sleep(1)
stdscr, window = init()
# quit()
window.box() # Draw the box outside the window
stdscr.clear()
return window, stdscr
def destruct(window, stdscr):
curses.nocbreak()
stdscr.keypad(False)
curses.echo()
curses.endwin()
def parseFile(cur_file):
result = []
for line in cur_file:
if len(line) < width:
line += " " * (width - len(line))
result.append(line)
if len(result) < height:
for i in range(height - len(result)):
result.append(" " * width)
return result
def main(stdscr):
window, stdscr = init()
if len(sys.argv) > 1:
year_key = sys.argv[1]
else:
year_key = "*"
frames = []
black = []
for i in range(height):
black.append(" " * width)
frames.append(black)
frames.append(parseFile(open("required/ship.txt", "r")))
for yearFolder in glob.glob("years/" + year_key):
for folder in glob.glob(yearFolder+"/*")[::-1]:
for filename in glob.glob(folder+"/*.txt"):
cur_file = open(filename, "r")
frames.append(parseFile(cur_file))
frames.append(parseFile(open("required/jason.txt", "r")))
emptyFile = [[" "] * width] * height
frames.append(emptyFile)
for start_col in range((len(frames) - 1) * width):
for col in range(width):
for row in range(height):
stdscr.addch(row, col, (frames[(start_col + col) / width][row][(start_col + col) % width]))
stdscr.refresh()
time.sleep(0.05)
destruct(window, stdscr)
if __name__ == "__main__":
curses.wrapper(main)