diff --git a/tilde-train.py b/tilde-train.py index 3ed807d..f9e4ebf 100755 --- a/tilde-train.py +++ b/tilde-train.py @@ -167,9 +167,6 @@ def test_user_car(): print("Yours contained " + bad_chars) sys.exit(1) -# print("") -# print("Test results:") - train_height = len(choochoo_list) train_length = len(max(choochoo_list, key=len)) @@ -238,7 +235,6 @@ def print_all_cars(): for fname in glob.glob('/home/*/' + traincarFN): try: with open(fname, 'r') as myfile: - # print fname # debug, print file path and name choochoo_string = myfile.read() choochoo_list = choochoo_string.split("\n") if len(choochoo_list) > max_y+1: @@ -250,10 +246,8 @@ def print_all_cars(): print(fname + ":") print("\n".join(car)) # print the car to stdout - # HOW TO CLOSE THE FILE HANDLE? fname.close(), close(fname), ...? except: pass; -# print "Cannot open " + fname # for debuggering purposes def chuggachugga(stdscr: curses.window): @@ -264,37 +258,19 @@ def chuggachugga(stdscr: curses.window): while True: for idx,train_layer in enumerate(reversed(train)): -# screen.print_at(train_layer, x_pos, (y_pos-idx)) -# stdscr.addstr((y_pos-idx),x_pos,train_layer) train_snip_start = 0 if (x_pos >= 0) else min(abs(x_pos), len(train_layer)) train_snip_end = w-x_pos if (w-x_pos <= len(train_layer)) else len(train_layer) -# train_snip_end = min(len(train_layer),w-x_pos) x = max(0, x_pos) -# stdscr.addstr(2,2,"start: " + str(train_snip_start)) -# stdscr.addstr(3,2,"end: "+ str(train_snip_end)) -# stdscr.addstr(4,2,"x_pos: " + str(x_pos)) -# stdscr.addstr(5,2,"train len: " + str(len(train_layer))) stdscr.addstr((y_pos-idx),x,train_layer[train_snip_start:train_snip_end]) x_pos -= 1 if x_pos == -train_len: -# stdscr.addstr(2,5,"here we are!") -# time.sleep(10) return stdscr.refresh() time.sleep(.03) -# ev = stdscr.getch() # seems like curses waits for input, which won't work here. -# if ev in (ord('Q'), ord('q')): -# return -# elif ev == curses.KEY_UP: # up -# y_pos += 1 -# elif ev == curses.KEY_DOWN: # down -# y_pos -= 1 - - def handler(signal_received, frame): print("Oops. The train broke. The engineer is looking into it!") print("(Note: the train does not work in all terminals yet.)") @@ -333,10 +309,8 @@ for fname in glob.glob('/home/*/' + traincarFN): if car != 0: cars.append(car) # start a list of lists (list of cars) here. - # HOW TO CLOSE THE FILE HANDLE? fname.close(), close(fname), ...? except: pass; - #print "Cannot open " + fname # for debuggering purposes while len(cars) < max_cars: cars.append([*default_car]) # add copies of default cars if train too short