Whitespace normalization.

This commit is contained in:
Tim Peters 2002-04-16 01:38:40 +00:00
parent c86c1b88f9
commit 863ac44b74
23 changed files with 84 additions and 88 deletions

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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 ''

View File

@ -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):

View File

@ -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.

View File

@ -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"]

View File

@ -18,4 +18,3 @@
from sre import *
from sre import __all__

View File

@ -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)

View File

@ -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 = {}

View File

@ -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)

View File

@ -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'),

View File

@ -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()

View File

@ -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 <mailman-admin@babylon.socal-raves.org>; 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 <mailman-admin@babylon.socal-raves.org>; 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 <mailman-admin@babylon.socal-raves.org>; 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 <mailman-admin@babylon.socal-raves.org>; 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 <mailman-admin@babylon.socal-raves.org>; 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 <mailman-admin@babylon.socal-raves.org>;
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 <mailman-admin@babylon.socal-raves.org>;
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 <mailman-admin@babylon.socal-raves.org>;
Sat, 2 Feb 2002 17:00:06 -0800 (PST)
by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
for <mailman-admin@babylon.socal-raves.org>;
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 <mailman-admin@babylon.socal-raves.org>;
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 <mailman-admin@babylon.socal-raves.org>;
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

View File

@ -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:

View File

@ -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'

View File

@ -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)

View File

@ -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)

View File

@ -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:

View File

@ -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'

View File

@ -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)

View File

@ -123,4 +123,3 @@ def test_main():
if __name__ == "__main__":
test_main()

View File

@ -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):