From 863ac44b74cd66f7d289748816d65c65808c149b Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Tue, 16 Apr 2002 01:38:40 +0000 Subject: [PATCH] Whitespace normalization. --- Lib/BaseHTTPServer.py | 2 +- Lib/asynchat.py | 12 ++++---- Lib/fileinput.py | 2 +- Lib/gzip.py | 4 +-- Lib/imaplib.py | 2 +- Lib/os2emxpath.py | 2 +- Lib/pre.py | 2 +- Lib/re.py | 1 - Lib/rlcompleter.py | 4 +-- Lib/smtplib.py | 4 +-- Lib/test/pickletester.py | 2 +- Lib/test/string_tests.py | 2 +- Lib/test/test_cfgparser.py | 2 +- Lib/test/test_email.py | 52 +++++++++++++++++------------------ Lib/test/test_longexp.py | 6 ++-- Lib/test/test_mpz.py | 1 - Lib/test/test_netrc.py | 9 +++--- Lib/test/test_robotparser.py | 18 ++++++------ Lib/test/test_types.py | 2 +- Lib/test/test_unicode.py | 2 +- Lib/test/test_univnewlines.py | 30 ++++++++++---------- Lib/test/test_urlparse.py | 1 - Lib/warnings.py | 10 +++---- 23 files changed, 84 insertions(+), 88 deletions(-) diff --git a/Lib/BaseHTTPServer.py b/Lib/BaseHTTPServer.py index 35baf2f4acd..ab34e8fe8cb 100644 --- a/Lib/BaseHTTPServer.py +++ b/Lib/BaseHTTPServer.py @@ -32,7 +32,7 @@ XXX To do: # Network Working Group R. Fielding # Request for Comments: 2616 et al # Obsoletes: 2068 June 1999 -# Category: Standards Track +# Category: Standards Track # # URL: http://www.faqs.org/rfcs/rfc2616.html diff --git a/Lib/asynchat.py b/Lib/asynchat.py index 762070f6b9a..e1c97949b00 100644 --- a/Lib/asynchat.py +++ b/Lib/asynchat.py @@ -66,10 +66,10 @@ class async_chat (asyncore.dispatcher): def collect_incoming_data(self, data): raise NotImplementedError, "must be implemented in subclass" - + def found_terminator(self): raise NotImplementedError, "must be implemented in subclass" - + def set_terminator (self, term): "Set the input delimiter. Can be a fixed string of any length, an integer, or None" self.terminator = term @@ -291,7 +291,7 @@ class fifo: # regex: 14035/s def find_prefix_at_end (haystack, needle): - l = len(needle) - 1 - while l and not haystack.endswith(needle[:l]): - l -= 1 - return l + l = len(needle) - 1 + while l and not haystack.endswith(needle[:l]): + l -= 1 + return l diff --git a/Lib/fileinput.py b/Lib/fileinput.py index 77487edd706..2f17dc8892f 100644 --- a/Lib/fileinput.py +++ b/Lib/fileinput.py @@ -183,7 +183,7 @@ class FileInput: if not line: raise StopIteration return line - + def __getitem__(self, i): if i != self._lineno: raise RuntimeError, "accessing lines out of order" diff --git a/Lib/gzip.py b/Lib/gzip.py index 793a3b55989..b2bbeda3e88 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -136,7 +136,7 @@ class GzipFile: if self.mode != WRITE: import errno raise IOError(errno.EBADF, "write() on read-only GzipFile object") - + if self.fileobj is None: raise ValueError, "write() on closed GzipFile object" if len(data) > 0: @@ -149,7 +149,7 @@ class GzipFile: if self.mode != READ: import errno raise IOError(errno.EBADF, "write() on read-only GzipFile object") - + if self.extrasize <= 0 and self.fileobj is None: return '' diff --git a/Lib/imaplib.py b/Lib/imaplib.py index 266acb668d2..ef93f734bd0 100644 --- a/Lib/imaplib.py +++ b/Lib/imaplib.py @@ -1012,7 +1012,7 @@ class IMAP4_SSL(IMAP4): """ self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.connect((self.host, self.port)) - self.sslobj = socket.ssl(self.sock,self.keyfile, self.certfile) + self.sslobj = socket.ssl(self.sock,self.keyfile, self.certfile) def read(self, size): diff --git a/Lib/os2emxpath.py b/Lib/os2emxpath.py index 451fb0e9abd..55f599c4d06 100644 --- a/Lib/os2emxpath.py +++ b/Lib/os2emxpath.py @@ -1,5 +1,5 @@ # Module 'os2emxpath' -- common operations on OS/2 pathnames -"""Common pathname manipulations, OS/2 EMX version. +"""Common pathname manipulations, OS/2 EMX version. Instead of importing this module directly, import os and refer to this module as os.path. diff --git a/Lib/pre.py b/Lib/pre.py index 817f8de37ba..504c7c66858 100644 --- a/Lib/pre.py +++ b/Lib/pre.py @@ -92,7 +92,7 @@ from pcre import * import warnings as _warnings _warnings.warn("Please use the 're' module, not the 'pre' module", DeprecationWarning) - + __all__ = ["match","search","sub","subn","split","findall","escape","compile", "I","L","M","S","X","IGNORECASE","LOCALE","MULTILINE","DOTALL", "VERBOSE","error"] diff --git a/Lib/re.py b/Lib/re.py index 4fef1dc178d..a7865932128 100644 --- a/Lib/re.py +++ b/Lib/re.py @@ -18,4 +18,3 @@ from sre import * from sre import __all__ - diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py index 633fad00147..d8208f3b7aa 100644 --- a/Lib/rlcompleter.py +++ b/Lib/rlcompleter.py @@ -60,7 +60,7 @@ class Completer: readline.set_completer(Completer(my_namespace).complete) """ - + if namespace and not isinstance(namespace, dict): raise TypeError,'namespace must be a dictionary' @@ -82,7 +82,7 @@ class Completer: """ if self.use_main_ns: self.namespace = __main__.__dict__ - + if state == 0: if "." in text: self.matches = self.attr_matches(text) diff --git a/Lib/smtplib.py b/Lib/smtplib.py index 283616581fd..bb8fd75e8eb 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -227,8 +227,8 @@ class SMTP: connect. If specified, `port' specifies the port to which to connect. By default, smtplib.SMTP_PORT is used. An SMTPConnectError is raised if the specified `host' doesn't respond correctly. If specified, - `local_hostname` is used as the FQDN of the local host. By default, - the local hostname is found using socket.getfqdn(). + `local_hostname` is used as the FQDN of the local host. By default, + the local hostname is found using socket.getfqdn(). """ self.esmtp_features = {} diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index e16428fa33a..2576e8fba3a 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/string_tests.py b/Lib/test/string_tests.py index ea25983e76a..180072c2fca 100644 --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -239,7 +239,7 @@ def run_method_tests(test): test('zfill', '', '000', 3) test('zfill', '34', '34', 1) test('zfill', '34', '0034', 4) - + # Encoding/decoding codecs = [('rot13', 'uryyb jbeyq'), ('base64', 'aGVsbG8gd29ybGQ=\n'), diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py index 57e712579be..6a6fecbfbb3 100644 --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.py @@ -67,7 +67,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_email.py b/Lib/test/test_email.py index efbe271ba96..7b3f06363e4 100644 --- a/Lib/test/test_email.py +++ b/Lib/test/test_email.py @@ -313,7 +313,7 @@ class TestMessageAPI(TestEmailBase): msg.del_param("report-type") eq(msg.get_params(), [('multipart/report', ''), - ('boundary', 'D1690A7AC1.996856090/mail.example.com')]) + ('boundary', 'D1690A7AC1.996856090/mail.example.com')]) msg.set_param("report-type", old_val) eq(msg.get_params(), [('multipart/report', ''), @@ -331,7 +331,7 @@ class TestMessageAPI(TestEmailBase): msg.set_type('text/html') eq(msg['content-type'], 'text/html; charset="us-ascii"') - + # Test the email.Encoders module class TestEncoders(unittest.TestCase): @@ -409,7 +409,7 @@ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Foobar-Spoink-Defrobnit: wasnipoop; giraffes="very-long-necked-animals"; - spooge="yummy"; hippos="gargantuan"; marshmallows="gooey" + spooge="yummy"; hippos="gargantuan"; marshmallows="gooey" ''') @@ -450,22 +450,22 @@ Test""") msg = Message() msg['Received'] = """\ from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) - from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) - from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) + from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) + from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) """ self.assertEqual(msg.as_string(), """\ Received: from babylon.socal-raves.org (localhost [127.0.0.1]); - by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; - for ; - Sat, 2 Feb 2002 17:00:06 -0800 (PST) - from babylon.socal-raves.org (localhost [127.0.0.1]); - by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; - for ; - Sat, 2 Feb 2002 17:00:06 -0800 (PST) - from babylon.socal-raves.org (localhost [127.0.0.1]); - by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; - for ; - Sat, 2 Feb 2002 17:00:06 -0800 (PST) + by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; + for ; + Sat, 2 Feb 2002 17:00:06 -0800 (PST) + from babylon.socal-raves.org (localhost [127.0.0.1]); + by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; + for ; + Sat, 2 Feb 2002 17:00:06 -0800 (PST) + from babylon.socal-raves.org (localhost [127.0.0.1]); + by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; + for ; + Sat, 2 Feb 2002 17:00:06 -0800 (PST) """) @@ -721,7 +721,7 @@ From: bperson@dom.ain --BOUNDARY-- -''') +''') def test_one_part_in_a_multipart(self): outer = MIMEBase('multipart', 'mixed') @@ -748,7 +748,7 @@ Content-Transfer-Encoding: 7bit hello world --BOUNDARY-- -''') +''') def test_seq_parts_in_a_multipart(self): outer = MIMEBase('multipart', 'mixed') @@ -775,7 +775,7 @@ Content-Transfer-Encoding: 7bit hello world --BOUNDARY-- -''') +''') @@ -1163,11 +1163,11 @@ class TestMiscellaneous(unittest.TestCase): module = __import__('email') all = module.__all__ all.sort() - self.assertEqual(all, ['Charset', 'Encoders', 'Errors', 'Generator', - 'Header', 'Iterators', 'MIMEAudio', - 'MIMEBase', 'MIMEImage', 'MIMEMessage', + self.assertEqual(all, ['Charset', 'Encoders', 'Errors', 'Generator', + 'Header', 'Iterators', 'MIMEAudio', + 'MIMEBase', 'MIMEImage', 'MIMEMessage', 'MIMEText', 'Message', 'Parser', - 'Utils', 'base64MIME', + 'Utils', 'base64MIME', 'message_from_file', 'message_from_string', 'quopriMIME']) @@ -1313,7 +1313,7 @@ class TestParsers(unittest.TestCase): From: aperson@dom.ain To: bperson@dom.ain Subject: the next line has a space on it - + Date: Mon, 8 Apr 2002 15:09:19 -0400 Message-ID: spam @@ -1367,7 +1367,7 @@ eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r eHh4eCB4eHh4IA==\r """) - + def test_header_encode(self): eq = self.assertEqual he = base64MIME.header_encode @@ -1504,7 +1504,7 @@ two line"""), """\ one line two line""") - + # Test the Charset class diff --git a/Lib/test/test_longexp.py b/Lib/test/test_longexp.py index 00ece6d240f..b7842f99b65 100644 --- a/Lib/test/test_longexp.py +++ b/Lib/test/test_longexp.py @@ -6,9 +6,9 @@ from test_support import TestFailed, TestSkipped REPS = 65580 if sys.platform == 'mac': - import gestalt - if gestalt.gestalt('sysv') > 0x9ff: - raise TestSkipped, 'Triggers pathological malloc slowdown on OSX MacPython' + import gestalt + if gestalt.gestalt('sysv') > 0x9ff: + raise TestSkipped, 'Triggers pathological malloc slowdown on OSX MacPython' if sys.platform == "os2emx": raise TestFailed, "OS/2+EMX port has malloc problems with long expressions" else: diff --git a/Lib/test/test_mpz.py b/Lib/test/test_mpz.py index 2e57db47958..804dc6bc3dd 100644 --- a/Lib/test/test_mpz.py +++ b/Lib/test/test_mpz.py @@ -87,4 +87,3 @@ else: raise TestFailed, 'gcdext(10, 10.) should raise a TypeError' try: mpz.mpz(-10).binary() except ValueError: pass else: raise TestFailed, 'mpz(-10).binary() should raise a ValueError' - diff --git a/Lib/test/test_netrc.py b/Lib/test/test_netrc.py index 5922fdc161c..2cf1ae4dcec 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_robotparser.py b/Lib/test/test_robotparser.py index a0107250aab..beec0067894 100644 --- a/Lib/test/test_robotparser.py +++ b/Lib/test/test_robotparser.py @@ -30,14 +30,14 @@ tests = unittest.TestSuite() def RobotTest(index, robots_txt, good_urls, bad_urls, agent="test_robotparser"): - - lines = StringIO.StringIO(robots_txt).readlines() - parser = robotparser.RobotFileParser() - parser.parse(lines) - for url in good_urls: - tests.addTest(RobotTestCase(index, parser, url, 1, agent)) - for url in bad_urls: - tests.addTest(RobotTestCase(index, parser, url, 0, agent)) + + lines = StringIO.StringIO(robots_txt).readlines() + parser = robotparser.RobotFileParser() + parser.parse(lines) + for url in good_urls: + tests.addTest(RobotTestCase(index, parser, url, 1, agent)) + for url in bad_urls: + tests.addTest(RobotTestCase(index, parser, url, 0, agent)) # Examples from http://www.robotstxt.org/wc/norobots.html (fetched 2002) @@ -116,7 +116,7 @@ Disallow: /%7ejoe/index.html good = ['/tmp',] # XFAIL: '/a%2fb.html' bad = ['/tmp/','/tmp/a.html', '/a%3cd.html','/a%3Cd.html',"/a/b.html", - '/%7Ejoe/index.html'] + '/%7Ejoe/index.html'] RobotTest(6, doc, good, bad) diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index 9d4508b16a6..fc30e5b6b85 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -494,7 +494,7 @@ else: raise TestFailed, "{}.pop(k) doesn't raise KeyError when dictionary is emp d[1] = 1 try: for i in d: - d[i+1] = 1 + d[i+1] = 1 except RuntimeError: pass else: diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 29dd819bfac..c04d929e191 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -523,7 +523,7 @@ verify(u'\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f' u'\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c' u'\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067' u'\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das' - u' Nunstuck git und'.encode('utf-8') == + u' Nunstuck git und'.encode('utf-8') == '\xe6\xad\xa3\xe7\xa2\xba\xe3\x81\xab\xe8\xa8\x80\xe3\x81' '\x86\xe3\x81\xa8\xe7\xbf\xbb\xe8\xa8\xb3\xe3\x81\xaf\xe3' '\x81\x95\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x84\xe3\x81\xbe' diff --git a/Lib/test/test_univnewlines.py b/Lib/test/test_univnewlines.py index e77797af114..8d6a8740695 100644 --- a/Lib/test/test_univnewlines.py +++ b/Lib/test/test_univnewlines.py @@ -5,11 +5,11 @@ import os import sys DATA_TEMPLATE=[ - "line1=1", - "line2='this is a very long line designed to go past the magic " + - "hundred character limit that is inside fileobject.c and which " + - "is meant to speed up the common case, but we also want to test " + - "the uncommon case, naturally.'", + "line1=1", + "line2='this is a very long line designed to go past the magic " + + "hundred character limit that is inside fileobject.c and which " + + "is meant to speed up the common case, but we also want to test " + + "the uncommon case, naturally.'", "def line3():pass" ] DATA_LF = "\n".join(DATA_TEMPLATE) + "\n" @@ -40,13 +40,13 @@ class TestGenericUnivNewlines(unittest.TestCase): os.unlink(test_support.TESTFN) except: pass - + def test_read(self): fp = open(test_support.TESTFN, self.READMODE) data = fp.read() self.assertEqual(data, DATA_LF) self.assertEqual(`fp.newlines`, `self.NEWLINE`) - + def test_readlines(self): fp = open(test_support.TESTFN, self.READMODE) data = fp.readlines() @@ -62,7 +62,7 @@ class TestGenericUnivNewlines(unittest.TestCase): d = fp.readline() self.assertEqual(data, DATA_SPLIT) self.assertEqual(`fp.newlines`, `self.NEWLINE`) - + def test_seek(self): fp = open(test_support.TESTFN, self.READMODE) fp.readline() @@ -72,36 +72,36 @@ class TestGenericUnivNewlines(unittest.TestCase): fp.seek(pos) data = fp.readlines() self.assertEqual(data, DATA_SPLIT[1:]) - + def test_execfile(self): dict = {} execfile(test_support.TESTFN, dict) func = dict['line3'] self.assertEqual(func.func_code.co_firstlineno, 3) - + class TestNativeNewlines(TestGenericUnivNewlines): NEWLINE=None DATA=DATA_LF READMODE='r' WRITEMODE='w' - + class TestCRNewlines(TestGenericUnivNewlines): NEWLINE='\r' DATA=DATA_CR - + class TestLFNewlines(TestGenericUnivNewlines): NEWLINE='\n' DATA=DATA_LF - + class TestCRLFNewlines(TestGenericUnivNewlines): NEWLINE='\r\n' DATA=DATA_CRLF - + class TestMixedNewlines(TestGenericUnivNewlines): NEWLINE=('\r', '\n') DATA=DATA_MIXED - + def test_main(): test_support.run_unittest(TestNativeNewlines) diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index dbe0283a315..2b3cf6ce0f6 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -123,4 +123,3 @@ def test_main(): if __name__ == "__main__": test_main() - diff --git a/Lib/warnings.py b/Lib/warnings.py index 7966a33737c..c3c9ecaf8f8 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -13,7 +13,7 @@ def warn(message, category=None, stacklevel=1): """Issue a warning, or maybe ignore it or raise an exception.""" # Check if message is already a Warning object if isinstance(message, Warning): - category = message.__class__ + category = message.__class__ # Check category argument if category is None: category = UserWarning @@ -53,11 +53,11 @@ def warn_explicit(message, category, filename, lineno, if registry is None: registry = {} if isinstance(message, Warning): - text = str(message) - category = message.__class__ + text = str(message) + category = message.__class__ else: - text = message - message = category(message) + text = message + message = category(message) key = (text, category, lineno) # Quick test for common case if registry.get(key):