Fix flake8 issues

This commit is contained in:
Channel Cat 2016-10-25 01:36:12 -07:00
parent c50aa34dd9
commit 9c16f6dbea

View File

@ -18,6 +18,7 @@ _Translator.update({
ord('\\'): '\\\\', ord('\\'): '\\\\',
}) })
def _quote(str): def _quote(str):
r"""Quote a string for use in a cookie header. r"""Quote a string for use in a cookie header.
If the string does not need to be double-quoted, then just return the If the string does not need to be double-quoted, then just return the
@ -35,6 +36,7 @@ _is_legal_key = re.compile('[%s]+' % re.escape(_LegalChars)).fullmatch
# Custom SimpleCookie # Custom SimpleCookie
# ------------------------------------------------------------ # # ------------------------------------------------------------ #
class CookieJar(dict): class CookieJar(dict):
""" """
CookieJar dynamically writes headers as cookies are added and removed CookieJar dynamically writes headers as cookies are added and removed
@ -45,6 +47,7 @@ class CookieJar(dict):
super().__init__() super().__init__()
self.headers = headers self.headers = headers
self.cookie_headers = {} self.cookie_headers = {}
def __setitem__(self, key, value): def __setitem__(self, key, value):
# If this cookie doesn't exist, add it to the header keys # If this cookie doesn't exist, add it to the header keys
cookie_header = self.cookie_headers.get(key) cookie_header = self.cookie_headers.get(key)
@ -61,19 +64,20 @@ class CookieJar(dict):
del self.cookie_headers[key] del self.cookie_headers[key]
return super().__delitem__(key) return super().__delitem__(key)
class Cookie(dict): class Cookie(dict):
""" """
This is a stripped down version of Morsel from SimpleCookie #gottagofast This is a stripped down version of Morsel from SimpleCookie #gottagofast
""" """
_keys = { _keys = {
"expires" : "expires", "expires": "expires",
"path" : "Path", "path": "Path",
"comment" : "Comment", "comment": "Comment",
"domain" : "Domain", "domain": "Domain",
"max-age" : "Max-Age", "max-age": "Max-Age",
"secure" : "Secure", "secure": "Secure",
"httponly" : "HttpOnly", "httponly": "HttpOnly",
"version" : "Version", "version": "Version",
} }
_flags = {'secure', 'httponly'} _flags = {'secure', 'httponly'}
@ -87,7 +91,7 @@ class Cookie(dict):
super().__init__() super().__init__()
def __setitem__(self, key, value): def __setitem__(self, key, value):
if not key in self._keys: if key not in self._keys:
raise KeyError("Unknown cookie property") raise KeyError("Unknown cookie property")
return super().__setitem__(key, value) return super().__setitem__(key, value)
@ -112,6 +116,7 @@ class Cookie(dict):
# Header Trickery # Header Trickery
# ------------------------------------------------------------ # # ------------------------------------------------------------ #
class MultiHeader: class MultiHeader:
""" """
Allows us to set a header within response that has a unique key, Allows us to set a header within response that has a unique key,
@ -119,5 +124,6 @@ class MultiHeader:
""" """
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
def encode(self): def encode(self):
return self.name.encode() return self.name.encode()