From 0eadaac7dc3ae49974c105ff9e8c1e98a04d7d5a Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Thu, 24 Apr 2003 16:02:54 +0000 Subject: Whitespace normalization. --- Lib/DocXMLRPCServer.py | 30 +++++++++++++++--------------- Lib/_strptime.py | 5 ++--- Lib/bsddb/__init__.py | 2 +- Lib/bsddb/dbobj.py | 1 - Lib/bsddb/dbshelve.py | 3 --- Lib/csv/__init__.py | 1 - Lib/csv/csv.py | 4 ++-- Lib/csv/util/sniffer.py | 29 +++++++++++++---------------- Lib/encodings/__init__.py | 1 - Lib/encodings/idna.py | 8 ++++---- Lib/encodings/punycode.py | 10 +++++----- Lib/markupbase.py | 8 ++++---- Lib/optparse.py | 1 - Lib/platform.py | 34 +++++++++++++++++----------------- Lib/sgmllib.py | 8 ++++---- Lib/shelve.py | 2 +- Lib/stringprep.py | 1 - Lib/test/string_tests.py | 1 - Lib/test/test_capi.py | 4 ++-- Lib/test/test_codecs.py | 4 ++-- Lib/test/test_csv.py | 24 ++++++++++++------------ Lib/test/test_getargs2.py | 2 +- Lib/test/test_gettext.py | 2 +- Lib/test/test_macfs.py | 2 +- Lib/test/test_pwd.py | 1 - Lib/test/test_scriptpackages.py | 18 +++++++++--------- Lib/test/test_shlex.py | 4 ++-- Lib/test/test_signal.py | 1 - Lib/test/test_stringprep.py | 2 -- Lib/test/test_time.py | 10 +++++----- Lib/test/test_unicode_file.py | 2 +- Lib/trace.py | 4 ++-- Lib/xml/dom/domreg.py | 4 ++-- Lib/xml/dom/pulldom.py | 2 +- Lib/xml/sax/handler.py | 2 +- Lib/xml/sax/saxutils.py | 2 +- Tools/scripts/db2pickle.py | 2 +- Tools/scripts/pickle2db.py | 2 +- Tools/scripts/trace.py | 28 ++++++++++++++-------------- 39 files changed, 127 insertions(+), 144 deletions(-) diff --git a/Lib/DocXMLRPCServer.py b/Lib/DocXMLRPCServer.py index adb8a93..55ec38e 100644 --- a/Lib/DocXMLRPCServer.py +++ b/Lib/DocXMLRPCServer.py @@ -22,7 +22,7 @@ from SimpleXMLRPCServer import SimpleXMLRPCServer,\ class ServerHTMLDoc(pydoc.HTMLDoc): """Class used to generate pydoc HTML document for a server""" - + def markup(self, text, escape=None, funcs={}, classes={}, methods={}): """Mark up some plain text, given a context of symbols to look for. Each context dictionary maps object names to anchor names.""" @@ -63,7 +63,7 @@ class ServerHTMLDoc(pydoc.HTMLDoc): here = end results.append(escape(text[here:])) return ''.join(results) - + def docroutine(self, object, name=None, mod=None, funcs={}, classes={}, methods={}, cl=None): """Produce HTML documentation for a function or method object.""" @@ -72,7 +72,7 @@ class ServerHTMLDoc(pydoc.HTMLDoc): note = '' title = '%s' % (anchor, name) - + if inspect.ismethod(object): args, varargs, varkw, defaults = inspect.getargspec(object.im_func) # exclude the argument bound to the instance, it will be @@ -96,7 +96,7 @@ class ServerHTMLDoc(pydoc.HTMLDoc): docstring = object[1] or "" else: docstring = pydoc.getdoc(object) - + decl = title + argspec + (note and self.grey( '%s' % note)) @@ -112,10 +112,10 @@ class ServerHTMLDoc(pydoc.HTMLDoc): for key, value in methods.items(): fdict[key] = '#-' + key fdict[value] = fdict[key] - - head = '%s' % server_name + + head = '%s' % server_name result = self.heading(head, '#ffffff', '#7799ee') - + doc = self.markup(package_documentation, self.preformat, fdict) doc = doc and '%s' % doc result = result + '

