apply autoformat
parent
3105277cfe
commit
63a267f628
|
@ -1,9 +1,9 @@
|
|||
# pylint: disable=invalid-name
|
||||
"""Sphinx configuration."""
|
||||
from datetime import datetime
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
VERSION_RE = re.compile(r"""__version__ = ['"]([0-9.]+)['"]""")
|
||||
HERE = os.path.abspath(os.path.dirname(__file__))
|
||||
|
|
|
@ -227,7 +227,7 @@ class Base64IO(io.IOBase):
|
|||
return data
|
||||
|
||||
_data_buffer = io.BytesIO() if isinstance(data, bytes) else io.StringIO()
|
||||
join_char = b'' if isinstance(data, bytes) else u''
|
||||
join_char = b"" if isinstance(data, bytes) else u""
|
||||
_data_buffer.write(join_char.join(data.split())) # type: ignore
|
||||
_remaining_bytes_to_read = total_bytes_to_read - _data_buffer.tell() # type: ignore
|
||||
|
||||
|
@ -274,8 +274,9 @@ class Base64IO(io.IOBase):
|
|||
data = self.__wrapped.read(_bytes_to_read)
|
||||
# Remove whitespace from read data and attempt to read more data to get the desired
|
||||
# number of bytes.
|
||||
whitespace = string.whitespace.encode("utf-8") if isinstance(data, bytes) \
|
||||
else string.whitespace # type: Union[bytes, str]
|
||||
whitespace = (
|
||||
string.whitespace.encode("utf-8") if isinstance(data, bytes) else string.whitespace
|
||||
) # type: Union[bytes, str]
|
||||
|
||||
if any([char in data for char in whitespace]):
|
||||
data = self._read_additional_data_removing_whitespace(data, _bytes_to_read)
|
||||
|
|
|
@ -19,8 +19,8 @@ import io
|
|||
import math
|
||||
import os
|
||||
|
||||
from mock import MagicMock, sentinel
|
||||
import pytest
|
||||
from mock import MagicMock, sentinel
|
||||
|
||||
from base64io import Base64IO
|
||||
|
||||
|
@ -159,7 +159,7 @@ def test_base64io_decode(bytes_to_generate, bytes_per_round, number_of_rounds, t
|
|||
)
|
||||
def test_base64io_decode_str(bytes_to_generate, bytes_per_round, number_of_rounds, total_bytes_to_expect):
|
||||
plaintext_source = os.urandom(bytes_to_generate)
|
||||
plaintext_b64 = io.StringIO(base64.b64encode(plaintext_source).decode('ascii'))
|
||||
plaintext_b64 = io.StringIO(base64.b64encode(plaintext_source).decode("ascii"))
|
||||
plaintext_wrapped = Base64IO(plaintext_b64)
|
||||
|
||||
test = b""
|
||||
|
@ -315,7 +315,7 @@ def test_base64io_decode_with_whitespace(plaintext_source, b64_plaintext_with_wh
|
|||
|
||||
@pytest.mark.parametrize("plaintext_source, b64_plaintext_with_whitespace, read_bytes", build_whitespace_testcases())
|
||||
def test_base64io_decode_with_whitespace_str(plaintext_source, b64_plaintext_with_whitespace, read_bytes):
|
||||
with Base64IO(io.StringIO(b64_plaintext_with_whitespace.decode('ascii'))) as decoder:
|
||||
with Base64IO(io.StringIO(b64_plaintext_with_whitespace.decode("ascii"))) as decoder:
|
||||
test = decoder.read(read_bytes)
|
||||
|
||||
assert test == plaintext_source[:read_bytes]
|
||||
|
|
|
@ -32,7 +32,7 @@ def test_file():
|
|||
if is_python2:
|
||||
# If we are in Python 2, the "file" assignment should not
|
||||
# happen because it is a builtin object.
|
||||
assert not hasattr(base64io, 'file')
|
||||
assert not hasattr(base64io, "file")
|
||||
else:
|
||||
# If we are in Python 3, the "file" assignment should happen
|
||||
# to provide a concrete definition of the "file" name.
|
||||
|
|
Loading…
Reference in New Issue