From 9e34f059594dce29ac270d032b0788f7b64ee307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20P=2E=20Tjern=C3=B8?= Date: Wed, 20 Aug 2008 14:03:24 +0200 Subject: [PATCH] Fix some warnings, allow easier checking with pychecker. --- .gitignore | 1 + .pycheckrc | 1 + bpython.py | 42 ++++++++++++++++++++++-------------------- 3 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 .gitignore create mode 100644 .pycheckrc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/.pycheckrc b/.pycheckrc new file mode 100644 index 0000000..e7050fa --- /dev/null +++ b/.pycheckrc @@ -0,0 +1 @@ +blacklist = ['pyparsing', 'code', 'pygments/lexer'] diff --git a/bpython.py b/bpython.py index 0a6526d..c44deae 100644 --- a/bpython.py +++ b/bpython.py @@ -29,11 +29,9 @@ import os import sys import curses import code -import codeop import traceback import re import time -import math import urllib import rlcompleter import inspect @@ -61,6 +59,8 @@ from pyparsing import Forward, Suppress, QuotedString, dblQuotedString, \ alphas, alphanums, printables, ParseException OPTS.arg_spec = True +DO_RESIZE = False + # TODO: # # C-l doesn't repaint the screen yet. @@ -200,6 +200,7 @@ class Repl( object ): self.tablen = None self.s = '' self.list_win_visible = False + self._C = {} if not OPTS.arg_spec: return @@ -1487,23 +1488,24 @@ def main( scr ): repl.repl() return repl.getstdout() -tb = None -try: - o = curses.wrapper( main ) -except: - tb = traceback.format_exc() -# I don't know why this is necessary; without it the wrapper doesn't always -# do its job. - if stdscr is not None: - stdscr.keypad(0) - curses.echo() - curses.nocbreak() - curses.endwin() +if __name__ == '__main__': + tb = None + try: + o = curses.wrapper( main ) + except: + tb = traceback.format_exc() + # I don't know why this is necessary; without it the wrapper doesn't always + # do its job. + if stdscr is not None: + stdscr.keypad(0) + curses.echo() + curses.nocbreak() + curses.endwin() -sys.stdout = sys.__stdout__ -if tb: - print tb - sys.exit(1) + sys.stdout = sys.__stdout__ + if tb: + print tb + sys.exit(1) -sys.stdout.write( o ) # Fake stdout data so everything's still visible after exiting -sys.stdout.flush() + sys.stdout.write( o ) # Fake stdout data so everything's still visible after exiting + sys.stdout.flush()