Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e119006

Browse files
committed
Whitespace normalization. Top level of Lib now fixed-point for reindent.py!
1 parent b90f89a commit e119006

12 files changed

Lines changed: 432 additions & 432 deletions

File tree

Lib/UserString.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## vim:ts=4:et:nowrap
33
"""A user-defined wrapper around string objects
44
5-
Note: string objects have grown methods in Python 1.6
5+
Note: string objects have grown methods in Python 1.6
66
This module requires Python 1.6 or later.
77
"""
88
from types import StringType, UnicodeType
@@ -14,7 +14,7 @@ def __init__(self, seq):
1414
self.data = seq
1515
elif isinstance(seq, UserString):
1616
self.data = seq.data[:]
17-
else:
17+
else:
1818
self.data = str(seq)
1919
def __str__(self): return str(self.data)
2020
def __repr__(self): return repr(self.data)
@@ -76,15 +76,15 @@ def encode(self, encoding=None, errors=None): # XXX improve this?
7676
return self.__class__(self.data.encode(encoding, errors))
7777
else:
7878
return self.__class__(self.data.encode(encoding))
79-
else:
79+
else:
8080
return self.__class__(self.data.encode())
8181
def endswith(self, suffix, start=0, end=sys.maxint):
8282
return self.data.endswith(suffix, start, end)
83-
def expandtabs(self, tabsize=8):
83+
def expandtabs(self, tabsize=8):
8484
return self.__class__(self.data.expandtabs(tabsize))
85-
def find(self, sub, start=0, end=sys.maxint):
85+
def find(self, sub, start=0, end=sys.maxint):
8686
return self.data.find(sub, start, end)
87-
def index(self, sub, start=0, end=sys.maxint):
87+
def index(self, sub, start=0, end=sys.maxint):
8888
return self.data.index(sub, start, end)
8989
def isalpha(self): return self.data.isalpha()
9090
def isalnum(self): return self.data.isalnum()
@@ -99,23 +99,23 @@ def join(self, seq): return self.data.join(seq)
9999
def ljust(self, width): return self.__class__(self.data.ljust(width))
100100
def lower(self): return self.__class__(self.data.lower())
101101
def lstrip(self): return self.__class__(self.data.lstrip())
102-
def replace(self, old, new, maxsplit=-1):
102+
def replace(self, old, new, maxsplit=-1):
103103
return self.__class__(self.data.replace(old, new, maxsplit))
104-
def rfind(self, sub, start=0, end=sys.maxint):
104+
def rfind(self, sub, start=0, end=sys.maxint):
105105
return self.data.rfind(sub, start, end)
106-
def rindex(self, sub, start=0, end=sys.maxint):
106+
def rindex(self, sub, start=0, end=sys.maxint):
107107
return self.data.rindex(sub, start, end)
108108
def rjust(self, width): return self.__class__(self.data.rjust(width))
109109
def rstrip(self): return self.__class__(self.data.rstrip())
110-
def split(self, sep=None, maxsplit=-1):
110+
def split(self, sep=None, maxsplit=-1):
111111
return self.data.split(sep, maxsplit)
112112
def splitlines(self, keepends=0): return self.data.splitlines(keepends)
113-
def startswith(self, prefix, start=0, end=sys.maxint):
113+
def startswith(self, prefix, start=0, end=sys.maxint):
114114
return self.data.startswith(prefix, start, end)
115115
def strip(self): return self.__class__(self.data.strip())
116116
def swapcase(self): return self.__class__(self.data.swapcase())
117117
def title(self): return self.__class__(self.data.title())
118-
def translate(self, *args):
118+
def translate(self, *args):
119119
return self.__class__(self.data.translate(*args))
120120
def upper(self): return self.__class__(self.data.upper())
121121

