From e40add41ccfb6560756051f79339286cd84180bb Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Mon, 7 Oct 2002 01:18:17 +0000 Subject: [PATCH] Whitespace normalization. --- Lib/ConfigParser.py | 2 +- Lib/StringIO.py | 10 +++++----- Lib/fileinput.py | 18 +++++++++--------- Lib/httplib.py | 4 ++-- Lib/smtplib.py | 4 ++-- Lib/tabnanny.py | 12 ++++++------ Lib/test/pickletester.py | 2 +- Lib/test/test_StringIO.py | 2 +- Lib/test/test_cfgparser.py | 2 +- Lib/test/test_generators.py | 2 +- Lib/test/test_httplib.py | 1 - Lib/test/test_multifile.py | 8 ++++---- Lib/test/test_netrc.py | 9 ++++----- Lib/test/test_string.py | 2 +- Lib/test/test_trace.py | 14 +++++++------- Lib/test/test_urlparse.py | 4 ++-- Lib/tokenize.py | 10 +++++----- Lib/urllib2.py | 2 +- 18 files changed, 53 insertions(+), 55 deletions(-) diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py index 76bc7f601daa..2cfa5d391687 100644 --- a/Lib/ConfigParser.py +++ b/Lib/ConfigParser.py @@ -282,7 +282,7 @@ class ConfigParser: def _interpolate(self, section, option, rawval, vars): # do the string interpolation value = rawval - depth = MAX_INTERPOLATION_DEPTH + depth = MAX_INTERPOLATION_DEPTH while depth: # Loop through this until it's done depth -= 1 if value.find("%(") != -1: diff --git a/Lib/StringIO.py b/Lib/StringIO.py index 1111f908fc57..8f816cdd346f 100644 --- a/Lib/StringIO.py +++ b/Lib/StringIO.py @@ -37,16 +37,16 @@ except ImportError: __all__ = ["StringIO"] class StringIO: - """class StringIO([buffer]) - + """class StringIO([buffer]) + When a StringIO object is created, it can be initialized to an existing string by passing the string to the constructor. If no string is given, - the StringIO will start empty. + the StringIO will start empty. The StringIO object can accept either Unicode or 8-bit strings, but mixing the two may take some care. If both are used, 8-bit strings that cannot be interpreted as 7-bit ASCII (that use the 8th bit) will cause - a UnicodeError to be raised when getvalue() is called. + a UnicodeError to be raised when getvalue() is called. """ def __init__(self, buf = ''): # Force self.buf to be a string or unicode @@ -185,7 +185,7 @@ class StringIO: but mixing the two may take some care. If both are used, 8-bit strings that cannot be interpreted as 7-bit ASCII (that use the 8th bit) will cause a UnicodeError to be raised when getvalue() - is called. + is called. """ if self.buflist: self.buf += ''.join(self.buflist) diff --git a/Lib/fileinput.py b/Lib/fileinput.py index bbd9781e7e6e..b3122617b335 100644 --- a/Lib/fileinput.py +++ b/Lib/fileinput.py @@ -94,7 +94,7 @@ def input(files=None, inplace=0, backup="", bufsize=0): Create an instance of the FileInput class. The instance will be used as global state for the functions of this module, and is also returned to use during iteration. The parameters to this function will be passed - along to the constructor of the FileInput class. + along to the constructor of the FileInput class. """ global _state if _state and _state._file: @@ -118,7 +118,7 @@ def nextfile(): changed until after the first line of the next file has been read. Before the first line has been read, this function has no effect; it cannot be used to skip the first file. After the last line of the - last file has been read, this function has no effect. + last file has been read, this function has no effect. """ if not _state: raise RuntimeError, "no active input()" @@ -127,7 +127,7 @@ def nextfile(): def filename(): """ Return the name of the file currently being read. - Before the first line has been read, returns None. + Before the first line has been read, returns None. """ if not _state: raise RuntimeError, "no active input()" @@ -137,7 +137,7 @@ def lineno(): """ Return the cumulative line number of the line that has just been read. Before the first line has been read, returns 0. After the last line - of the last file has been read, returns the line number of that line. + of the last file has been read, returns the line number of that line. """ if not _state: raise RuntimeError, "no active input()" @@ -147,7 +147,7 @@ def filelineno(): """ Return the line number in the current file. Before the first line has been read, returns 0. After the last line of the last file has - been read, returns the line number of that line within the file. + been read, returns the line number of that line within the file. """ if not _state: raise RuntimeError, "no active input()" @@ -156,7 +156,7 @@ def filelineno(): def isfirstline(): """ Returns true the line just read is the first line of its file, - otherwise returns false. + otherwise returns false. """ if not _state: raise RuntimeError, "no active input()" @@ -165,7 +165,7 @@ def isfirstline(): def isstdin(): """ Returns true if the last line was read from sys.stdin, - otherwise returns false. + otherwise returns false. """ if not _state: raise RuntimeError, "no active input()" @@ -173,14 +173,14 @@ def isstdin(): class FileInput: """class FileInput([files[, inplace[, backup]]]) - + Class FileInput is the implementation of the module; its methods filename(), lineno(), fileline(), isfirstline(), isstdin(), nextfile() and close() correspond to the functions of the same name in the module. In addition it has a readline() method which returns the next input line, and a __getitem__() method which implements the sequence behavior. The sequence must be accessed in strictly - sequential order; random access and readline() cannot be mixed. + sequential order; random access and readline() cannot be mixed. """ def __init__(self, files=None, inplace=0, backup="", bufsize=0): diff --git a/Lib/httplib.py b/Lib/httplib.py index e6dc898b2c70..077fb255dc3b 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -371,7 +371,7 @@ class HTTPResponse: if self.chunked: return self._read_chunked(amt) - + if amt is None: # unbounded read if self.will_close: @@ -441,7 +441,7 @@ class HTTPResponse: self.close() return value - + def _safe_read(self, amt): """Read the number of bytes requested, compensating for partial reads. diff --git a/Lib/smtplib.py b/Lib/smtplib.py index 1d0c1f5645c4..019228f18799 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -408,7 +408,7 @@ class SMTP: self.esmtp_features["auth"] = self.esmtp_features.get("auth", "") \ + " " + auth_match.groups(0)[0] continue - + # RFC 1869 requires a space between ehlo keyword and parameters. # It's actually stricter, in that only spaces are allowed between # parameters, but were not going to check for that here. Note @@ -524,7 +524,7 @@ class SMTP: def encode_plain(user, password): return encode_base64("%s\0%s\0%s" % (user, user, password), eol="") - + AUTH_PLAIN = "PLAIN" AUTH_CRAM_MD5 = "CRAM-MD5" diff --git a/Lib/tabnanny.py b/Lib/tabnanny.py index ce1c4a425cee..6de9070b1082 100755 --- a/Lib/tabnanny.py +++ b/Lib/tabnanny.py @@ -2,14 +2,14 @@ """The Tab Nanny despises ambiguous indentation. She knows no mercy. -tabnanny -- Detection of ambiguous indentation +tabnanny -- Detection of ambiguous indentation For the time being this module is intended to be called as a script. However it is possible to import it into an IDE and use the function -check() described below. +check() described below. Warning: The API provided by this module is likely to change in future -releases; such changes may not be backward compatible. +releases; such changes may not be backward compatible. """ # Released to the public domain, by Tim Peters, 15 April 1998. @@ -73,14 +73,14 @@ class NannyNag: def check(file): """check(file_or_dir) - + If file_or_dir is a directory and not a symbolic link, then recursively descend the directory tree named by file_or_dir, checking all .py files along the way. If file_or_dir is an ordinary Python source file, it is checked for whitespace related problems. The diagnostic messages are - written to standard output using the print statement. + written to standard output using the print statement. """ - + if os.path.isdir(file) and not os.path.islink(file): if verbose: print "%s: listing directory" % `file` diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index e16428fa33a7..2576e8fba3ad 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -253,7 +253,7 @@ class AbstractPickleTests(unittest.TestCase): t = time.localtime() s = self.dumps(t) u = self.loads(s) - self.assertEqual(t, u) + self.assertEqual(t, u) import os if hasattr(os, "stat"): t = os.stat(os.curdir) diff --git a/Lib/test/test_StringIO.py b/Lib/test/test_StringIO.py index 79d2e738d61d..888f9c166428 100644 --- a/Lib/test/test_StringIO.py +++ b/Lib/test/test_StringIO.py @@ -77,7 +77,7 @@ class TestStringIO(TestGenericStringIO): # The StringIO module also supports concatenating Unicode # snippets to larger Unicode strings. This is tested by this # method. Note that cStringIO does not support this extension. - + f = self.MODULE.StringIO() f.write(self._line[:6]) f.seek(3) diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py index 2c9587e06901..491c0318e7fb 100644 --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.py @@ -70,7 +70,7 @@ foo = another very foo = this line is much, much longer than my editor likes it. """) - + def case_sensitivity(): print "Testing case sensitivity..." cf = ConfigParser.ConfigParser() diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py index 410f043fd363..345bdc87b448 100644 --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -816,7 +816,7 @@ This one caused a crash (see SF bug 567538): ... continue ... finally: ... yield i -... +... >>> g = f() >>> print g.next() 0 diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 09f92fc46a9f..f70abec7ea54 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -56,4 +56,3 @@ r.begin() cookies = r.getheader("Set-Cookie") if cookies != hdr: raise AssertionError, "multiple headers not combined properly" - diff --git a/Lib/test/test_multifile.py b/Lib/test/test_multifile.py index 8f703477f346..6cb946f89926 100644 --- a/Lib/test/test_multifile.py +++ b/Lib/test/test_multifile.py @@ -4,12 +4,12 @@ import cStringIO msg = """Mime-Version: 1.0 Content-Type: multipart/mixed; - boundary="=====================_590453667==_" + boundary="=====================_590453667==_" X-OriginalArrivalTime: 05 Feb 2002 03:43:23.0310 (UTC) FILETIME=[42D88CE0:01C1ADF7] --=====================_590453667==_ Content-Type: multipart/alternative; - boundary="=====================_590453677==_.ALT" + boundary="=====================_590453677==_.ALT" --=====================_590453677==_.ALT Content-Type: text/plain; charset="us-ascii"; format=flowed @@ -49,8 +49,8 @@ def getMIMEMsg(mf): boundaries += 1 mf.push(boundary) - while mf.next(): - getMIMEMsg(mf) + while mf.next(): + getMIMEMsg(mf) mf.pop() else: lines = mf.readlines() diff --git a/Lib/test/test_netrc.py b/Lib/test/test_netrc.py index 5922fdc161cb..2cf1ae4dcec9 100644 --- a/Lib/test/test_netrc.py +++ b/Lib/test/test_netrc.py @@ -12,7 +12,7 @@ macdef macro2 line3 line4 -default login log2 password pass2 +default login log2 password pass2 """ @@ -25,7 +25,7 @@ class NetrcTestCase(unittest.TestCase): fp.write(TEST_NETRC) fp.close() self.netrc = netrc.netrc(temp_filename) - + def tearDown (self): del self.netrc os.unlink(temp_filename) @@ -36,8 +36,7 @@ class NetrcTestCase(unittest.TestCase): ) self.assert_(self.netrc.hosts['foo'] == ('log1', 'acct1', 'pass1')) self.assert_(self.netrc.hosts['default'] == ('log2', None, 'pass2')) - - + + if __name__ == "__main__": test_support.run_unittest(NetrcTestCase) - diff --git a/Lib/test/test_string.py b/Lib/test/test_string.py index 8f0ea47bd0a1..cc61512a73e3 100644 --- a/Lib/test/test_string.py +++ b/Lib/test/test_string.py @@ -38,7 +38,7 @@ def test(name, input, output, *args): value = apply(f, (input,) + args) if value is input: if verbose: - print 'no' + print 'no' print '*',f, `input`, `output`, `value` return if value != output: diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py index a0483ebce947..d61be828802c 100644 --- a/Lib/test/test_trace.py +++ b/Lib/test/test_trace.py @@ -119,7 +119,7 @@ def _settrace_and_return(tracefunc): sys._getframe().f_back.f_trace = tracefunc def settrace_and_return(tracefunc): _settrace_and_return(tracefunc) - + settrace_and_return.events = [(1, 'return')] def _settrace_and_raise(tracefunc): @@ -131,7 +131,7 @@ def settrace_and_raise(tracefunc): _settrace_and_raise(tracefunc) except RuntimeError, exc: pass - + settrace_and_raise.events = [(2, 'exception'), (3, 'line'), (4, 'line'), @@ -146,14 +146,14 @@ class Tracer: class TraceTestCase(unittest.TestCase): def compare_events(self, line_offset, events, expected_events): - events = [(l - line_offset, e) for (l, e) in events] + events = [(l - line_offset, e) for (l, e) in events] if events != expected_events: self.fail( "events did not match expectation:\n" + "\n".join(difflib.ndiff(map(str, expected_events), map(str, events)))) - - + + def run_test(self, func): tracer = Tracer() sys.settrace(tracer.trace) @@ -168,7 +168,7 @@ class TraceTestCase(unittest.TestCase): sys.settrace(None) self.compare_events(func.func_code.co_firstlineno, tracer.events, func.events) - + def test_1_basic(self): self.run_test(basic) def test_2_arigo(self): @@ -206,7 +206,7 @@ class RaisingTraceFuncTestCase(unittest.TestCase): self.fail("exception not thrown!") except RuntimeError: self.fail("recursion counter not reset") - + def test_main(): test_support.run_unittest(TraceTestCase) diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index b0a38b585c7e..7651afab85f7 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -12,8 +12,8 @@ for url, expected in [('http://www.python.org', ('http', 'www.python.org', '/', '', '', 'abc')), (RFC1808_BASE, ('http', 'a', '/b/c/d', 'p', 'q', 'f')), - ('file:///tmp/junk.txt', - ('file', '', '/tmp/junk.txt', '', '', '')), + ('file:///tmp/junk.txt', + ('file', '', '/tmp/junk.txt', '', '', '')), ]: result = urlparse.urlparse(url) print "%-13s = %r" % (url, result) diff --git a/Lib/tokenize.py b/Lib/tokenize.py index 160482a042a1..b64be8083202 100644 --- a/Lib/tokenize.py +++ b/Lib/tokenize.py @@ -125,14 +125,14 @@ def tokenize(readline, tokeneater=printtoken): """ The tokenize() function accepts two parameters: one representing the input stream, and one providing an output mechanism for tokenize(). - + The first parameter, readline, must be a callable object which provides the same interface as the readline() method of built-in file objects. - Each call to the function should return one line of input as a string. + Each call to the function should return one line of input as a string. The second parameter, tokeneater, must also be a callable object. It is called once for each token, with five arguments, corresponding to the - tuples generated by generate_tokens(). + tuples generated by generate_tokens(). """ try: tokenize_loop(readline, tokeneater) @@ -150,13 +150,13 @@ def generate_tokens(readline): must be a callable object which provides the same interface as the readline() method of built-in file objects. Each call to the function should return one line of input as a string. - + The generator produces 5-tuples with these members: the token type; the token string; a 2-tuple (srow, scol) of ints specifying the row and column where the token begins in the source; a 2-tuple (erow, ecol) of ints specifying the row and column where the token ends in the source; and the line on which the token was found. The line passed is the - logical line; continuation lines are included. + logical line; continuation lines are included. """ lnum = parenlev = continued = 0 namechars, numchars = string.ascii_letters + '_', '0123456789' diff --git a/Lib/urllib2.py b/Lib/urllib2.py index e9f2d52a9ed1..479bab91a659 100644 --- a/Lib/urllib2.py +++ b/Lib/urllib2.py @@ -458,7 +458,7 @@ class ProxyHandler(BaseHandler): user_pass, host = host.split('@', 1) if ':' in user_pass: user, password = user_pass.split(':', 1) - user_pass = base64.encodestring('%s:%s' % (unquote(user), + user_pass = base64.encodestring('%s:%s' % (unquote(user), unquote(password))) req.add_header('Proxy-Authorization', 'Basic ' + user_pass) host = unquote(host) -- 2.47.3