%s

\n' % doc @@ -136,7 +136,7 @@ class XMLRPCDocGenerator: This class is designed as mix-in and should not be constructed directly. """ - + def __init__(self): # setup variables used for HTML documentation self.server_name = 'XML-RPC Server Documentation' @@ -170,7 +170,7 @@ class XMLRPCDocGenerator: argument string used in the documentation and the _methodHelp(method_name) method to provide the help text used in the documentation.""" - + methods = {} for method_name in self.system_listMethods(): @@ -208,7 +208,7 @@ class XMLRPCDocGenerator: self.server_documentation, methods ) - + return documenter.page(self.server_title, documentation) class DocXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): @@ -227,7 +227,7 @@ class DocXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): Interpret all HTTP GET requests as requests for server documentation. """ - + response = self.server.generate_html_documentation() self.send_response(200) self.send_header("Content-type", "text/html") @@ -251,7 +251,7 @@ class DocXMLRPCServer( SimpleXMLRPCServer, logRequests=1): SimpleXMLRPCServer.__init__(self, addr, requestHandler, logRequests) XMLRPCDocGenerator.__init__(self) - + class DocCGIXMLRPCRequestHandler( CGIXMLRPCRequestHandler, XMLRPCDocGenerator): """Handler for XML-RPC data and documentation requests passed through @@ -281,8 +281,8 @@ if __name__ == '__main__': Converts an angle in degrees to an angle in radians""" import math - return deg * math.pi / 180 - + return deg * math.pi / 180 + server = DocXMLRPCServer(("localhost", 8000)) server.set_server_title("Math Server") @@ -299,4 +299,4 @@ You can use it from Python as follows: server.register_function(deg_to_rad) server.register_introspection_functions() - server.serve_forever() \ No newline at end of file + server.serve_forever() diff --git a/Lib/_strptime.py b/Lib/_strptime.py index 0777b7e..81c105f 100644 --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -374,10 +374,10 @@ class TimeRE(dict): def pattern(self, format): """Return re pattern for the format string. - + Need to make sure that any characters that might be interpreted as regex syntax is escaped. - + """ processed_format = '' # The sub() call escapes all characters that might be misconstrued @@ -528,4 +528,3 @@ def _insensitiveindex(lst, findme): return key else: raise ValueError("value not in list") - diff --git a/Lib/bsddb/__init__.py b/Lib/bsddb/__init__.py index e62d249..1ec6adc 100644 --- a/Lib/bsddb/__init__.py +++ b/Lib/bsddb/__init__.py @@ -43,7 +43,7 @@ except ImportError: import sys del sys.modules[__name__] raise - + # bsddb3 calls it db, but provide _db for backwards compatibility db = _db = _bsddb __version__ = db.__version__ diff --git a/Lib/bsddb/dbobj.py b/Lib/bsddb/dbobj.py index 889e554..b2632a1 100644 --- a/Lib/bsddb/dbobj.py +++ b/Lib/bsddb/dbobj.py @@ -192,4 +192,3 @@ class DB(DictMixin): if db.version() >= (4,1): def set_encrypt(self, *args, **kwargs): return apply(self._cobj.set_encrypt, args, kwargs) - diff --git a/Lib/bsddb/dbshelve.py b/Lib/bsddb/dbshelve.py index efaa003..fe4c4d1 100644 --- a/Lib/bsddb/dbshelve.py +++ b/Lib/bsddb/dbshelve.py @@ -296,6 +296,3 @@ class DBShelfCursor: #--------------------------------------------------------------------------- - - - diff --git a/Lib/csv/__init__.py b/Lib/csv/__init__.py index b1b973b..656b464 100644 --- a/Lib/csv/__init__.py +++ b/Lib/csv/__init__.py @@ -1,2 +1 @@ from csv import * - diff --git a/Lib/csv/csv.py b/Lib/csv/csv.py index a3ea4e2..36717cc 100644 --- a/Lib/csv/csv.py +++ b/Lib/csv/csv.py @@ -116,7 +116,7 @@ class DictWriter: self.restval = restval # for writing short dicts if extrasaction.lower() not in ("raise", "ignore"): raise ValueError, \ - ("extrasaction (%s) must be 'raise' or 'ignore'" % + ("extrasaction (%s) must be 'raise' or 'ignore'" % extrasaction) self.extrasaction = extrasaction self.writer = writer(f, dialect, *args) @@ -126,7 +126,7 @@ class DictWriter: for k in rowdict.keys(): if k not in self.fieldnames: raise ValueError, "dict contains fields not in fieldnames" - return [rowdict.get(key, self.restval) for key in self.fieldnames] + return [rowdict.get(key, self.restval) for key in self.fieldnames] def writerow(self, rowdict): return self.writer.writerow(self._dict_to_list(rowdict)) diff --git a/Lib/csv/util/sniffer.py b/Lib/csv/util/sniffer.py index 7b9b060..0fb2e1f 100644 --- a/Lib/csv/util/sniffer.py +++ b/Lib/csv/util/sniffer.py @@ -26,9 +26,9 @@ class Sniffer: """ Takes a file-like object and returns a dialect (or None) """ - + self.fileobj = fileobj - + data = fileobj.read(self.sample) quotechar, delimiter, skipinitialspace = self._guessQuoteAndDelimiter(data) @@ -51,11 +51,11 @@ class Sniffer: def hasHeaders(self): return self._hasHeaders(self.fileobj, self.dialect) - + def register_dialect(self, name = 'sniffed'): csv.register_dialect(name, self.dialect) - + def _guessQuoteAndDelimiter(self, data): """ @@ -78,7 +78,7 @@ class Sniffer: matches = regexp.findall(data) if matches: break - + if not matches: return ('', None, 0) # (quotechar, delimiter, skipinitialspace) @@ -117,7 +117,7 @@ class Sniffer: # there is *no* delimiter, it's a single column of quoted data delim = '' skipinitialspace = 0 - + return (quotechar, delim, skipinitialspace) @@ -132,14 +132,14 @@ class Sniffer: e.g. "x occurred 5 times in 10 rows, 6 times in 1000 rows, 7 times in 2 rows" 3) use the mode of the meta-frequency to determine the /expected/ - frequency for that character - 4) find out how often the character actually meets that goal - 5) the character that best meets its goal is the delimiter + frequency for that character + 4) find out how often the character actually meets that goal + 5) the character that best meets its goal is the delimiter For performance reasons, the data is evaluated in chunks, so it can try and evaluate the smallest portion of the data possible, evaluating - additional chunks as necessary. + additional chunks as necessary. """ - + data = filter(None, data.split('\n')) ascii = [chr(c) for c in range(127)] # 7-bit ASCII @@ -218,7 +218,7 @@ class Sniffer: # be a string in which case the length of the string is the determining factor: if # all of the rows except for the first are the same length, it's a header. # Finally, a 'vote' is taken at the end for each column, adding or subtracting from - # the likelihood of the first row being a header. + # the likelihood of the first row being a header. def seval(item): """ @@ -227,7 +227,7 @@ class Sniffer: return eval(item.replace('(', '').replace(')', '')) fileobj.seek(0) # rewind the fileobj - this might not work for some file-like objects... - + reader = csv.reader(fileobj, delimiter = dialect.delimiter, quotechar = dialect.quotechar, @@ -284,6 +284,3 @@ class Sniffer: hasHeader -= 1 return hasHeader > 0 - - - diff --git a/Lib/encodings/__init__.py b/Lib/encodings/__init__.py index a214190..66bea5c 100644 --- a/Lib/encodings/__init__.py +++ b/Lib/encodings/__init__.py @@ -120,4 +120,3 @@ def search_function(encoding): # Register the search_function in the Python codec registry codecs.register(search_function) - diff --git a/Lib/encodings/idna.py b/Lib/encodings/idna.py index 7e4d04e..62aa450 100644 --- a/Lib/encodings/idna.py +++ b/Lib/encodings/idna.py @@ -19,10 +19,10 @@ def nameprep(label): continue newlabel.append(stringprep.map_table_b2(c)) label = u"".join(newlabel) - + # Normalize label = unicodedata.normalize("NFKC", label) - + # Prohibit for c in label: if stringprep.in_table_c12(c) or \ @@ -139,7 +139,7 @@ def ToUnicode(label): # Step 8: return the result of step 5 return result - + ### Codec APIs class Codec(codecs.Codec): @@ -156,7 +156,7 @@ class Codec(codecs.Codec): return ".".join(result), len(input) def decode(self,input,errors='strict'): - + if errors != 'strict': raise UnicodeError, "Unsupported error handling "+errors diff --git a/Lib/encodings/punycode.py b/Lib/encodings/punycode.py index e7f2d45..82fd458 100644 --- a/Lib/encodings/punycode.py +++ b/Lib/encodings/punycode.py @@ -9,7 +9,7 @@ import codecs ##################### Encoding ##################################### def segregate(str): - """3.1 Basic code point segregation""" + """3.1 Basic code point segregation""" base = [] extended = {} for c in str: @@ -66,7 +66,7 @@ def insertion_unsort(str, extended): oldindex = index delta = 0 oldchar = char - + return result def T(j, bias): @@ -103,7 +103,7 @@ def adapt(delta, first, numchars): divisions += 36 bias = divisions + (36 * delta // (delta + 38)) return bias - + def generate_integers(baselen, deltas): """3.4 Bias adaptation""" @@ -155,7 +155,7 @@ def decode_generalized_number(extended, extpos, bias, errors): return extpos, result w = w * (36 - t) j += 1 - + def insertion_sort(base, extended, errors): """3.2 Insertion unsort coding""" @@ -193,7 +193,7 @@ def punycode_decode(text, errors): base = unicode(base, "ascii", errors) extended = extended.upper() return insertion_sort(base, extended, errors) - + ### Codec APIs class Codec(codecs.Codec): diff --git a/Lib/markupbase.py b/Lib/markupbase.py index f97cf10..62587e0 100644 --- a/Lib/markupbase.py +++ b/Lib/markupbase.py @@ -60,12 +60,12 @@ class ParserBase: # This is some sort of declaration; in "HTML as # deployed," this should only be the document type # declaration (""). - # ISO 8879:1986, however, has more complex + # ISO 8879:1986, however, has more complex # declaration syntax for elements in , including: # --comment-- # [marked section] - # name in the following list: ENTITY, DOCTYPE, ELEMENT, - # ATTLIST, NOTATION, SHORTREF, USEMAP, + # name in the following list: ENTITY, DOCTYPE, ELEMENT, + # ATTLIST, NOTATION, SHORTREF, USEMAP, # LINKTYPE, LINK, IDLINK, USELINK, SYSTEM rawdata = self.rawdata j = i + 2 @@ -151,7 +151,7 @@ class ParserBase: j = match.start(0) self.unknown_decl(rawdata[i+3: j]) return match.end(0) - + # Internal -- parse comment, return length or -1 if not terminated def parse_comment(self, i, report=1): rawdata = self.rawdata diff --git a/Lib/optparse.py b/Lib/optparse.py index eb1330e..991bcb6 100644 --- a/Lib/optparse.py +++ b/Lib/optparse.py @@ -1380,4 +1380,3 @@ def _match_abbrev (s, wordmap): # which will become a factory function when there are many Option # classes. make_option = Option - diff --git a/Lib/platform.py b/Lib/platform.py index d356fb1..8e3b47f 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -110,8 +110,8 @@ import sys,string,os,re _libc_search = re.compile(r'(__libc_init)' '|' - '(GLIBC_([0-9.]+))' - '|' + '(GLIBC_([0-9.]+))' + '|' '(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)') def libc_ver(executable=sys.executable,lib='',version='', @@ -126,7 +126,7 @@ def libc_ver(executable=sys.executable,lib='',version='', Note that the function has intimate knowledge of how different libc versions add symbols to the executable is probably only - useable for executables compiled using gcc. + useable for executables compiled using gcc. The file is read and scanned in chunks of chunksize bytes. @@ -164,7 +164,7 @@ def libc_ver(executable=sys.executable,lib='',version='', def _dist_try_harder(distname,version,id): - """ Tries some special tricks to get the distribution + """ Tries some special tricks to get the distribution information in case the default method fails. Currently supports older SuSE Linux, Caldera OpenLinux and @@ -376,7 +376,7 @@ def _syscmd_ver(system='',release='',version='', """ Tries to figure out the OS version used and returns a tuple (system,release,version). - + It uses the "ver" shell command for this which is known to exists on Windows, DOS and OS/2. XXX Others too ? @@ -501,7 +501,7 @@ def win32_ver(release='',version='',csd='',ptype=''): RegQueryValueEx(keyCurVer,'SystemRoot') except: return release,version,csd,ptype - + # Parse values #subversion = _win32_getvalue(keyCurVer, # 'SubVersionNumber', @@ -581,7 +581,7 @@ def mac_ver(release='',versioninfo=('','',''),machine=''): 0x80:'final'}.get(stage,'') versioninfo = (version,stage,nonrel) if sysa: - machine = {0x1: '68k', + machine = {0x1: '68k', 0x2: 'PowerPC'}.get(sysa,'') return release,versioninfo,machine @@ -594,7 +594,7 @@ def _java_getprop(self,name,default): return default def java_ver(release='',vendor='',vminfo=('','',''),osinfo=('','','')): - + """ Version interface for JPython. Returns a tuple (release,vendor,vminfo,osinfo) with vminfo being @@ -623,7 +623,7 @@ def java_ver(release='',vendor='',vminfo=('','',''),osinfo=('','','')): os_name = _java_getprop('java.os.name',os_name) os_version = _java_getprop('java.os.version',os_version) osinfo = os_name,os_version,os_arch - + return release,vendor,vminfo,osinfo ### System name aliasing @@ -843,14 +843,14 @@ def architecture(executable=sys.executable,bits='',linkage=''): # Older installations can only query longs size = struct.calcsize('l') bits = str(size*8) + 'bit' - + # Get data from the 'file' system command output = _syscmd_file(executable,'') if not output and \ executable == sys.executable: # "file" command did not return anything; we'll try to provide - # some sensible defaults then... + # some sensible defaults then... if _default_architecture.has_key(sys.platform): b,l = _default_architecture[sys.platform] if b: @@ -861,7 +861,7 @@ def architecture(executable=sys.executable,bits='',linkage=''): # Split the output into a list of strings omitting the filename fileout = _architecture_split(output)[1:] - + if 'executable' not in fileout: # Format not supported return bits,linkage @@ -895,7 +895,7 @@ def architecture(executable=sys.executable,bits='',linkage=''): return bits,linkage ### Portable uname() interface - + _uname_cache = None def uname(): @@ -934,7 +934,7 @@ def uname(): release,version,csd,ptype = win32_ver() if release and version: use_syscmd_ver = 0 - + # Try the 'ver' system command available on some # platforms if use_syscmd_ver: @@ -1140,7 +1140,7 @@ def platform(aliased=0, terse=0): """ Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). - + The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. @@ -1215,7 +1215,7 @@ def platform(aliased=0, terse=0): else: bits,linkage = architecture(sys.executable) platform = _platform(system,release,machine,processor,bits,linkage) - + if aliased: _platform_aliased_cache = platform elif terse: @@ -1228,7 +1228,7 @@ def platform(aliased=0, terse=0): if __name__ == '__main__': # Default is to print the aliased verbose platform string - terse = ('terse' in sys.argv or '--terse' in sys.argv) + terse = ('terse' in sys.argv or '--terse' in sys.argv) aliased = (not 'nonaliased' in sys.argv and not '--nonaliased' in sys.argv) print platform(aliased,terse) sys.exit(0) diff --git a/Lib/sgmllib.py b/Lib/sgmllib.py index b259328..4a8c3b4 100644 --- a/Lib/sgmllib.py +++ b/Lib/sgmllib.py @@ -144,10 +144,10 @@ class SGMLParser(markupbase.ParserBase): break continue if rawdata.startswith("