bookwyrm/bookwyrm/importers/bookwyrm_import.py

25 lines
750 B
Python
Raw Normal View History

"""Import data from Bookwyrm export files"""
2023-10-23 10:30:17 +00:00
from django.http import QueryDict
from bookwyrm.models import User
from bookwyrm.models.bookwyrm_import_job import BookwyrmImportJob
class BookwyrmImporter:
2023-10-22 05:52:29 +00:00
"""Import a Bookwyrm User export file.
This is kind of a combination of an importer and a connector.
"""
2023-10-27 19:51:26 +00:00
# pylint: disable=no-self-use
2023-10-22 05:52:29 +00:00
def process_import(
2023-10-23 10:30:17 +00:00
self, user: User, archive_file: bytes, settings: QueryDict
2023-10-27 19:51:26 +00:00
) -> BookwyrmImportJob:
"""import user data from a Bookwyrm export file"""
required = [k for k in settings if settings.get(k) == "on"]
job = BookwyrmImportJob.objects.create(
user=user, archive_file=archive_file, required=required
)
return job