Kaydet (Commit) bffa52f0 authored tarafından Guido van Rossum's avatar Guido van Rossum

Whitespace normalization (get rid of tabs).

üst af7a302c
"""Constants and membership tests for ASCII characters""" """Constants and membership tests for ASCII characters"""
NUL = 0x00 # ^@ NUL = 0x00 # ^@
SOH = 0x01 # ^A SOH = 0x01 # ^A
STX = 0x02 # ^B STX = 0x02 # ^B
ETX = 0x03 # ^C ETX = 0x03 # ^C
EOT = 0x04 # ^D EOT = 0x04 # ^D
ENQ = 0x05 # ^E ENQ = 0x05 # ^E
ACK = 0x06 # ^F ACK = 0x06 # ^F
BEL = 0x07 # ^G BEL = 0x07 # ^G
BS = 0x08 # ^H BS = 0x08 # ^H
TAB = 0x09 # ^I TAB = 0x09 # ^I
HT = 0x09 # ^I HT = 0x09 # ^I
LF = 0x0a # ^J LF = 0x0a # ^J
NL = 0x0a # ^J NL = 0x0a # ^J
VT = 0x0b # ^K VT = 0x0b # ^K
FF = 0x0c # ^L FF = 0x0c # ^L
CR = 0x0d # ^M CR = 0x0d # ^M
SO = 0x0e # ^N SO = 0x0e # ^N
SI = 0x0f # ^O SI = 0x0f # ^O
DLE = 0x10 # ^P DLE = 0x10 # ^P
DC1 = 0x11 # ^Q DC1 = 0x11 # ^Q
DC2 = 0x12 # ^R DC2 = 0x12 # ^R
DC3 = 0x13 # ^S DC3 = 0x13 # ^S
DC4 = 0x14 # ^T DC4 = 0x14 # ^T
NAK = 0x15 # ^U NAK = 0x15 # ^U
SYN = 0x16 # ^V SYN = 0x16 # ^V
ETB = 0x17 # ^W ETB = 0x17 # ^W
CAN = 0x18 # ^X CAN = 0x18 # ^X
EM = 0x19 # ^Y EM = 0x19 # ^Y
SUB = 0x1a # ^Z SUB = 0x1a # ^Z
ESC = 0x1b # ^[ ESC = 0x1b # ^[
FS = 0x1c # ^\ FS = 0x1c # ^\
GS = 0x1d # ^] GS = 0x1d # ^]
RS = 0x1e # ^^ RS = 0x1e # ^^
US = 0x1f # ^_ US = 0x1f # ^_
SP = 0x20 # space SP = 0x20 # space
DEL = 0x7f # delete DEL = 0x7f # delete
controlnames = [ controlnames = [
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
...@@ -53,7 +53,7 @@ def _ctoi(c): ...@@ -53,7 +53,7 @@ def _ctoi(c):
def isalnum(c): return isalpha(c) or isdigit(c) def isalnum(c): return isalpha(c) or isdigit(c)
def isalpha(c): return isupper(c) or islower(c) def isalpha(c): return isupper(c) or islower(c)
def isascii(c): return _ctoi(c) <= 127 # ? def isascii(c): return _ctoi(c) <= 127 # ?
def isblank(c): return _ctoi(c) in (8,32) def isblank(c): return _ctoi(c) in (8,32)
def iscntrl(c): return _ctoi(c) <= 31 def iscntrl(c): return _ctoi(c) <= 31
def isdigit(c): return _ctoi(c) >= 48 and _ctoi(c) <= 57 def isdigit(c): return _ctoi(c) >= 48 and _ctoi(c) <= 57
...@@ -97,4 +97,3 @@ def unctrl(c): ...@@ -97,4 +97,3 @@ def unctrl(c):
if bits & 0x80: if bits & 0x80:
return "!" + rep return "!" + rep
return rep return rep
...@@ -71,7 +71,7 @@ class Textbox: ...@@ -71,7 +71,7 @@ class Textbox:
self.win.addch(ch) self.win.addch(ch)
except curses.error: except curses.error:
pass pass
elif ch == ascii.SOH: # ^a elif ch == ascii.SOH: # ^a
self.win.move(y, 0) self.win.move(y, 0)
elif ch in (ascii.STX,curses.KEY_LEFT, ascii.BS,curses.KEY_BACKSPACE): elif ch in (ascii.STX,curses.KEY_LEFT, ascii.BS,curses.KEY_BACKSPACE):
if x > 0: if x > 0:
...@@ -84,48 +84,48 @@ class Textbox: ...@@ -84,48 +84,48 @@ class Textbox:
self.win.move(y-1, self.maxx) self.win.move(y-1, self.maxx)
if ch in (ascii.BS, curses.KEY_BACKSPACE): if ch in (ascii.BS, curses.KEY_BACKSPACE):
self.win.delch() self.win.delch()
elif ch == ascii.EOT: # ^d elif ch == ascii.EOT: # ^d
self.win.delch() self.win.delch()
elif ch == ascii.ENQ: # ^e elif ch == ascii.ENQ: # ^e
if self.stripspaces: if self.stripspaces:
self.win.move(y, self._end_of_line(y)) self.win.move(y, self._end_of_line(y))
else: else:
self.win.move(y, self.maxx) self.win.move(y, self.maxx)
elif ch in (ascii.ACK, curses.KEY_RIGHT): # ^f elif ch in (ascii.ACK, curses.KEY_RIGHT): # ^f
if x < self.maxx: if x < self.maxx:
self.win.move(y, x+1) self.win.move(y, x+1)
elif y == self.maxy: elif y == self.maxy:
pass pass
else: else:
self.win.move(y+1, 0) self.win.move(y+1, 0)
elif ch == ascii.BEL: # ^g elif ch == ascii.BEL: # ^g
return 0 return 0
elif ch == ascii.NL: # ^j elif ch == ascii.NL: # ^j
if self.maxy == 0: if self.maxy == 0:
return 0 return 0
elif y < self.maxy: elif y < self.maxy:
self.win.move(y+1, 0) self.win.move(y+1, 0)
elif ch == ascii.VT: # ^k elif ch == ascii.VT: # ^k
if x == 0 and self._end_of_line(y) == 0: if x == 0 and self._end_of_line(y) == 0:
self.win.deleteln() self.win.deleteln()
else: else:
self.win.clrtoeol() self.win.clrtoeol()
elif ch == ascii.FF: # ^l elif ch == ascii.FF: # ^l
self.win.refresh() self.win.refresh()
elif ch in (ascii.SO, curses.KEY_DOWN): # ^n elif ch in (ascii.SO, curses.KEY_DOWN): # ^n
if y < self.maxy: if y < self.maxy:
self.win.move(y+1, x) self.win.move(y+1, x)
if x > self._end_of_line(y+1): if x > self._end_of_line(y+1):
self.win.move(y+1, self._end_of_line(y+1)) self.win.move(y+1, self._end_of_line(y+1))
elif ch == ascii.SI: # ^o elif ch == ascii.SI: # ^o
self.win.insertln() self.win.insertln()
elif ch in (ascii.DLE, curses.KEY_UP): # ^p elif ch in (ascii.DLE, curses.KEY_UP): # ^p
if y > 0: if y > 0:
self.win.move(y-1, x) self.win.move(y-1, x)
if x > self._end_of_line(y-1): if x > self._end_of_line(y-1):
self.win.move(y-1, self._end_of_line(y-1)) self.win.move(y-1, self._end_of_line(y-1))
return 1 return 1
def gather(self): def gather(self):
"Collect and return the contents of the window." "Collect and return the contents of the window."
result = "" result = ""
......
...@@ -16,20 +16,20 @@ def wrapper(func, *rest): ...@@ -16,20 +16,20 @@ def wrapper(func, *rest):
as its first argument, followed by any other arguments passed to as its first argument, followed by any other arguments passed to
wrapper(). wrapper().
""" """
res = None res = None
try: try:
# Initialize curses # Initialize curses
stdscr=curses.initscr() stdscr=curses.initscr()
# Turn off echoing of keys, and enter cbreak mode, # Turn off echoing of keys, and enter cbreak mode,
# where no buffering is performed on keyboard input # where no buffering is performed on keyboard input
curses.noecho() curses.noecho()
curses.cbreak() curses.cbreak()
# In keypad mode, escape sequences for special keys # In keypad mode, escape sequences for special keys
# (like the cursor keys) will be interpreted and # (like the cursor keys) will be interpreted and
# a special value like curses.KEY_LEFT will be returned # a special value like curses.KEY_LEFT will be returned
stdscr.keypad(1) stdscr.keypad(1)
# Start color, too. Harmless if the terminal doesn't have # Start color, too. Harmless if the terminal doesn't have
...@@ -43,21 +43,21 @@ def wrapper(func, *rest): ...@@ -43,21 +43,21 @@ def wrapper(func, *rest):
res = apply(func, (stdscr,) + rest) res = apply(func, (stdscr,) + rest)
except: except:
# In the event of an error, restore the terminal # In the event of an error, restore the terminal
# to a sane state. # to a sane state.
stdscr.keypad(0) stdscr.keypad(0)
curses.echo() curses.echo()
curses.nocbreak() curses.nocbreak()
curses.endwin() curses.endwin()
# Pass the exception upwards # Pass the exception upwards
(exc_type, exc_value, exc_traceback) = sys.exc_info() (exc_type, exc_value, exc_traceback) = sys.exc_info()
raise exc_type, exc_value, exc_traceback raise exc_type, exc_value, exc_traceback
else: else:
# Set everything back to normal # Set everything back to normal
stdscr.keypad(0) stdscr.keypad(0)
curses.echo() curses.echo()
curses.nocbreak() curses.nocbreak()
curses.endwin() # Terminate curses curses.endwin() # Terminate curses
return res return res
...@@ -16,7 +16,7 @@ handles the EMX port of the GNU C compiler to OS/2. ...@@ -16,7 +16,7 @@ handles the EMX port of the GNU C compiler to OS/2.
# of Python is only distributed with threads enabled. # of Python is only distributed with threads enabled.
# #
# tested configurations: # tested configurations:
# #
# * EMX gcc 2.81/EMX 0.9d fix03 # * EMX gcc 2.81/EMX 0.9d fix03
# created 2001/5/7, Andrew MacIntyre, from Rene Liebscher's cywinccompiler.py # created 2001/5/7, Andrew MacIntyre, from Rene Liebscher's cywinccompiler.py
...@@ -40,7 +40,7 @@ class EMXCCompiler (UnixCCompiler): ...@@ -40,7 +40,7 @@ class EMXCCompiler (UnixCCompiler):
shared_lib_format = "%s%s" shared_lib_format = "%s%s"
res_extension = ".res" # compiled resource file res_extension = ".res" # compiled resource file
exe_extension = ".exe" exe_extension = ".exe"
def __init__ (self, def __init__ (self,
verbose=0, verbose=0,
dry_run=0, dry_run=0,
...@@ -56,11 +56,11 @@ class EMXCCompiler (UnixCCompiler): ...@@ -56,11 +56,11 @@ class EMXCCompiler (UnixCCompiler):
"Python's pyconfig.h doesn't seem to support your compiler. " + "Python's pyconfig.h doesn't seem to support your compiler. " +
("Reason: %s." % details) + ("Reason: %s." % details) +
"Compiling may fail because of undefined preprocessor macros.") "Compiling may fail because of undefined preprocessor macros.")
(self.gcc_version, self.ld_version) = \ (self.gcc_version, self.ld_version) = \
get_versions() get_versions()
self.debug_print(self.compiler_type + ": gcc %s, ld %s\n" % self.debug_print(self.compiler_type + ": gcc %s, ld %s\n" %
(self.gcc_version, (self.gcc_version,
self.ld_version) ) self.ld_version) )
# Hard-code GCC because that's what this is all about. # Hard-code GCC because that's what this is all about.
...@@ -73,7 +73,7 @@ class EMXCCompiler (UnixCCompiler): ...@@ -73,7 +73,7 @@ class EMXCCompiler (UnixCCompiler):
# want the gcc library statically linked (so that we don't have # want the gcc library statically linked (so that we don't have
# to distribute a version dependent on the compiler we have) # to distribute a version dependent on the compiler we have)
self.dll_libraries=["gcc"] self.dll_libraries=["gcc"]
# __init__ () # __init__ ()
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
...@@ -83,7 +83,7 @@ class EMXCCompiler (UnixCCompiler): ...@@ -83,7 +83,7 @@ class EMXCCompiler (UnixCCompiler):
self.spawn(["rc", "-r", src]) self.spawn(["rc", "-r", src])
except DistutilsExecError, msg: except DistutilsExecError, msg:
raise CompileError, msg raise CompileError, msg
else: # for other files use the C-compiler else: # for other files use the C-compiler
try: try:
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
extra_postargs) extra_postargs)
...@@ -103,12 +103,12 @@ class EMXCCompiler (UnixCCompiler): ...@@ -103,12 +103,12 @@ class EMXCCompiler (UnixCCompiler):
extra_preargs=None, extra_preargs=None,
extra_postargs=None, extra_postargs=None,
build_temp=None): build_temp=None):
# use separate copies, so we can modify the lists # use separate copies, so we can modify the lists
extra_preargs = copy.copy(extra_preargs or []) extra_preargs = copy.copy(extra_preargs or [])
libraries = copy.copy(libraries or []) libraries = copy.copy(libraries or [])
objects = copy.copy(objects or []) objects = copy.copy(objects or [])
# Additional libraries # Additional libraries
libraries.extend(self.dll_libraries) libraries.extend(self.dll_libraries)
...@@ -118,10 +118,10 @@ class EMXCCompiler (UnixCCompiler): ...@@ -118,10 +118,10 @@ class EMXCCompiler (UnixCCompiler):
(target_desc != self.EXECUTABLE)): (target_desc != self.EXECUTABLE)):
# (The linker doesn't do anything if output is up-to-date. # (The linker doesn't do anything if output is up-to-date.
# So it would probably better to check if we really need this, # So it would probably better to check if we really need this,
# but for this we had to insert some unchanged parts of # but for this we had to insert some unchanged parts of
# UnixCCompiler, and this is not what we want.) # UnixCCompiler, and this is not what we want.)
# we want to put some files in the same directory as the # we want to put some files in the same directory as the
# object files are, build_temp doesn't help much # object files are, build_temp doesn't help much
# where are the object files # where are the object files
temp_dir = os.path.dirname(objects[0]) temp_dir = os.path.dirname(objects[0])
...@@ -131,7 +131,7 @@ class EMXCCompiler (UnixCCompiler): ...@@ -131,7 +131,7 @@ class EMXCCompiler (UnixCCompiler):
# generate the filenames for these files # generate the filenames for these files
def_file = os.path.join(temp_dir, dll_name + ".def") def_file = os.path.join(temp_dir, dll_name + ".def")
# Generate .def file # Generate .def file
contents = [ contents = [
"LIBRARY %s INITINSTANCE TERMINSTANCE" % \ "LIBRARY %s INITINSTANCE TERMINSTANCE" % \
...@@ -144,21 +144,21 @@ class EMXCCompiler (UnixCCompiler): ...@@ -144,21 +144,21 @@ class EMXCCompiler (UnixCCompiler):
"writing %s" % def_file) "writing %s" % def_file)
# next add options for def-file and to creating import libraries # next add options for def-file and to creating import libraries
# for gcc/ld the def-file is specified as any other object files # for gcc/ld the def-file is specified as any other object files
objects.append(def_file) objects.append(def_file)
#end: if ((export_symbols is not None) and #end: if ((export_symbols is not None) and
# (target_desc != self.EXECUTABLE or self.linker_dll == "gcc")): # (target_desc != self.EXECUTABLE or self.linker_dll == "gcc")):
# who wants symbols and a many times larger output file # who wants symbols and a many times larger output file
# should explicitly switch the debug mode on # should explicitly switch the debug mode on
# otherwise we let dllwrap/ld strip the output file # otherwise we let dllwrap/ld strip the output file
# (On my machine: 10KB < stripped_file < ??100KB # (On my machine: 10KB < stripped_file < ??100KB
# unstripped_file = stripped_file + XXX KB # unstripped_file = stripped_file + XXX KB
# ( XXX=254 for a typical python extension)) # ( XXX=254 for a typical python extension))
if not debug: if not debug:
extra_preargs.append("-s") extra_preargs.append("-s")
UnixCCompiler.link(self, UnixCCompiler.link(self,
target_desc, target_desc,
objects, objects,
...@@ -172,7 +172,7 @@ class EMXCCompiler (UnixCCompiler): ...@@ -172,7 +172,7 @@ class EMXCCompiler (UnixCCompiler):
extra_preargs, extra_preargs,
extra_postargs, extra_postargs,
build_temp) build_temp)
# link () # link ()
# -- Miscellaneous methods ----------------------------------------- # -- Miscellaneous methods -----------------------------------------
...@@ -196,7 +196,7 @@ class EMXCCompiler (UnixCCompiler): ...@@ -196,7 +196,7 @@ class EMXCCompiler (UnixCCompiler):
base = os.path.basename (base) base = os.path.basename (base)
if ext == '.rc': if ext == '.rc':
# these need to be compiled to object files # these need to be compiled to object files
obj_names.append (os.path.join (output_dir, obj_names.append (os.path.join (output_dir,
base + self.res_extension)) base + self.res_extension))
else: else:
obj_names.append (os.path.join (output_dir, obj_names.append (os.path.join (output_dir,
...@@ -216,7 +216,7 @@ class EMXCCompiler (UnixCCompiler): ...@@ -216,7 +216,7 @@ class EMXCCompiler (UnixCCompiler):
emx_dirs = os.environ['LIBRARY_PATH'].split(';') emx_dirs = os.environ['LIBRARY_PATH'].split(';')
except KeyError: except KeyError:
emx_dirs = [] emx_dirs = []
for dir in dirs + emx_dirs: for dir in dirs + emx_dirs:
shortlibp = os.path.join(dir, shortlib) shortlibp = os.path.join(dir, shortlib)
longlibp = os.path.join(dir, longlib) longlibp = os.path.join(dir, longlib)
...@@ -224,7 +224,7 @@ class EMXCCompiler (UnixCCompiler): ...@@ -224,7 +224,7 @@ class EMXCCompiler (UnixCCompiler):
return shortlibp return shortlibp
elif os.path.exists(longlibp): elif os.path.exists(longlibp):
return longlibp return longlibp
# Oops, didn't find it in *any* of 'dirs' # Oops, didn't find it in *any* of 'dirs'
return None return None
...@@ -266,15 +266,15 @@ def check_config_h(): ...@@ -266,15 +266,15 @@ def check_config_h():
# GCC, and the pyconfig.h file should be OK # GCC, and the pyconfig.h file should be OK
if string.find(sys.version,"GCC") >= 0: if string.find(sys.version,"GCC") >= 0:
return (CONFIG_H_OK, "sys.version mentions 'GCC'") return (CONFIG_H_OK, "sys.version mentions 'GCC'")
fn = sysconfig.get_config_h_filename() fn = sysconfig.get_config_h_filename()
try: try:
# It would probably better to read single lines to search. # It would probably better to read single lines to search.
# But we do this only once, and it is fast enough # But we do this only once, and it is fast enough
f = open(fn) f = open(fn)
s = f.read() s = f.read()
f.close() f.close()
except IOError, exc: except IOError, exc:
# if we can't read this file, we cannot say it is wrong # if we can't read this file, we cannot say it is wrong
# the compiler will complain later about this file as missing # the compiler will complain later about this file as missing
...@@ -296,7 +296,7 @@ def get_versions(): ...@@ -296,7 +296,7 @@ def get_versions():
from distutils.version import StrictVersion from distutils.version import StrictVersion
from distutils.spawn import find_executable from distutils.spawn import find_executable
import re import re
gcc_exe = find_executable('gcc') gcc_exe = find_executable('gcc')
if gcc_exe: if gcc_exe:
out = os.popen(gcc_exe + ' -dumpversion','r') out = os.popen(gcc_exe + ' -dumpversion','r')
...@@ -313,4 +313,3 @@ def get_versions(): ...@@ -313,4 +313,3 @@ def get_versions():
# anyway - so we can link OMF DLLs # anyway - so we can link OMF DLLs
ld_version = None ld_version = None
return (gcc_version, ld_version) return (gcc_version, ld_version)
...@@ -199,7 +199,7 @@ class RawPen: ...@@ -199,7 +199,7 @@ class RawPen:
if self._filling: if self._filling:
self._path.append(self._position) self._path.append(self._position)
self._draw_turtle() self._draw_turtle()
def heading(self): def heading(self):
return self._angle return self._angle
...@@ -209,13 +209,13 @@ class RawPen: ...@@ -209,13 +209,13 @@ class RawPen:
def window_width(self): def window_width(self):
width = self._canvas.winfo_width() width = self._canvas.winfo_width()
if width <= 1: # the window isn't managed by a geometry manager if width <= 1: # the window isn't managed by a geometry manager
width = self._canvas['width'] width = self._canvas['width']
return width return width
def window_height(self): def window_height(self):
height = self._canvas.winfo_height() height = self._canvas.winfo_height()
if height <= 1: # the window isn't managed by a geometry manager if height <= 1: # the window isn't managed by a geometry manager
height = self._canvas['height'] height = self._canvas['height']
return height return height
...@@ -254,7 +254,7 @@ class RawPen: ...@@ -254,7 +254,7 @@ class RawPen:
if self._filling: if self._filling:
self._path.append(self._position) self._path.append(self._position)
if self._drawing: if self._drawing:
if self._tracing: if self._tracing:
dx = float(x1 - x0) dx = float(x1 - x0)
dy = float(y1 - y0) dy = float(y1 - y0)
distance = hypot(dx, dy) distance = hypot(dx, dy)
......
...@@ -4,12 +4,12 @@ import cStringIO ...@@ -4,12 +4,12 @@ import cStringIO
msg = """Mime-Version: 1.0 msg = """Mime-Version: 1.0
Content-Type: multipart/mixed; Content-Type: multipart/mixed;
boundary="=====================_590453667==_" boundary="=====================_590453667==_"
X-OriginalArrivalTime: 05 Feb 2002 03:43:23.0310 (UTC) FILETIME=[42D88CE0:01C1ADF7] X-OriginalArrivalTime: 05 Feb 2002 03:43:23.0310 (UTC) FILETIME=[42D88CE0:01C1ADF7]
--=====================_590453667==_ --=====================_590453667==_
Content-Type: multipart/alternative; Content-Type: multipart/alternative;
boundary="=====================_590453677==_.ALT" boundary="=====================_590453677==_.ALT"
--=====================_590453677==_.ALT --=====================_590453677==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed Content-Type: text/plain; charset="us-ascii"; format=flowed
...@@ -49,8 +49,8 @@ def getMIMEMsg(mf): ...@@ -49,8 +49,8 @@ def getMIMEMsg(mf):
boundaries += 1 boundaries += 1
mf.push(boundary) mf.push(boundary)
while mf.next(): while mf.next():
getMIMEMsg(mf) getMIMEMsg(mf)
mf.pop() mf.pop()
else: else:
lines = mf.readlines() lines = mf.readlines()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment