diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-01-14 21:54:20 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-01-14 21:54:20 (GMT) |
commit | 11cf605f840b17fb993ada5c14748d3b54d50568 (patch) | |
tree | 8e50b44ff283852388f0b11f6367ce7bcc056e0c /Lib | |
parent | f6922aa43536610bd54f5ef7af7f614dcf92bc04 (diff) | |
download | cpython-11cf605f840b17fb993ada5c14748d3b54d50568.zip cpython-11cf605f840b17fb993ada5c14748d3b54d50568.tar.gz cpython-11cf605f840b17fb993ada5c14748d3b54d50568.tar.bz2 |
Whitespace normalization.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/BaseHTTPServer.py | 48 | ||||
-rw-r--r-- | Lib/bdb.py | 88 | ||||
-rw-r--r-- | Lib/binhex.py | 60 |
3 files changed, 98 insertions, 98 deletions
diff --git a/Lib/BaseHTTPServer.py b/Lib/BaseHTTPServer.py index 49f8984..f075e58 100644 --- a/Lib/BaseHTTPServer.py +++ b/Lib/BaseHTTPServer.py @@ -32,31 +32,31 @@ XXX To do: # Log files # --------- -# +# # Here's a quote from the NCSA httpd docs about log file format. -# -# | The logfile format is as follows. Each line consists of: -# | -# | host rfc931 authuser [DD/Mon/YYYY:hh:mm:ss] "request" ddd bbbb -# | -# | host: Either the DNS name or the IP number of the remote client +# +# | The logfile format is as follows. Each line consists of: +# | +# | host rfc931 authuser [DD/Mon/YYYY:hh:mm:ss] "request" ddd bbbb +# | +# | host: Either the DNS name or the IP number of the remote client # | rfc931: Any information returned by identd for this person, -# | - otherwise. +# | - otherwise. # | authuser: If user sent a userid for authentication, the user name, -# | - otherwise. -# | DD: Day -# | Mon: Month (calendar name) -# | YYYY: Year -# | hh: hour (24-hour format, the machine's timezone) -# | mm: minutes -# | ss: seconds -# | request: The first line of the HTTP request as sent by the client. -# | ddd: the status code returned by the server, - if not available. +# | - otherwise. +# | DD: Day +# | Mon: Month (calendar name) +# | YYYY: Year +# | hh: hour (24-hour format, the machine's timezone) +# | mm: minutes +# | ss: seconds +# | request: The first line of the HTTP request as sent by the client. +# | ddd: the status code returned by the server, - if not available. # | bbbb: the total number of bytes sent, -# | *not including the HTTP/1.0 header*, - if not available -# | +# | *not including the HTTP/1.0 header*, - if not available +# | # | You can determine the name of the file accessed through request. -# +# # (Actually, the latter is only true if you know the server configuration # at the time the request was made!) @@ -429,13 +429,13 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler): 'Request accepted, processing continues off-line'), 203: ('Partial information', 'Request fulfilled from cache'), 204: ('No response', 'Request fulfilled, nothing follows'), - + 301: ('Moved', 'Object moved permanently -- see URI list'), 302: ('Found', 'Object moved temporarily -- see URI list'), 303: ('Method', 'Object moved -- see Method and URL list'), 304: ('Not modified', 'Document has not changed singe given time'), - + 400: ('Bad request', 'Bad request syntax or unsupported method'), 401: ('Unauthorized', @@ -445,7 +445,7 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler): 403: ('Forbidden', 'Request forbidden -- authorization will not help'), 404: ('Not found', 'Nothing matches the given URI'), - + 500: ('Internal error', 'Server got itself in trouble'), 501: ('Not implemented', 'Server does not support this operation'), @@ -453,7 +453,7 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler): 'The server cannot process the request due to a high load'), 503: ('Gateway timeout', 'The gateway server did not receive a timely response'), - + } @@ -8,7 +8,7 @@ BdbQuit = 'bdb.BdbQuit' # Exception to give up completely class Bdb: - + """Generic Python debugger base class. This class takes care of details of the trace facility; @@ -26,7 +26,7 @@ class Bdb: canonic = os.path.abspath(filename) self.fncache[filename] = canonic return canonic - + def reset(self): import linecache linecache.checkcache() @@ -34,7 +34,7 @@ class Bdb: self.stopframe = None self.returnframe = None self.quitting = 0 - + def trace_dispatch(self, frame, event, arg): if self.quitting: return # None @@ -48,13 +48,13 @@ class Bdb: return self.dispatch_exception(frame, arg) print 'bdb.Bdb.dispatch: unknown debugging event:', `event` return self.trace_dispatch - + def dispatch_line(self, frame): if self.stop_here(frame) or self.break_here(frame): self.user_line(frame) if self.quitting: raise BdbQuit return self.trace_dispatch - + def dispatch_call(self, frame, arg): # XXX 'arg' is no longer used if self.botframe is None: @@ -67,22 +67,22 @@ class Bdb: self.user_call(frame, arg) if self.quitting: raise BdbQuit return self.trace_dispatch - + def dispatch_return(self, frame, arg): if self.stop_here(frame) or frame == self.returnframe: self.user_return(frame, arg) if self.quitting: raise BdbQuit - + def dispatch_exception(self, frame, arg): if self.stop_here(frame): self.user_exception(frame, arg) if self.quitting: raise BdbQuit return self.trace_dispatch - + # Normally derived classes don't override the following # methods, but they may if they want to redefine the # definition of stopping and breakpoints. - + def stop_here(self, frame): if self.stopframe is None: return 1 @@ -110,53 +110,53 @@ class Bdb: return 1 else: return 0 - + def break_anywhere(self, frame): return self.breaks.has_key( self.canonic(frame.f_code.co_filename)) - + # Derived classes should override the user_* methods # to gain control. - + def user_call(self, frame, argument_list): """This method is called when there is the remote possibility that we ever need to stop in this function.""" pass - + def user_line(self, frame): """This method is called when we stop or break at this line.""" pass - + def user_return(self, frame, return_value): """This method is called when a return trap is set here.""" pass - + def user_exception(self, frame, (exc_type, exc_value, exc_traceback)): """This method is called if an exception occurs, but only if we are to stop at or just below this level.""" pass - + # Derived classes and clients can call the following methods # to affect the stepping state. - + def set_step(self): """Stop after one line of code.""" self.stopframe = None self.returnframe = None self.quitting = 0 - + def set_next(self, frame): """Stop on the next line in or below the given frame.""" self.stopframe = frame self.returnframe = None self.quitting = 0 - + def set_return(self, frame): """Stop when returning from the given frame.""" self.stopframe = frame.f_back self.returnframe = frame self.quitting = 0 - + def set_trace(self): """Start debugging from here.""" try: @@ -186,20 +186,20 @@ class Bdb: while frame and frame is not self.botframe: del frame.f_trace frame = frame.f_back - + def set_quit(self): self.stopframe = self.botframe self.returnframe = None self.quitting = 1 sys.settrace(None) - + # Derived classes and clients can call the following methods # to manipulate breakpoints. These methods return an # error message is something went wrong, None if all is well. # Set_break prints out the breakpoint line and file:lineno. # Call self.get_*break*() to see the breakpoints or better # for bp in Breakpoint.bpbynumber: if bp: bp.bpprint(). - + def set_break(self, filename, lineno, temporary=0, cond = None): filename = self.canonic(filename) import linecache # Import as late as possible @@ -229,7 +229,7 @@ class Bdb: self.breaks[filename].remove(lineno) if not self.breaks[filename]: del self.breaks[filename] - + def clear_bpbynumber(self, arg): try: number = int(arg) @@ -252,7 +252,7 @@ class Bdb: for bp in blist: bp.deleteMe() del self.breaks[filename] - + def clear_all_breaks(self): if not self.breaks: return 'There are no breakpoints' @@ -260,31 +260,31 @@ class Bdb: if bp: bp.deleteMe() self.breaks = {} - + def get_break(self, filename, lineno): filename = self.canonic(filename) return self.breaks.has_key(filename) and \ lineno in self.breaks[filename] - + def get_breaks(self, filename, lineno): filename = self.canonic(filename) return self.breaks.has_key(filename) and \ lineno in self.breaks[filename] and \ Breakpoint.bplist[filename, lineno] or [] - + def get_file_breaks(self, filename): filename = self.canonic(filename) if self.breaks.has_key(filename): return self.breaks[filename] else: return [] - + def get_all_breaks(self): return self.breaks - + # Derived classes and clients can call the following method # to get a data structure representing a stack trace. - + def get_stack(self, f, t): stack = [] if t and t.tb_frame is f: @@ -300,9 +300,9 @@ class Bdb: stack.append((t.tb_frame, t.tb_lineno)) t = t.tb_next return stack, i - - # - + + # + def format_stack_entry(self, frame_lineno, lprefix=': '): import linecache, repr, string frame, lineno = frame_lineno @@ -327,10 +327,10 @@ class Bdb: line = linecache.getline(filename, lineno) if line: s = s + lprefix + string.strip(line) return s - + # The following two methods can be called by clients to use # a debugger to debug a statement, given as a string. - + def run(self, cmd, globals=None, locals=None): if globals is None: import __main__ @@ -349,7 +349,7 @@ class Bdb: finally: self.quitting = 1 sys.settrace(None) - + def runeval(self, expr, globals=None, locals=None): if globals is None: import __main__ @@ -435,7 +435,7 @@ class Breakpoint: else: self.bplist[file, line] = [self] - + def deleteMe(self): index = (self.file, self.line) self.bpbynumber[self.number] = None # No longer in list @@ -452,13 +452,13 @@ class Breakpoint: def bpprint(self): if self.temporary: - disp = 'del ' + disp = 'del ' else: - disp = 'keep ' + disp = 'keep ' if self.enabled: - disp = disp + 'yes' + disp = disp + 'yes' else: - disp = disp + 'no ' + disp = disp + 'no ' print '%-4dbreakpoint %s at %s:%d' % (self.number, disp, self.file, self.line) if self.cond: @@ -506,7 +506,7 @@ def effective(file, line, frame): # condition evaluates to true. try: val = eval(b.cond, frame.f_globals, - frame.f_locals) + frame.f_locals) if val: if b.ignore > 0: b.ignore = b.ignore -1 @@ -518,7 +518,7 @@ def effective(file, line, frame): except: # if eval fails, most conservative # thing is to stop on breakpoint - # regardless of ignore count. + # regardless of ignore count. # Don't delete temporary, # as another hint to user. return (b,0) diff --git a/Lib/binhex.py b/Lib/binhex.py index fe695ac..ac2437b 100644 --- a/Lib/binhex.py +++ b/Lib/binhex.py @@ -26,7 +26,7 @@ import os import struct import string import binascii - + class Error(Exception): pass @@ -51,10 +51,10 @@ if os.name == 'mac': except AttributeError: # Backward compatibility openrf = open - + def FInfo(): return macfs.FInfo() - + def getfileinfo(name): finfo = macfs.FSSpec(name).GetFInfo() dir, file = os.path.split(name) @@ -66,7 +66,7 @@ if os.name == 'mac': fp.seek(0, 2) rlen = fp.tell() return file, finfo, dlen, rlen - + def openrsrc(name, *mode): if not mode: mode = '*rb' @@ -78,7 +78,7 @@ else: # # Glue code for non-macintosh usage # - + class FInfo: def __init__(self): self.Type = '????' @@ -106,19 +106,19 @@ else: class openrsrc: def __init__(self, *args): pass - + def read(self, *args): return '' - + def write(self, *args): pass - + def close(self): pass - + class _Hqxcoderengine: """Write data to the coder in 3-byte chunks""" - + def __init__(self, ofp): self.ofp = ofp self.data = '' @@ -253,12 +253,12 @@ class BinHex: self.ofp.close() self.state = None del self.ofp - + def binhex(inp, out): """(infilename, outfilename) - Create binhex-encoded copy of a file""" finfo = getfileinfo(inp) ofp = BinHex(finfo, out) - + ifp = open(inp, 'rb') # XXXX Do textfile translation on non-mac systems while 1: @@ -274,11 +274,11 @@ def binhex(inp, out): if not d: break ofp.write_rsrc(d) ofp.close() - ifp.close() + ifp.close() class _Hqxdecoderengine: """Read data via the decoder in 4-byte chunks""" - + def __init__(self, ifp): self.ifp = ifp self.eof = 0 @@ -288,7 +288,7 @@ class _Hqxdecoderengine: decdata = '' wtd = totalwtd # - # The loop here is convoluted, since we don't really now how + # The loop here is convoluted, since we don't really now how # much to decode: there may be newlines in the incoming data. while wtd > 0: if self.eof: return decdata @@ -343,7 +343,7 @@ class _Rledecoderengine: binascii.rledecode_hqx(self.pre_buffer) self.pre_buffer = '' return - + # # Obfuscated code ahead. We have to take care that we don't # end up with an orphaned RUNCHAR later on. So, we keep a couple @@ -393,17 +393,17 @@ class HexBin: break if ch != '\n': dummy = ifp.readline() - + hqxifp = _Hqxdecoderengine(ifp) self.ifp = _Rledecoderengine(hqxifp) self.crc = 0 self._readheader() - + def _read(self, len): data = self.ifp.read(len) self.crc = binascii.crc_hqx(data, self.crc) return data - + def _checkcrc(self): filecrc = struct.unpack('>h', self.ifp.read(2))[0] & 0xffff #self.crc = binascii.crc_hqx('\0\0', self.crc) @@ -419,21 +419,21 @@ class HexBin: fname = self._read(ord(len)) rest = self._read(1+4+4+2+4+4) self._checkcrc() - + type = rest[1:5] creator = rest[5:9] flags = struct.unpack('>h', rest[9:11])[0] self.dlen = struct.unpack('>l', rest[11:15])[0] self.rlen = struct.unpack('>l', rest[15:19])[0] - + self.FName = fname self.FInfo = FInfo() self.FInfo.Creator = creator self.FInfo.Type = type self.FInfo.Flags = flags - + self.state = _DID_HEADER - + def read(self, *n): if self.state != _DID_HEADER: raise Error, 'Read data at wrong time' @@ -447,7 +447,7 @@ class HexBin: rv = rv + self._read(n-len(rv)) self.dlen = self.dlen - n return rv - + def close_data(self): if self.state != _DID_HEADER: raise Error, 'close_data at wrong time' @@ -455,7 +455,7 @@ class HexBin: dummy = self._read(self.dlen) self._checkcrc() self.state = _DID_DATA - + def read_rsrc(self, *n): if self.state == _DID_HEADER: self.close_data() @@ -468,14 +468,14 @@ class HexBin: n = self.rlen self.rlen = self.rlen - n return self._read(n) - + def close(self): if self.rlen: dummy = self.read_rsrc(self.rlen) self._checkcrc() self.state = _DID_RSRC self.ifp.close() - + def hexbin(inp, out): """(infilename, outfilename) - Decode binhexed file""" ifp = HexBin(inp) @@ -494,7 +494,7 @@ def hexbin(inp, out): ofp.write(d) ofp.close() ifp.close_data() - + d = ifp.read_rsrc(128000) if d: ofp = openrsrc(out, 'wb') @@ -511,7 +511,7 @@ def hexbin(inp, out): nfinfo.Type = finfo.Type nfinfo.Flags = finfo.Flags ofss.SetFInfo(nfinfo) - + ifp.close() def _test(): @@ -526,6 +526,6 @@ def _test(): hexbin(fname+'.hqx', fname+'.viahqx') #hexbin(fname, fname+'.unpacked') sys.exit(1) - + if __name__ == '__main__': _test() |