Skip to content

Commit

Permalink
Use double quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed Feb 10, 2024
1 parent 63142bf commit 8be3216
Show file tree
Hide file tree
Showing 6 changed files with 482 additions and 484 deletions.
20 changes: 10 additions & 10 deletions multipart/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# This is the canonical package information.
__author__ = 'Andrew Dunham'
__license__ = 'Apache'
__copyright__ = 'Copyright (c) 2012-2013, Andrew Dunham'
__version__ = '0.0.8'
__author__ = "Andrew Dunham"
__license__ = "Apache"
__copyright__ = "Copyright (c) 2012-2013, Andrew Dunham"
__version__ = "0.0.8"

from .multipart import FormParser, MultipartParser, OctetStreamParser, QuerystringParser, create_form_parser, parse_form

__all__ = (
'FormParser',
'MultipartParser',
'OctetStreamParser',
'QuerystringParser',
'create_form_parser',
'parse_form',
"FormParser",
"MultipartParser",
"OctetStreamParser",
"QuerystringParser",
"create_form_parser",
"parse_form",
)
26 changes: 13 additions & 13 deletions multipart/decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def write(self, data):
try:
decoded = base64.b64decode(val)
except binascii.Error:
raise DecodeError('There was an error raised while decoding ' 'base64-encoded data.')
raise DecodeError("There was an error raised while decoding " "base64-encoded data.")

self.underlying.write(decoded)

Expand All @@ -68,7 +68,7 @@ def write(self, data):
if remaining_len > 0:
self.cache = data[-remaining_len:]
else:
self.cache = b''
self.cache = b""

# Return the length of the data to indicate no error.
return len(data)
Expand All @@ -77,7 +77,7 @@ def close(self):
"""Close this decoder. If the underlying object has a `close()`
method, this function will call it.
"""
if hasattr(self.underlying, 'close'):
if hasattr(self.underlying, "close"):
self.underlying.close()

def finalize(self):
Expand All @@ -91,14 +91,14 @@ def finalize(self):
"""
if len(self.cache) > 0:
raise DecodeError(
'There are %d bytes remaining in the ' 'Base64Decoder cache when finalize() is called' % len(self.cache)
"There are %d bytes remaining in the " "Base64Decoder cache when finalize() is called" % len(self.cache)
)

if hasattr(self.underlying, 'finalize'):
if hasattr(self.underlying, "finalize"):
self.underlying.finalize()

def __repr__(self):
return f'{self.__class__.__name__}(underlying={self.underlying!r})'
return f"{self.__class__.__name__}(underlying={self.underlying!r})"


class QuotedPrintableDecoder:
Expand All @@ -112,7 +112,7 @@ class QuotedPrintableDecoder:
"""

def __init__(self, underlying):
self.cache = b''
self.cache = b""
self.underlying = underlying

def write(self, data):
Expand All @@ -128,11 +128,11 @@ def write(self, data):
# If the last 2 characters have an '=' sign in it, then we won't be
# able to decode the encoded value and we'll need to save it for the
# next decoding step.
if data[-2:].find(b'=') != -1:
if data[-2:].find(b"=") != -1:
enc, rest = data[:-2], data[-2:]
else:
enc = data
rest = b''
rest = b""

# Encode and write, if we have data.
if len(enc) > 0:
Expand All @@ -146,7 +146,7 @@ def close(self):
"""Close this decoder. If the underlying object has a `close()`
method, this function will call it.
"""
if hasattr(self.underlying, 'close'):
if hasattr(self.underlying, "close"):
self.underlying.close()

def finalize(self):
Expand All @@ -161,11 +161,11 @@ def finalize(self):
# If we have a cache, write and then remove it.
if len(self.cache) > 0:
self.underlying.write(binascii.a2b_qp(self.cache))
self.cache = b''
self.cache = b""

# Finalize our underlying stream.
if hasattr(self.underlying, 'finalize'):
if hasattr(self.underlying, "finalize"):
self.underlying.finalize()

def __repr__(self):
return f'{self.__class__.__name__}(underlying={self.underlying!r})'
return f"{self.__class__.__name__}(underlying={self.underlying!r})"
Loading

0 comments on commit 8be3216

Please sign in to comment.