@@ -136,7 +136,7 @@ class MutableString(UserString):
136136
A faster and better solution is to rewrite your program using lists."""
137137
def __init__(self, string=""):
138138
self.data = string
139-
def __hash__(self):
139+
def __hash__(self):
140140
raise TypeError, "unhashable type (it is mutable)"
141141
def __setitem__(self, index, sub):
142142
if index < 0 or index >= len(self.data): raise IndexError
@@ -157,7 +157,7 @@ def __delslice__(self, start, end):
157157
self.data = self.data[:start] + self.data[end:]
158158
def immutable(self):
159159
return UserString(self.data)
160-
160+
161161
if __name__ == "__main__":
162162
# execute the regression test to stdout, if called as a script:
163163
import os

Lib/urllib.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,11 @@ def http_error_401(self, url, fp, errcode, errmsg, headers, data=None):
551551
if match:
552552
scheme, realm = match.groups()
553553
if scheme.lower() == 'basic':
554-
name = 'retry_' + self.type + '_basic_auth'
555-
if data is None:
556-
return getattr(self,name)(url, realm)
557-
else:
558-
return getattr(self,name)(url, realm, data)
554+
name = 'retry_' + self.type + '_basic_auth'
555+
if data is None:
556+
return getattr(self,name)(url, realm)
557+
else:
558+
return getattr(self,name)(url, realm, data)
559559

560560
def retry_http_basic_auth(self, url, realm, data=None):
561561
host, selector = splithost(url)
@@ -571,14 +571,14 @@ def retry_http_basic_auth(self, url, realm, data=None):
571571
return self.open(newurl, data)
572572

573573
def retry_https_basic_auth(self, url, realm, data=None):
574-
host, selector = splithost(url)
575-
i = host.find('@') + 1
576-
host = host[i:]
577-
user, passwd = self.get_user_passwd(host, realm, i)
578-
if not (user or passwd): return None
579-
host = user + ':' + passwd + '@' + host
580-
newurl = '//' + host + selector
581-
return self.open_https(newurl)
574+
host, selector = splithost(url)
575+
i = host.find('@') + 1
576+
host = host[i:]
577+
user, passwd = self.get_user_passwd(host, realm, i)
578+
if not (user or passwd): return None
579+
host = user + ':' + passwd + '@' + host
580+
newurl = '//' + host + selector
581+
return self.open_https(newurl)
582582

583583
def get_user_passwd(self, host, realm, clear_cache = 0):
584584
key = realm + '@' + host.lower()

Lib/urllib2.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""An extensible library for opening URLs using a variety of protocols
22
33
The simplest way to use this module is to call the urlopen function,
4-
which accepts a string containing a URL or a Request object (described
4+
which accepts a string containing a URL or a Request object (described
55
below). It opens the URL and returns the results as file-like
66
object; the returned object has some extra methods described below.
77
88
The OpenerDirectory manages a collection of Handler objects that do
9-
all the actual work. Each Handler implements a particular protocol or
9+
all the actual work. Each Handler implements a particular protocol or
1010
option. The OpenerDirector is a composite object that invokes the
1111
Handlers needed to open the requested URL. For example, the
1212
HTTPHandler performs HTTP GET and POST requests and deals with
@@ -16,7 +16,7 @@
1616
1717
urlopen(url, data=None) -- basic usage is that same as original
1818
urllib. pass the url and optionally data to post to an HTTP URL, and
19-
get a file-like object back. One difference is that you can also pass
19+
get a file-like object back. One difference is that you can also pass
2020
a Request instance instead of URL. Raises a URLError (subclass of
2121
IOError); for HTTP errors, raises an HTTPError, which can also be
2222
treated as a valid response.
@@ -42,7 +42,7 @@
4242
URLError-- a subclass of IOError, individual protocols have their own
4343
specific subclass
4444
45-
HTTPError-- also a valid HTTP response, so you can treat an HTTP error
45+
HTTPError-- also a valid HTTP response, so you can treat an HTTP error
4646
as an exceptional event or valid response
4747
4848
internals:
@@ -57,7 +57,7 @@
5757
authinfo = urllib2.HTTPBasicAuthHandler()
5858
authinfo.add_password('realm', 'host', 'username', 'password')
5959
60-
# build a new opener that adds authentication and caching FTP handlers
60+
# build a new opener that adds authentication and caching FTP handlers
6161
opener = urllib2.build_opener(authinfo, urllib2.CacheFTPHandler)
6262
6363
# install it
@@ -73,7 +73,7 @@
7373
# authentication for some reason but fails, how should the error be
7474
# signalled? The client needs to know the HTTP error code. But if
7575
# the handler knows that the problem was, e.g., that it didn't know
76-
# that hash algo that requested in the challenge, it would be good to
76+
# that hash algo that requested in the challenge, it would be good to
7777
# pass that information along to the client, too.
7878

7979
# XXX to do:
@@ -141,7 +141,7 @@ def install_opener(opener):
141141
_opener = opener
142142

143143
# do these error classes make sense?
144-
# make sure all of the IOError stuff is overridden. we just want to be
144+
# make sure all of the IOError stuff is overridden. we just want to be
145145
# subtypes.
146146

147147
class URLError(IOError):
@@ -165,7 +165,7 @@ def __init__(self, url, code, msg, hdrs, fp):
165165
self.fp = fp
166166
# XXX
167167
self.filename = url
168-
168+
169169
def __str__(self):
170170
return 'HTTP Error %s: %s' % (self.code, self.msg)
171171

@@ -192,7 +192,7 @@ def __init__(self, url, data=None, headers={}):
192192

193193
def __getattr__(self, attr):
194194
# XXX this is a fallback mechanism to guard against these
195-
# methods getting called in a non-standard order. this may be
195+
# methods getting called in a non-standard order. this may be
196196
# too complicated and/or unnecessary.
197197
# XXX should the __r_XXX attributes be public?
198198
if attr[:12] == '_Request__r_':
@@ -259,7 +259,7 @@ def add_handler(self, handler):
259259
for meth in get_methods(handler):
260260
if meth[-5:] == '_open':
261261
protocol = meth[:-5]
262-
if self.handle_open.has_key(protocol):
262+
if self.handle_open.has_key(protocol):
263263
self.handle_open[protocol].append(handler)
264264
else:
265265
self.handle_open[protocol] = [handler]
@@ -285,7 +285,7 @@ def add_handler(self, handler):
285285
if added:
286286
self.handlers.append(handler)
287287
handler.add_parent(self)
288-
288+
289289
def __del__(self):
290290
self.close()
291291

@@ -314,9 +314,9 @@ def open(self, fullurl, data=None):
314314
if data is not None:
315315
req.add_data(data)
316316
assert isinstance(req, Request) # really only care about interface
317-
317+
318318
result = self._call_chain(self.handle_open, 'default',
319-
'default_open', req)
319+
'default_open', req)
320320
if result:
321321
return result
322322

@@ -381,7 +381,7 @@ def get_methods(inst):
381381
# XXX probably also want an abstract factory that knows things like
382382
# the fact that a ProxyHandler needs to get inserted first.
383383
# would also know when it makes sense to skip a superclass in favor of
384-
# a subclass and when it might make sense to include both
384+
# a subclass and when it might make sense to include both
385385

386386
def build_opener(*handlers):
387387
"""Create an opener object from a list of handlers.
@@ -393,7 +393,7 @@ def build_opener(*handlers):
393393
If any of the handlers passed as arguments are subclasses of the
394394
default handlers, the default handlers will not be used.
395395
"""
396-
396+
397397
opener = OpenerDirector()
398398
default_classes = [ProxyHandler, UnknownHandler, HTTPHandler,
399399
HTTPDefaultErrorHandler, HTTPRedirectHandler,
@@ -472,7 +472,7 @@ def __init__(self, proxies=None):
472472
assert hasattr(proxies, 'has_key'), "proxies must be a mapping"
473473
self.proxies = proxies
474474
for type, url in proxies.items():
475-
setattr(self, '%s_open' % type,
475+
setattr(self, '%s_open' % type,
476476
lambda r, proxy=url, type=type, meth=self.proxy_open: \
477477
meth(r, proxy, type))
478478

@@ -574,7 +574,7 @@ def is_suburi(self, base, test):
574574
if len(common) == len(base[1]):
575575
return 1
576576
return 0
577-
577+
578578

579579
class HTTPBasicAuthHandler(BaseHandler):
580580
rx = re.compile('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"')
@@ -590,8 +590,8 @@ def __init__(self):
590590
# if __current_realm is not None, then the server must have
591591
# refused our name/password and is asking for authorization
592592
# again. must be careful to set it to None on successful
593-
# return.
594-
593+
# return.
594+
595595
def http_error_401(self, req, fp, code, msg, headers):
596596
# XXX could be mult. headers
597597
authreq = headers.get('www-authenticate', None)
@@ -674,7 +674,7 @@ def get_authorization(self, req, chal):
674674
return None
675675

676676
user, pw = self.passwd.find_user_password(realm,
677-
req.get_full_url())
677+
req.get_full_url())
678678
if user is None:
679679
return None
680680

@@ -724,8 +724,8 @@ def encode_digest(digest):
724724
n = ord(c) & 0xf
725725
hexrep.append(hex(n)[-1])
726726
return string.join(hexrep, '')
727-
728-
727+
728+
729729
class HTTPHandler(BaseHandler):
730730
def http_open(self, req):
731731
# XXX devise a new mechanism to specify user/password
@@ -745,7 +745,7 @@ def http_open(self, req):
745745
h.putrequest('GET', req.get_selector())
746746
except socket.error, err:
747747
raise URLError(err)
748-
748+
749749
# XXX proxies would have different host here
750750
h.putheader('Host', host)
751751
for args in self.parent.addheaders:
@@ -813,7 +813,7 @@ def parse_http_list(s):
813813
start = i
814814
inquote = 0
815815
else:
816-
i = i + q
816+
i = i + q
817817
else:
818818
if c < q:
819819
list.append(s[start:i+c])
@@ -838,7 +838,7 @@ def file_open(self, req):
838838
names = None
839839
def get_names(self):
840840
if FileHandler.names is None:
841-
FileHandler.names = (socket.gethostbyname('localhost'),
841+
FileHandler.names = (socket.gethostbyname('localhost'),
842842
socket.gethostbyname(socket.gethostname()))
843843
return FileHandler.names
844844

@@ -967,7 +967,7 @@ def gopher_open(self, req):
967967
class OpenerFactory:
968968

969969
default_handlers = [UnknownHandler, HTTPHandler,
970-
HTTPDefaultErrorHandler, HTTPRedirectHandler,
970+
HTTPDefaultErrorHandler, HTTPRedirectHandler,
971971
FTPHandler, FileHandler]
972972
proxy_handlers = [ProxyHandler]
973973
handlers = []
@@ -990,7 +990,7 @@ def build_opener(self):
990990
opener.add_handler(ph)
991991

992992
if __name__ == "__main__":
993-
# XXX some of the test code depends on machine configurations that
993+
# XXX some of the test code depends on machine configurations that
994994
# are internal to CNRI. Need to set up a public server with the
995995
# right authentication configuration for test purposes.
996996
if socket.gethostname() == 'bitdiddle':
@@ -1030,11 +1030,11 @@ def build_opener(self):
10301030

10311031
bauth = HTTPBasicAuthHandler()
10321032
bauth.add_password('basic_test_realm', localhost, 'jhylton',
1033-
'password')
1033+
'password')
10341034
dauth = HTTPDigestAuthHandler()
1035-
dauth.add_password('digest_test_realm', localhost, 'jhylton',
1035+
dauth.add_password('digest_test_realm', localhost, 'jhylton',
10361036
'password')
1037-
1037+
10381038

10391039
cfh = CacheFTPHandler()
10401040
cfh.setTimeout(1)

0 commit comments

Comments
 (0)