Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/tasks.py
# Copyright (C) 2015-2021 The Software Heritage developers | # Copyright (C) 2015-2021 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 | ||||
from datetime import datetime | |||||
from typing import Optional | from typing import Optional | ||||
from celery import shared_task | from celery import shared_task | ||||
import iso8601 | |||||
from .loader import SvnLoader, SvnLoaderFromDumpArchive, SvnLoaderFromRemoteDump | from .loader import SvnLoader, SvnLoaderFromDumpArchive, SvnLoaderFromRemoteDump | ||||
def convert_to_datetime(date: Optional[str]) -> Optional[datetime]: | |||||
try: | |||||
anlambert: I guess this can be removed. | |||||
Done Inline Actionsi initially thought "no" Then i realized you probably mean, it'd be trapped by the try except... so maybe ;) ardumont: i initially thought "no"
Then i realized you probably mean, it'd be trapped by the try except.. | |||||
return iso8601.parse_date(date) | |||||
except Exception: | |||||
return None | |||||
@shared_task(name=__name__ + ".LoadSvnRepository") | @shared_task(name=__name__ + ".LoadSvnRepository") | ||||
def load_svn( | def load_svn( | ||||
*, | *, | ||||
url: Optional[str] = None, | url: Optional[str] = None, | ||||
origin_url: Optional[str] = None, | origin_url: Optional[str] = None, | ||||
destination_path: Optional[str] = None, | destination_path: Optional[str] = None, | ||||
swh_revision: Optional[str] = None, | swh_revision: Optional[str] = None, | ||||
visit_date: Optional[str] = None, | visit_date: Optional[str] = None, | ||||
Show All 15 Lines | Args: | ||||
start | start | ||||
""" | """ | ||||
loader = SvnLoader.from_configfile( | loader = SvnLoader.from_configfile( | ||||
url=url, | url=url, | ||||
origin_url=origin_url, | origin_url=origin_url, | ||||
destination_path=destination_path, | destination_path=destination_path, | ||||
swh_revision=swh_revision, | swh_revision=swh_revision, | ||||
visit_date=visit_date, | visit_date=convert_to_datetime(visit_date), | ||||
start_from_scratch=start_from_scratch, | start_from_scratch=start_from_scratch, | ||||
) | ) | ||||
return loader.load() | return loader.load() | ||||
@shared_task(name=__name__ + ".MountAndLoadSvnRepository") | @shared_task(name=__name__ + ".MountAndLoadSvnRepository") | ||||
def load_svn_from_archive( | def load_svn_from_archive( | ||||
*, | *, | ||||
Show All 12 Lines | Args: | ||||
- visit_date: Optional date to override the visit date | - visit_date: Optional date to override the visit date | ||||
- start_from_scratch: Flag to allow starting back the svn repository from the | - start_from_scratch: Flag to allow starting back the svn repository from the | ||||
start | start | ||||
""" | """ | ||||
loader = SvnLoaderFromDumpArchive.from_configfile( | loader = SvnLoaderFromDumpArchive.from_configfile( | ||||
url=url, | url=url, | ||||
archive_path=archive_path, | archive_path=archive_path, | ||||
visit_date=visit_date, | visit_date=convert_to_datetime(visit_date), | ||||
start_from_scratch=start_from_scratch, | start_from_scratch=start_from_scratch, | ||||
) | ) | ||||
return loader.load() | return loader.load() | ||||
@shared_task(name=__name__ + ".DumpMountAndLoadSvnRepository") | @shared_task(name=__name__ + ".DumpMountAndLoadSvnRepository") | ||||
def load_svn_from_remote_dump( | def load_svn_from_remote_dump( | ||||
*, | *, | ||||
Show All 13 Lines | Args: | ||||
- visit_date: Optional date to override the visit date | - visit_date: Optional date to override the visit date | ||||
- start_from_scratch: Flag to allow starting back the svn repository from the | - start_from_scratch: Flag to allow starting back the svn repository from the | ||||
start | start | ||||
""" | """ | ||||
loader = SvnLoaderFromRemoteDump.from_configfile( | loader = SvnLoaderFromRemoteDump.from_configfile( | ||||
url=url, | url=url, | ||||
origin_url=origin_url, | origin_url=origin_url, | ||||
visit_date=visit_date, | visit_date=convert_to_datetime(visit_date), | ||||
start_from_scratch=start_from_scratch, | start_from_scratch=start_from_scratch, | ||||
) | ) | ||||
return loader.load() | return loader.load() |
I guess this can be removed.