Kaydet (Commit) ff5364ac authored tarafından Fred Drake's avatar Fred Drake

Whitespace cleanup; now passes the regression test (the last checkin made

it fail on a TabError (inconsistent tab/space usage)).

Removed a comment about including a test since there is a regression test
for this module.
üst 103d5268
...@@ -309,7 +309,7 @@ _Translator = { ...@@ -309,7 +309,7 @@ _Translator = {
} }
def _quote(str, LegalChars=_LegalChars, def _quote(str, LegalChars=_LegalChars,
join=string.join, idmap=string._idmap, translate=string.translate): join=string.join, idmap=string._idmap, translate=string.translate):
# #
# If the string does not need to be double-quoted, # If the string does not need to be double-quoted,
# then just return the string. Otherwise, surround # then just return the string. Otherwise, surround
...@@ -317,9 +317,9 @@ def _quote(str, LegalChars=_LegalChars, ...@@ -317,9 +317,9 @@ def _quote(str, LegalChars=_LegalChars,
# special characters. # special characters.
# #
if "" == translate(str, idmap, LegalChars): if "" == translate(str, idmap, LegalChars):
return str return str
else: else:
return '"' + join( map(_Translator.get, str, str), "" ) + '"' return '"' + join( map(_Translator.get, str, str), "" ) + '"'
# end _quote # end _quote
...@@ -339,7 +339,7 @@ def _unquote(str, join=string.join, atoi=string.atoi): ...@@ -339,7 +339,7 @@ def _unquote(str, join=string.join, atoi=string.atoi):
# Remove the "s # Remove the "s
str = str[1:-1] str = str[1:-1]
# Check for special sequences. Examples: # Check for special sequences. Examples:
# \012 --> \n # \012 --> \n
# \" --> " # \" --> "
...@@ -421,7 +421,7 @@ class Morsel(UserDict): ...@@ -421,7 +421,7 @@ class Morsel(UserDict):
"version" : "Version", "version" : "Version",
} }
_reserved_keys = _reserved.keys() _reserved_keys = _reserved.keys()
def __init__(self): def __init__(self):
# Set defaults # Set defaults
self.key = self.value = self.coded_value = None self.key = self.value = self.coded_value = None
...@@ -440,7 +440,7 @@ class Morsel(UserDict): ...@@ -440,7 +440,7 @@ class Morsel(UserDict):
# end __setitem__ # end __setitem__
def isReservedKey(self, K): def isReservedKey(self, K):
return string.lower(K) in self._reserved_keys return string.lower(K) in self._reserved_keys
# end isReservedKey # end isReservedKey
def set(self, key, val, coded_val, def set(self, key, val, coded_val,
...@@ -467,7 +467,7 @@ class Morsel(UserDict): ...@@ -467,7 +467,7 @@ class Morsel(UserDict):
def __repr__(self): def __repr__(self):
return '<%s: %s=%s>' % (self.__class__.__name__, return '<%s: %s=%s>' % (self.__class__.__name__,
self.key, repr(self.value) ) self.key, repr(self.value) )
def js_output(self, attrs=None): def js_output(self, attrs=None):
# Print javascript # Print javascript
return """ return """
...@@ -484,7 +484,7 @@ class Morsel(UserDict): ...@@ -484,7 +484,7 @@ class Morsel(UserDict):
# #
result = [] result = []
RA = result.append RA = result.append
# First, the key=value pair # First, the key=value pair
RA("%s=%s;" % (self.key, self.coded_value)) RA("%s=%s;" % (self.key, self.coded_value))
...@@ -502,7 +502,7 @@ class Morsel(UserDict): ...@@ -502,7 +502,7 @@ class Morsel(UserDict):
RA("%s;" % self._reserved[K]) RA("%s;" % self._reserved[K])
else: else:
RA("%s=%s;" % (self._reserved[K], V)) RA("%s=%s;" % (self._reserved[K], V))
# Return the result # Return the result
return string.join(result, " ") return string.join(result, " ")
# end OutputString # end OutputString
...@@ -542,7 +542,7 @@ _CookiePattern = re.compile( ...@@ -542,7 +542,7 @@ _CookiePattern = re.compile(
class BaseCookie(UserDict): class BaseCookie(UserDict):
# A container class for a set of Morsels # A container class for a set of Morsels
# #
def value_decode(self, val): def value_decode(self, val):
"""real_value, coded_value = value_decode(STRING) """real_value, coded_value = value_decode(STRING)
Called prior to setting a cookie's value from the network Called prior to setting a cookie's value from the network
...@@ -562,7 +562,7 @@ class BaseCookie(UserDict): ...@@ -562,7 +562,7 @@ class BaseCookie(UserDict):
strval = str(val) strval = str(val)
return strval, strval return strval, strval
# end value_encode # end value_encode
def __init__(self, input=None): def __init__(self, input=None):
UserDict.__init__(self) UserDict.__init__(self)
if input: self.load(input) if input: self.load(input)
...@@ -596,7 +596,7 @@ class BaseCookie(UserDict): ...@@ -596,7 +596,7 @@ class BaseCookie(UserDict):
for K,V in self.items(): for K,V in self.items():
L.append( '%s=%s' % (K,repr(V.value) ) ) L.append( '%s=%s' % (K,repr(V.value) ) )
return '<%s: %s>' % (self.__class__.__name__, string.join(L)) return '<%s: %s>' % (self.__class__.__name__, string.join(L))
def js_output(self, attrs=None): def js_output(self, attrs=None):
"""Return a string suitable for JavaScript.""" """Return a string suitable for JavaScript."""
result = [] result = []
...@@ -617,7 +617,7 @@ class BaseCookie(UserDict): ...@@ -617,7 +617,7 @@ class BaseCookie(UserDict):
self.update(rawdata) self.update(rawdata)
return return
# end load() # end load()
def __ParseString(self, str, patt=_CookiePattern): def __ParseString(self, str, patt=_CookiePattern):
i = 0 # Our starting point i = 0 # Our starting point
n = len(str) # Length of string n = len(str) # Length of string
...@@ -645,8 +645,6 @@ class BaseCookie(UserDict): ...@@ -645,8 +645,6 @@ class BaseCookie(UserDict):
rval, cval = self.value_decode(V) rval, cval = self.value_decode(V)
self.__set(K, rval, cval) self.__set(K, rval, cval)
M = self[K] M = self[K]
return
# end __ParseString # end __ParseString
# end BaseCookie class # end BaseCookie class
...@@ -674,7 +672,7 @@ class SerialCookie(BaseCookie): ...@@ -674,7 +672,7 @@ class SerialCookie(BaseCookie):
Note: Large cookie values add overhead because they must be Note: Large cookie values add overhead because they must be
retransmitted on every HTTP transaction. retransmitted on every HTTP transaction.
Note: HTTP has a 2k limit on the size of a cookie. This class Note: HTTP has a 2k limit on the size of a cookie. This class
does not check for this limit, so be careful!!! does not check for this limit, so be careful!!!
""" """
...@@ -694,7 +692,7 @@ class SmartCookie(BaseCookie): ...@@ -694,7 +692,7 @@ class SmartCookie(BaseCookie):
Note: Large cookie values add overhead because they must be Note: Large cookie values add overhead because they must be
retransmitted on every HTTP transaction. retransmitted on every HTTP transaction.
Note: HTTP has a 2k limit on the size of a cookie. This class Note: HTTP has a 2k limit on the size of a cookie. This class
does not check for this limit, so be careful!!! does not check for this limit, so be careful!!!
""" """
...@@ -723,10 +721,6 @@ Cookie = SmartCookie ...@@ -723,10 +721,6 @@ Cookie = SmartCookie
#
# should add a test routine?
#
#Local Variables: #Local Variables:
#tab-width: 4 #tab-width: 4
#end: #end:
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