Kaydet (Commit) ab9ba27d authored tarafından Tim Peters's avatar Tim Peters

Whitespace normalization.

üst c7ca3ffb
...@@ -247,9 +247,9 @@ def parse_multipart(fp, pdict): ...@@ -247,9 +247,9 @@ def parse_multipart(fp, pdict):
if pdict.has_key('boundary'): if pdict.has_key('boundary'):
boundary = pdict['boundary'] boundary = pdict['boundary']
if not valid_boundary(boundary): if not valid_boundary(boundary):
raise ValueError, ('Invalid boundary in multipart form: %s' raise ValueError, ('Invalid boundary in multipart form: %s'
% `ib`) % `ib`)
nextpart = "--" + boundary nextpart = "--" + boundary
lastpart = "--" + boundary + "--" lastpart = "--" + boundary + "--"
partdict = {} partdict = {}
...@@ -600,7 +600,7 @@ class FieldStorage: ...@@ -600,7 +600,7 @@ class FieldStorage:
"""Internal: read a part that is itself multipart.""" """Internal: read a part that is itself multipart."""
ib = self.innerboundary ib = self.innerboundary
if not valid_boundary(ib): if not valid_boundary(ib):
raise ValueError, ('Invalid boundary in multipart form: %s' raise ValueError, ('Invalid boundary in multipart form: %s'
% `ib`) % `ib`)
self.list = [] self.list = []
klass = self.FieldStorageClass or self.__class__ klass = self.FieldStorageClass or self.__class__
......
...@@ -20,14 +20,14 @@ Interpreters constructed with this class obey the following conventions: ...@@ -20,14 +20,14 @@ Interpreters constructed with this class obey the following conventions:
arguments text, line, begidx, endidx. text is string we are matching arguments text, line, begidx, endidx. text is string we are matching
against, all returned matches must begin with it. line is the current against, all returned matches must begin with it. line is the current
input line (lstripped), begidx and endidx are the beginning and end input line (lstripped), begidx and endidx are the beginning and end
indexes of the text being matched, which could be used to provide indexes of the text being matched, which could be used to provide
different completion depending upon which position the argument is in. different completion depending upon which position the argument is in.
The `default' method may be overridden to intercept commands for which there The `default' method may be overridden to intercept commands for which there
is no do_ method. is no do_ method.
The `completedefault' method may be overridden to intercept completions for The `completedefault' method may be overridden to intercept completions for
commands that have no complete_ method. commands that have no complete_ method.
The data member `self.ruler' sets the character used to draw separator lines The data member `self.ruler' sets the character used to draw separator lines
in the help messages. If empty, no ruler line is drawn. It defaults to "=". in the help messages. If empty, no ruler line is drawn. It defaults to "=".
...@@ -66,7 +66,7 @@ class Cmd: ...@@ -66,7 +66,7 @@ class Cmd:
nohelp = "*** No help on %s" nohelp = "*** No help on %s"
use_rawinput = 1 use_rawinput = 1
def __init__(self, completekey='tab'): def __init__(self, completekey='tab'):
if completekey: if completekey:
try: try:
import readline import readline
...@@ -131,7 +131,7 @@ class Cmd: ...@@ -131,7 +131,7 @@ class Cmd:
while i < n and line[i] in self.identchars: i = i+1 while i < n and line[i] in self.identchars: i = i+1
cmd, arg = line[:i], line[i:].strip() cmd, arg = line[:i], line[i:].strip()
return cmd, arg, line return cmd, arg, line
def onecmd(self, line): def onecmd(self, line):
cmd, arg, line = self.parseline(line) cmd, arg, line = self.parseline(line)
if not line: if not line:
...@@ -191,7 +191,7 @@ class Cmd: ...@@ -191,7 +191,7 @@ class Cmd:
return self.completion_matches[state] return self.completion_matches[state]
except IndexError: except IndexError:
return None return None
def get_names(self): def get_names(self):
# Inheritance says we have to look in class and # Inheritance says we have to look in class and
# base classes; order is not important. # base classes; order is not important.
......
...@@ -277,7 +277,7 @@ class GzipFile: ...@@ -277,7 +277,7 @@ class GzipFile:
def rewind(self): def rewind(self):
'''Return the uncompressed stream file position indicator to the '''Return the uncompressed stream file position indicator to the
beginning of the file''' beginning of the file'''
if self.mode != READ: if self.mode != READ:
raise IOError("Can't rewind in write mode") raise IOError("Can't rewind in write mode")
self.fileobj.seek(0) self.fileobj.seek(0)
...@@ -291,7 +291,7 @@ class GzipFile: ...@@ -291,7 +291,7 @@ class GzipFile:
if offset < self.offset: if offset < self.offset:
raise IOError('Negative seek in write mode') raise IOError('Negative seek in write mode')
count = offset - self.offset count = offset - self.offset
for i in range(count/1024): for i in range(count/1024):
f.write(1024*'\0') f.write(1024*'\0')
self.write((count%1024)*'\0') self.write((count%1024)*'\0')
elif self.mode == READ: elif self.mode == READ:
......
...@@ -41,7 +41,7 @@ def check_all(modname): ...@@ -41,7 +41,7 @@ def check_all(modname):
# In case _socket fails to build, make this test fail more gracefully # In case _socket fails to build, make this test fail more gracefully
# than an AttributeError somewhere deep in CGIHTTPServer. # than an AttributeError somewhere deep in CGIHTTPServer.
import _socket import _socket
check_all("BaseHTTPServer") check_all("BaseHTTPServer")
check_all("CGIHTTPServer") check_all("CGIHTTPServer")
check_all("ConfigParser") check_all("ConfigParser")
......
...@@ -13,7 +13,7 @@ class CodeopTests(unittest.TestCase): ...@@ -13,7 +13,7 @@ class CodeopTests(unittest.TestCase):
'''succeed iff str is a valid piece of code''' '''succeed iff str is a valid piece of code'''
expected = compile(str, "<input>", symbol) expected = compile(str, "<input>", symbol)
self.assertEquals( compile_command(str, "<input>", symbol), expected) self.assertEquals( compile_command(str, "<input>", symbol), expected)
def assertIncomplete(self, str, symbol='single'): def assertIncomplete(self, str, symbol='single'):
'''succeed iff str is the start of a valid piece of code''' '''succeed iff str is the start of a valid piece of code'''
...@@ -41,13 +41,13 @@ class CodeopTests(unittest.TestCase): ...@@ -41,13 +41,13 @@ class CodeopTests(unittest.TestCase):
av("a=3\n\n") av("a=3\n\n")
# special case # special case
self.assertEquals(compile_command(""), self.assertEquals(compile_command(""),
compile("pass", "<input>", 'single')) compile("pass", "<input>", 'single'))
av("3**3","eval") av("3**3","eval")
av("(lambda z: \n z**3)","eval") av("(lambda z: \n z**3)","eval")
av("#a\n#b\na**3","eval") av("#a\n#b\na**3","eval")
def test_incomplete(self): def test_incomplete(self):
ai = self.assertIncomplete ai = self.assertIncomplete
ai("(a **") ai("(a **")
...@@ -59,7 +59,7 @@ class CodeopTests(unittest.TestCase): ...@@ -59,7 +59,7 @@ class CodeopTests(unittest.TestCase):
ai("if 9==3:\n pass\nelse:\n pass") ai("if 9==3:\n pass\nelse:\n pass")
ai("a = (") ai("a = (")
ai("a = 9+ \\") ai("a = 9+ \\")
ai("(","eval") ai("(","eval")
ai("(\n\n\n","eval") ai("(\n\n\n","eval")
ai("(9+","eval") ai("(9+","eval")
......
...@@ -107,4 +107,3 @@ class GlobTests(unittest.TestCase): ...@@ -107,4 +107,3 @@ class GlobTests(unittest.TestCase):
os.path.join('aab', 'F')])) os.path.join('aab', 'F')]))
run_unittest(GlobTests) run_unittest(GlobTests)
...@@ -71,7 +71,7 @@ f.close() ...@@ -71,7 +71,7 @@ f.close()
# Try seek, write test # Try seek, write test
f = gzip.GzipFile(filename, 'w') f = gzip.GzipFile(filename, 'w')
for pos in range(0, 256, 16): for pos in range(0, 256, 16):
f.seek(pos) f.seek(pos)
f.write('GZ\n') f.write('GZ\n')
f.close() f.close()
......
...@@ -43,7 +43,7 @@ def writeProfile(dict): ...@@ -43,7 +43,7 @@ def writeProfile(dict):
def writeContext(folder): def writeContext(folder):
folder = normF(folder) folder = normF(folder)
writeFile(os.path.join(_mhpath, "context"), writeFile(os.path.join(_mhpath, "context"),
"Current-Folder: %s\n" % folder) "Current-Folder: %s\n" % folder)
def writeCurMessage(folder, cur): def writeCurMessage(folder, cur):
...@@ -96,31 +96,31 @@ class MhlibTests(unittest.TestCase): ...@@ -96,31 +96,31 @@ class MhlibTests(unittest.TestCase):
def setUp(self): def setUp(self):
deltree(_mhroot) deltree(_mhroot)
mkdirs(_mhpath) mkdirs(_mhpath)
writeProfile({'Path' : os.path.abspath(_mhpath), writeProfile({'Path' : os.path.abspath(_mhpath),
'Editor': 'emacs', 'Editor': 'emacs',
'ignored-attribute': 'camping holiday'}) 'ignored-attribute': 'camping holiday'})
# Note: These headers aren't really conformant to RFC822, but # Note: These headers aren't really conformant to RFC822, but
# mhlib shouldn't care about that. # mhlib shouldn't care about that.
# An inbox with a couple of messages. # An inbox with a couple of messages.
writeMessage('inbox', 1, writeMessage('inbox', 1,
{'From': 'Mrs. Premise', {'From': 'Mrs. Premise',
'To': 'Mrs. Conclusion', 'To': 'Mrs. Conclusion',
'Date': '18 July 2001'}, "Hullo, Mrs. Conclusion!\n") 'Date': '18 July 2001'}, "Hullo, Mrs. Conclusion!\n")
writeMessage('inbox', 2, writeMessage('inbox', 2,
{'From': 'Mrs. Conclusion', {'From': 'Mrs. Conclusion',
'To': 'Mrs. Premise', 'To': 'Mrs. Premise',
'Date': '29 July 2001'}, "Hullo, Mrs. Premise!\n") 'Date': '29 July 2001'}, "Hullo, Mrs. Premise!\n")
# A folder with many messages # A folder with many messages
for i in range(5, 101)+range(101, 201, 2): for i in range(5, 101)+range(101, 201, 2):
writeMessage('wide', i, writeMessage('wide', i,
{'From': 'nowhere', 'Subject': 'message #%s' % i}, {'From': 'nowhere', 'Subject': 'message #%s' % i},
"This is message number %s\n" % i) "This is message number %s\n" % i)
# A deeply nested folder # A deeply nested folder
def deep(folder, n): def deep(folder, n):
writeMessage(folder, n, writeMessage(folder, n,
{'Subject': 'Message %s/%s' % (folder, n) }, {'Subject': 'Message %s/%s' % (folder, n) },
"This is message number %s in %s\n" % (n, folder) ) "This is message number %s in %s\n" % (n, folder) )
deep('deep/f1', 1) deep('deep/f1', 1)
...@@ -131,10 +131,10 @@ class MhlibTests(unittest.TestCase): ...@@ -131,10 +131,10 @@ class MhlibTests(unittest.TestCase):
deep('deep', 3) deep('deep', 3)
deep('deep/f2/f3', 1) deep('deep/f2/f3', 1)
deep('deep/f2/f3', 2) deep('deep/f2/f3', 2)
def tearDown(self): def tearDown(self):
deltree(_mhroot) deltree(_mhroot)
def test_basic(self): def test_basic(self):
writeContext('inbox') writeContext('inbox')
writeCurMessage('inbox', 2) writeCurMessage('inbox', 2)
...@@ -154,13 +154,13 @@ class MhlibTests(unittest.TestCase): ...@@ -154,13 +154,13 @@ class MhlibTests(unittest.TestCase):
mh.setcontext('inbox') mh.setcontext('inbox')
inbox = mh.openfolder('inbox') inbox = mh.openfolder('inbox')
eq(inbox.getfullname(), eq(inbox.getfullname(),
os.path.join(os.path.abspath(_mhpath), 'inbox')) os.path.join(os.path.abspath(_mhpath), 'inbox'))
eq(inbox.getsequencesfilename(), eq(inbox.getsequencesfilename(),
os.path.join(os.path.abspath(_mhpath), 'inbox', '.mh_sequences')) os.path.join(os.path.abspath(_mhpath), 'inbox', '.mh_sequences'))
eq(inbox.getmessagefilename(1), eq(inbox.getmessagefilename(1),
os.path.join(os.path.abspath(_mhpath), 'inbox', '1')) os.path.join(os.path.abspath(_mhpath), 'inbox', '1'))
def test_listfolders(self): def test_listfolders(self):
mh = getMH() mh = getMH()
eq = self.assertEquals eq = self.assertEquals
...@@ -168,7 +168,7 @@ class MhlibTests(unittest.TestCase): ...@@ -168,7 +168,7 @@ class MhlibTests(unittest.TestCase):
folders = mh.listfolders() folders = mh.listfolders()
folders.sort() folders.sort()
eq(folders, ['deep', 'inbox', 'wide']) eq(folders, ['deep', 'inbox', 'wide'])
folders = mh.listallfolders() folders = mh.listallfolders()
folders.sort() folders.sort()
eq(folders, map(normF, ['deep', 'deep/f1', 'deep/f2', 'deep/f2/f3', eq(folders, map(normF, ['deep', 'deep/f1', 'deep/f2', 'deep/f2/f3',
...@@ -177,7 +177,7 @@ class MhlibTests(unittest.TestCase): ...@@ -177,7 +177,7 @@ class MhlibTests(unittest.TestCase):
folders = mh.listsubfolders('deep') folders = mh.listsubfolders('deep')
folders.sort() folders.sort()
eq(folders, map(normF, ['deep/f1', 'deep/f2'])) eq(folders, map(normF, ['deep/f1', 'deep/f2']))
folders = mh.listallsubfolders('deep') folders = mh.listallsubfolders('deep')
folders.sort() folders.sort()
eq(folders, map(normF, ['deep/f1', 'deep/f2', 'deep/f2/f3'])) eq(folders, map(normF, ['deep/f1', 'deep/f2', 'deep/f2/f3']))
...@@ -190,22 +190,22 @@ class MhlibTests(unittest.TestCase): ...@@ -190,22 +190,22 @@ class MhlibTests(unittest.TestCase):
mh = getMH() mh = getMH()
eq = self.assertEquals eq = self.assertEquals
writeCurMessage('wide', 55) writeCurMessage('wide', 55)
f = mh.openfolder('wide') f = mh.openfolder('wide')
all = f.listmessages() all = f.listmessages()
eq(all, range(5, 101)+range(101, 201, 2)) eq(all, range(5, 101)+range(101, 201, 2))
eq(f.getcurrent(), 55) eq(f.getcurrent(), 55)
f.setcurrent(99) f.setcurrent(99)
eq(readFile(os.path.join(_mhpath, 'wide', '.mh_sequences')), eq(readFile(os.path.join(_mhpath, 'wide', '.mh_sequences')),
'cur: 99\n') 'cur: 99\n')
def seqeq(seq, val): def seqeq(seq, val):
eq(f.parsesequence(seq), val) eq(f.parsesequence(seq), val)
seqeq('5-55', range(5, 56)) seqeq('5-55', range(5, 56))
seqeq('90-108', range(90, 101)+range(101, 109, 2)) seqeq('90-108', range(90, 101)+range(101, 109, 2))
seqeq('90-108', range(90, 101)+range(101, 109, 2)) seqeq('90-108', range(90, 101)+range(101, 109, 2))
seqeq('10:10', range(10, 20)) seqeq('10:10', range(10, 20))
seqeq('10:+10', range(10, 20)) seqeq('10:+10', range(10, 20))
seqeq('101:10', range(101, 121, 2)) seqeq('101:10', range(101, 121, 2))
...@@ -249,7 +249,7 @@ class MhlibTests(unittest.TestCase): ...@@ -249,7 +249,7 @@ class MhlibTests(unittest.TestCase):
self.assert_("dummy1" in mh.listfolders()) self.assert_("dummy1" in mh.listfolders())
path = os.path.join(_mhpath, "dummy1") path = os.path.join(_mhpath, "dummy1")
self.assert_(os.path.exists(path)) self.assert_(os.path.exists(path))
f = mh.openfolder('dummy1') f = mh.openfolder('dummy1')
def create(n): def create(n):
msg = "From: foo\nSubject: %s\n\nDummy Message %s\n" % (n,n) msg = "From: foo\nSubject: %s\n\nDummy Message %s\n" % (n,n)
...@@ -258,14 +258,14 @@ class MhlibTests(unittest.TestCase): ...@@ -258,14 +258,14 @@ class MhlibTests(unittest.TestCase):
create(7) create(7)
create(8) create(8)
create(9) create(9)
eq(readFile(f.getmessagefilename(9)), eq(readFile(f.getmessagefilename(9)),
"From: foo\nSubject: 9\n\nDummy Message 9\n") "From: foo\nSubject: 9\n\nDummy Message 9\n")
eq(f.listmessages(), [7, 8, 9]) eq(f.listmessages(), [7, 8, 9])
files = os.listdir(path) files = os.listdir(path)
files.sort() files.sort()
eq(files, ['7', '8', '9']) eq(files, ['7', '8', '9'])
f.removemessages(['7', '8']) f.removemessages(['7', '8'])
files = os.listdir(path) files = os.listdir(path)
...@@ -275,7 +275,7 @@ class MhlibTests(unittest.TestCase): ...@@ -275,7 +275,7 @@ class MhlibTests(unittest.TestCase):
create(10) create(10)
create(11) create(11)
create(12) create(12)
mh.makefolder("dummy2") mh.makefolder("dummy2")
f2 = mh.openfolder("dummy2") f2 = mh.openfolder("dummy2")
eq(f2.listmessages(), []) eq(f2.listmessages(), [])
...@@ -285,12 +285,12 @@ class MhlibTests(unittest.TestCase): ...@@ -285,12 +285,12 @@ class MhlibTests(unittest.TestCase):
eq(f2.listmessages(), [3, 5]) eq(f2.listmessages(), [3, 5])
eq(readFile(f2.getmessagefilename(3)), eq(readFile(f2.getmessagefilename(3)),
"From: foo\nSubject: 10\n\nDummy Message 10\n") "From: foo\nSubject: 10\n\nDummy Message 10\n")
f.copymessage(9, f2, 4) f.copymessage(9, f2, 4)
eq(f.listmessages(), [9, 12]) eq(f.listmessages(), [9, 12])
eq(readFile(f2.getmessagefilename(4)), eq(readFile(f2.getmessagefilename(4)),
"From: foo\nSubject: 9\n\nDummy Message 9\n") "From: foo\nSubject: 9\n\nDummy Message 9\n")
f.refilemessages([9, 12], f2) f.refilemessages([9, 12], f2)
eq(f.listmessages(), []) eq(f.listmessages(), [])
eq(f2.listmessages(), [3, 4, 5, 6, 7]) eq(f2.listmessages(), [3, 4, 5, 6, 7])
...@@ -306,7 +306,7 @@ class MhlibTests(unittest.TestCase): ...@@ -306,7 +306,7 @@ class MhlibTests(unittest.TestCase):
def test_read(self): def test_read(self):
mh = getMH() mh = getMH()
eq = self.assertEquals eq = self.assertEquals
f = mh.openfolder('inbox') f = mh.openfolder('inbox')
msg = f.openmessage(1) msg = f.openmessage(1)
# Check some basic stuff from rfc822 # Check some basic stuff from rfc822
...@@ -316,15 +316,15 @@ class MhlibTests(unittest.TestCase): ...@@ -316,15 +316,15 @@ class MhlibTests(unittest.TestCase):
# Okay, we have the right message. Let's check the stuff from # Okay, we have the right message. Let's check the stuff from
# mhlib. # mhlib.
lines = sortLines(msg.getheadertext()) lines = sortLines(msg.getheadertext())
eq(lines, ["Date: 18 July 2001", eq(lines, ["Date: 18 July 2001",
"From: Mrs. Premise", "From: Mrs. Premise",
"To: Mrs. Conclusion"]) "To: Mrs. Conclusion"])
lines = sortLines(msg.getheadertext(lambda h: len(h)==4)) lines = sortLines(msg.getheadertext(lambda h: len(h)==4))
eq(lines, ["Date: 18 July 2001", eq(lines, ["Date: 18 July 2001",
"From: Mrs. Premise"]) "From: Mrs. Premise"])
eq(msg.getbodytext(), "Hullo, Mrs. Conclusion!\n\n") eq(msg.getbodytext(), "Hullo, Mrs. Conclusion!\n\n")
eq(msg.getbodytext(0), "Hullo, Mrs. Conclusion!\n\n") eq(msg.getbodytext(0), "Hullo, Mrs. Conclusion!\n\n")
# XXXX there should be a better way to reclaim the file handle # XXXX there should be a better way to reclaim the file handle
msg.fp.close() msg.fp.close()
del msg del msg
......
...@@ -43,7 +43,7 @@ class TestImport(unittest.TestCase): ...@@ -43,7 +43,7 @@ class TestImport(unittest.TestCase):
f = open(self.module_path, 'w') f = open(self.module_path, 'w')
f.write(contents) f.write(contents)
f.close() f.close()
def test_package_import__semantics(self): def test_package_import__semantics(self):
# Generate a couple of broken modules to try importing. # Generate a couple of broken modules to try importing.
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import unittest import unittest
from test_support import run_unittest from test_support import run_unittest
from repr import repr as r # Don't shadow builtin repr from repr import repr as r # Don't shadow builtin repr
def nestedTuple(nesting): def nestedTuple(nesting):
...@@ -24,7 +24,7 @@ class ReprTests(unittest.TestCase): ...@@ -24,7 +24,7 @@ class ReprTests(unittest.TestCase):
s = "a"*30+"b"*30 s = "a"*30+"b"*30
expected = `s`[:13] + "..." + `s`[-14:] expected = `s`[:13] + "..." + `s`[-14:]
eq(r(s), expected) eq(r(s), expected)
eq(r("\"'"), repr("\"'")) eq(r("\"'"), repr("\"'"))
s = "\""*30+"'"*100 s = "\""*30+"'"*100
expected = `s`[:13] + "..." + `s`[-14:] expected = `s`[:13] + "..." + `s`[-14:]
...@@ -67,7 +67,7 @@ class ReprTests(unittest.TestCase): ...@@ -67,7 +67,7 @@ class ReprTests(unittest.TestCase):
eq = self.assertEquals eq = self.assertEquals
i1 = ClassWithRepr("a") i1 = ClassWithRepr("a")
eq(r(i1), repr(i1)) eq(r(i1), repr(i1))
i2 = ClassWithRepr("x"*1000) i2 = ClassWithRepr("x"*1000)
expected = `i2`[:13] + "..." + `i2`[-14:] expected = `i2`[:13] + "..." + `i2`[-14:]
eq(r(i2), expected) eq(r(i2), expected)
......
...@@ -1353,9 +1353,9 @@ elif os.name == 'nt': ...@@ -1353,9 +1353,9 @@ elif os.name == 'nt':
# print proxyOverride # print proxyOverride
# now check if we match one of the registry values. # now check if we match one of the registry values.
for test in proxyOverride: for test in proxyOverride:
test = test.replace(".", r"\.") # mask dots test = test.replace(".", r"\.") # mask dots
test = test.replace("*", r".*") # change glob sequence test = test.replace("*", r".*") # change glob sequence
test = test.replace("?", r".") # change glob char test = test.replace("?", r".") # change glob char
for val in host: for val in host:
# print "%s <--> %s" %( test, val ) # print "%s <--> %s" %( test, val )
if re.match(test, val, re.I): if re.match(test, val, re.I):
......
...@@ -452,7 +452,7 @@ class HTTPRedirectHandler(BaseHandler): ...@@ -452,7 +452,7 @@ class HTTPRedirectHandler(BaseHandler):
new.error_302_dict[newurl] = newurl new.error_302_dict[newurl] = newurl
# Don't close the fp until we are sure that we won't use it # Don't close the fp until we are sure that we won't use it
# with HTTPError. # with HTTPError.
fp.read() fp.read()
fp.close() fp.close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment