Some cleanup in the Tools directory.

This commit is contained in:
Florent Xicluna 2012-07-07 17:03:54 +02:00
parent 61ea12c9a0
commit c20740109d
8 changed files with 53 additions and 49 deletions

View file

@ -10,7 +10,6 @@
import time import time
import os import os
import sys import sys
import functools
import itertools import itertools
import threading import threading
import subprocess import subprocess

View file

@ -120,8 +120,11 @@ def display(self, update_board=True):
random.randrange(1, 7))) random.randrange(1, 7)))
self.scr.addch(j + 1, i + 1, self.char) self.scr.addch(j + 1, i + 1, self.char)
self.scr.attrset(0) self.scr.attrset(0)
if not live: self.boring = 0 if not live:
elif s == 2 and live: d[i,j] = 1 # Survival self.boring = 0
elif s == 2 and live:
# Survival
d[i, j] = 1
elif live: elif live:
# Death # Death
self.scr.addch(j + 1, i + 1, ' ') self.scr.addch(j + 1, i + 1, ' ')
@ -145,6 +148,7 @@ def erase_menu(stdscr, menu_y):
stdscr.move(menu_y + 1, 0) stdscr.move(menu_y + 1, 0)
stdscr.clrtoeol() stdscr.clrtoeol()
def display_menu(stdscr, menu_y): def display_menu(stdscr, menu_y):
"Display the menu of possible keystroke commands" "Display the menu of possible keystroke commands"
erase_menu(stdscr, menu_y) erase_menu(stdscr, menu_y)
@ -158,6 +162,7 @@ def display_menu(stdscr, menu_y):
'E)rase the board, R)andom fill, S)tep once or C)ontinuously, Q)uit') 'E)rase the board, R)andom fill, S)tep once or C)ontinuously, Q)uit')
stdscr.attrset(0) stdscr.attrset(0)
def keyloop(stdscr): def keyloop(stdscr):
# Clear the screen and display the menu of keys # Clear the screen and display the menu of keys
stdscr.clear() stdscr.clear()
@ -224,11 +229,17 @@ def keyloop(stdscr):
board.display(update_board=False) board.display(update_board=False)
elif c in 'Ss': elif c in 'Ss':
board.display() board.display()
else: pass # Ignore incorrect keys else:
elif c == curses.KEY_UP and ypos > 0: ypos -= 1 # Ignore incorrect keys
elif c == curses.KEY_DOWN and ypos < board.Y-1: ypos += 1 pass
elif c == curses.KEY_LEFT and xpos > 0: xpos -= 1 elif c == curses.KEY_UP and ypos > 0:
elif c == curses.KEY_RIGHT and xpos < board.X-1: xpos += 1 ypos -= 1
elif c == curses.KEY_DOWN and ypos + 1 < board.Y:
ypos += 1
elif c == curses.KEY_LEFT and xpos > 0:
xpos -= 1
elif c == curses.KEY_RIGHT and xpos + 1 < board.X:
xpos += 1
elif c == curses.KEY_MOUSE: elif c == curses.KEY_MOUSE:
mouse_id, mouse_x, mouse_y, mouse_z, button_state = curses.getmouse() mouse_id, mouse_x, mouse_y, mouse_z, button_state = curses.getmouse()
if (mouse_x > 0 and mouse_x < board.X + 1 and if (mouse_x > 0 and mouse_x < board.X + 1 and

View file

@ -812,7 +812,6 @@ def sync(self):
def test_basic(): def test_basic():
"Basic non-gui self-test." "Basic non-gui self-test."
import os
a = Sheet() a = Sheet()
for x in range(1, 11): for x in range(1, 11):
for y in range(1, 11): for y in range(1, 11):

View file

@ -163,7 +163,6 @@
import getopt import getopt
import token import token
import tokenize import tokenize
import operator
__version__ = '1.5' __version__ = '1.5'

View file

@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# This file should be kept compatible with both Python 2.6 and Python >= 3.0. # This file should be kept compatible with both Python 2.6 and Python >= 3.0.
import functools
import hashlib
import itertools import itertools
import os import os
import platform import platform

View file

@ -1,6 +1,5 @@
"Usage: unparse.py <path to source file>" "Usage: unparse.py <path to source file>"
import sys import sys
import math
import ast import ast
import tokenize import tokenize
import io import io

View file

@ -35,7 +35,9 @@
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE ! WITH THE USE OR PERFORMANCE OF THIS SOFTWARE !
""" """
import sys, time, operator, platform import sys
import time
import platform
from CommandLine import * from CommandLine import *
try: try:
@ -962,8 +964,6 @@ def main(self):
bench.name = reportfile bench.name = reportfile
pickle.dump(bench,f) pickle.dump(bench,f)
f.close() f.close()
except IOError as reason:
print('* Error opening/writing reportfile')
except IOError as reason: except IOError as reason:
print('* Error opening/writing reportfile %s: %s' % ( print('* Error opening/writing reportfile %s: %s' % (
reportfile, reportfile,

View file

@ -32,7 +32,6 @@
import zipfile import zipfile
from textwrap import dedent from textwrap import dedent
from operator import itemgetter
SCRIPT = sys.argv[0] SCRIPT = sys.argv[0]
VERSION = "3.2" VERSION = "3.2"