mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
Merge pull request #3057 from hughrun/user-migrate
once more into the linting breach!
This commit is contained in:
commit
d05cf8e59b
3 changed files with 7 additions and 5 deletions
|
@ -94,7 +94,8 @@ def json_export(user): # pylint: disable=too-many-locals, too-many-statements
|
|||
# reading goals
|
||||
reading_goals = models.AnnualGoal.objects.filter(user=user).distinct()
|
||||
goals_list = []
|
||||
# TODO: either error checking should be more sophisticated or maybe we don't need this try/except
|
||||
# TODO: either error checking should be more sophisticated
|
||||
# or maybe we don't need this try/except
|
||||
try:
|
||||
for goal in reading_goals:
|
||||
goals_list.append(
|
||||
|
|
|
@ -10,6 +10,7 @@ def read_tar():
|
|||
yield tar
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def write_tar():
|
||||
archive_path = "/tmp/test.tar.gz"
|
||||
with open(archive_path, "wb") as archive_file:
|
||||
|
|
|
@ -8,14 +8,14 @@ from django.core.files import File
|
|||
class BookwyrmTarFile(tarfile.TarFile):
|
||||
"""Create tar files for user exports"""
|
||||
|
||||
def write_bytes(self, data: bytes):
|
||||
def write_bytes(self, data: bytes) -> None:
|
||||
"""Add a file containing bytes to the archive"""
|
||||
buffer = io.BytesIO(data)
|
||||
info = tarfile.TarInfo("archive.json")
|
||||
info.size = len(data)
|
||||
self.addfile(info, fileobj=buffer)
|
||||
|
||||
def add_image(self, image, filename=None, directory=""):
|
||||
def add_image(self, image: Any, filename: str = None, directory: Any = "") -> None:
|
||||
"""
|
||||
Add an image to the tar archive
|
||||
:param str filename: overrides the file name set by image
|
||||
|
@ -32,12 +32,12 @@ class BookwyrmTarFile(tarfile.TarFile):
|
|||
|
||||
self.addfile(info, fileobj=image)
|
||||
|
||||
def read(self, filename):
|
||||
def read(self, filename: str) -> Any:
|
||||
"""read data from the tar"""
|
||||
with self.extractfile(filename) as reader:
|
||||
return reader.read()
|
||||
|
||||
def write_image_to_file(self, filename, file_field):
|
||||
def write_image_to_file(self, filename: str, file_field: Any) -> None:
|
||||
"""add an image to the tar"""
|
||||
extension = filename.rsplit(".")[-1]
|
||||
with self.extractfile(filename) as reader:
|
||||
|
|
Loading…
Reference in a new issue