Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/tar/loader.py
# Copyright (C) 2015-2018 The Software Heritage developers | # Copyright (C) 2015-2018 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import os | import os | ||||
import tempfile | import tempfile | ||||
import shutil | import shutil | ||||
from swh.core import tarball | from swh.core import tarball | ||||
from swh.loader.core.loader import SWHLoader | from swh.loader.core.loader import BufferedLoader | ||||
from swh.loader.dir import loader | from swh.loader.dir import loader | ||||
from swh.model.hashutil import MultiHash | from swh.model.hashutil import MultiHash | ||||
class TarLoader(loader.DirLoader): | class TarLoader(loader.DirLoader): | ||||
"""Tarball loader implementation. | """Tarball loader implementation. | ||||
This is a subclass of the :class:DirLoader as the main goal of | This is a subclass of the :class:DirLoader as the main goal of | ||||
Show All 33 Lines | def load(self, *, tar_path, origin, visit_date, revision, | ||||
isoformatted string) | isoformatted string) | ||||
revision (dict): a revision as passed to | revision (dict): a revision as passed to | ||||
:func:`swh.storage.storage.Storage.revision_add`, excluding the | :func:`swh.storage.storage.Storage.revision_add`, excluding the | ||||
`id` and `directory` keys (computed from the directory) | `id` and `directory` keys (computed from the directory) | ||||
branch_name (str): the optional branch_name to use for snapshot | branch_name (str): the optional branch_name to use for snapshot | ||||
""" | """ | ||||
# Shortcut super() as we use different arguments than the DirLoader. | # Shortcut super() as we use different arguments than the DirLoader. | ||||
return SWHLoader.load(self, tar_path=tar_path, origin=origin, | return BufferedLoader.load(self, tar_path=tar_path, origin=origin, | ||||
visit_date=visit_date, revision=revision, | visit_date=visit_date, revision=revision, | ||||
branch_name=branch_name) | branch_name=branch_name) | ||||
def prepare_origin_visit(self, *, origin, visit_date=None, **kwargs): | def prepare_origin_visit(self, *, origin, visit_date=None, **kwargs): | ||||
self.origin = origin | self.origin = origin | ||||
if 'type' not in self.origin: # let the type flow if present | if 'type' not in self.origin: # let the type flow if present | ||||
self.origin['type'] = 'tar' | self.origin['type'] = 'tar' | ||||
self.visit_date = visit_date | self.visit_date = visit_date | ||||
def prepare(self, *, tar_path, origin, revision, visit_date=None, | def prepare(self, *, tar_path, origin, revision, visit_date=None, | ||||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |