Skip to content
Snippets Groups Projects
Commit aa1bc913 authored by Jenkins for Software Heritage's avatar Jenkins for Software Heritage
Browse files

Update upstream source from tag 'debian/upstream/0.2.2'

Update to upstream version '0.2.2'
with Debian dir 0058bdf22c4fff3486ccd8de7020fbf9b0cc2c12
parents 15abf837 3c5660ba
No related branches found
No related tags found
No related merge requests found
Metadata-Version: 2.1
Name: swh.loader.cvs
Version: 0.2.1
Version: 0.2.2
Summary: Software Heritage CVS Loader
Home-page: https://forge.softwareheritage.org/diffusion/swh-loader-cvs
Author: Software Heritage developers
......@@ -17,7 +17,7 @@ Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 3 - Alpha
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Description-Content-Type: text/x-rst
Provides-Extra: testing
License-File: LICENSE
License-File: AUTHORS
......@@ -28,11 +28,12 @@ Software Heritage - CVS loader
The Software Heritage CVS Loader imports the history of CVS repositories
into the SWH dataset.
The main entry points are
The main entry points is:
- :class:`swh.loader.cvs.loader.CvsLoader` for the main cvs loader
- ``swh.loader.cvs.loader.CvsLoader`` for the main cvs loader
which ingests content out of a local cvs repository
Features
--------
......
......@@ -4,11 +4,12 @@ Software Heritage - CVS loader
The Software Heritage CVS Loader imports the history of CVS repositories
into the SWH dataset.
The main entry points are
The main entry points is:
- :class:`swh.loader.cvs.loader.CvsLoader` for the main cvs loader
- ``swh.loader.cvs.loader.CvsLoader`` for the main cvs loader
which ingests content out of a local cvs repository
Features
--------
......
......@@ -4,11 +4,12 @@ Software Heritage - CVS loader
The Software Heritage CVS Loader imports the history of CVS repositories
into the SWH dataset.
The main entry points are
The main entry points is:
- :class:`swh.loader.cvs.loader.CvsLoader` for the main cvs loader
- ``swh.loader.cvs.loader.CvsLoader`` for the main cvs loader
which ingests content out of a local cvs repository
Features
--------
......
......@@ -40,7 +40,7 @@ setup(
name="swh.loader.cvs",
description="Software Heritage CVS Loader",
long_description=long_description,
long_description_content_type="text/markdown",
long_description_content_type="text/x-rst",
python_requires=">=3.7",
author="Software Heritage developers",
author_email="swh-devel@inria.fr",
......
Metadata-Version: 2.1
Name: swh.loader.cvs
Version: 0.2.1
Version: 0.2.2
Summary: Software Heritage CVS Loader
Home-page: https://forge.softwareheritage.org/diffusion/swh-loader-cvs
Author: Software Heritage developers
......@@ -17,7 +17,7 @@ Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 3 - Alpha
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Description-Content-Type: text/x-rst
Provides-Extra: testing
License-File: LICENSE
License-File: AUTHORS
......@@ -28,11 +28,12 @@ Software Heritage - CVS loader
The Software Heritage CVS Loader imports the history of CVS repositories
into the SWH dataset.
The main entry points are
The main entry points is:
- :class:`swh.loader.cvs.loader.CvsLoader` for the main cvs loader
- ``swh.loader.cvs.loader.CvsLoader`` for the main cvs loader
which ingests content out of a local cvs repository
Features
--------
......
# Copyright (C) 2015-2021 The Software Heritage developers
# Copyright (C) 2015-2022 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
from datetime import datetime
from typing import Optional
from celery import shared_task
import iso8601
from swh.loader.core.utils import parse_visit_date
from .loader import CvsLoader
def convert_to_datetime(date: Optional[str]) -> Optional[datetime]:
if date is None:
return None
try:
assert isinstance(date, str)
return iso8601.parse_date(date)
except Exception:
return None
def _process_kwargs(kwargs):
if "visit_date" in kwargs:
kwargs["visit_date"] = parse_visit_date(kwargs["visit_date"])
return kwargs
@shared_task(name=__name__ + ".LoadCvsRepository")
def load_cvs(
*,
url: str,
origin_url: Optional[str] = None,
visit_date: Optional[str] = None,
):
"""Import a CVS repository
Args:
- url: (mandatory) CVS's repository url to ingest data from
- origin_url: Optional original url override to use as origin reference
in the archive. If not provided, "url" is used as origin.
- visit_date: Optional date to override the visit date
"""
loader = CvsLoader.from_configfile(
url=url,
origin_url=origin_url,
visit_date=convert_to_datetime(visit_date),
)
def load_cvs(**kwargs):
"""Import a CVS repository"""
loader = CvsLoader.from_configfile(**_process_kwargs(kwargs))
return loader.load()
# Copyright (C) 2019-2021 The Software Heritage developers
# Copyright (C) 2019-2022 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
from datetime import datetime, timezone
import uuid
import pytest
from swh.loader.cvs.tasks import convert_to_datetime
from swh.scheduler.model import ListedOrigin, Lister
from swh.scheduler.utils import create_origin_task_dict
@pytest.mark.parametrize(
"date,expected_result",
[
(None, None),
(
"2021-11-23 09:41:02.434195+00:00",
datetime(2021, 11, 23, 9, 41, 2, 434195, tzinfo=timezone.utc),
),
(
"23112021",
None,
), # failure to parse
],
)
def test_convert_to_datetime(date, expected_result):
assert convert_to_datetime(date) == expected_result
@pytest.fixture(autouse=True)
def celery_worker_and_swh_config(swh_scheduler_celery_worker, swh_config):
pass
@pytest.fixture
def cvs_lister():
return Lister(name="cvs-lister", instance_name="example", id=uuid.uuid4())
@pytest.fixture
def cvs_listed_origin(cvs_lister):
return ListedOrigin(
lister_id=cvs_lister.id, url="https://cvs.example.org/repo", visit_type="cvs"
)
def test_cvs_loader(
mocker, swh_scheduler_celery_app, swh_scheduler_celery_worker, swh_config
mocker,
swh_scheduler_celery_app,
):
mock_loader = mocker.patch("swh.loader.cvs.loader.CvsLoader.load")
mock_loader.return_value = {"status": "eventful"}
res = swh_scheduler_celery_app.send_task(
"swh.loader.cvs.tasks.LoadCvsRepository",
kwargs=dict(url="some-technical-url", origin_url="origin-url"),
kwargs=dict(
url="some-technical-url", origin_url="origin-url", visit_date="now"
),
)
assert res
res.wait()
assert res.successful()
assert res.result == {"status": "eventful"}
assert mock_loader.called
def test_cvs_loader_for_listed_origin(
mocker, swh_scheduler_celery_app, cvs_lister, cvs_listed_origin
):
mock_loader = mocker.patch("swh.loader.cvs.loader.CvsLoader.load")
mock_loader.return_value = {"status": "eventful"}
task_dict = create_origin_task_dict(cvs_listed_origin, cvs_lister)
res = swh_scheduler_celery_app.send_task(
"swh.loader.cvs.tasks.LoadCvsRepository",
kwargs=task_dict["arguments"]["kwargs"],
)
assert res
res.wait()
......
......@@ -35,7 +35,7 @@ commands =
extras =
testing
deps =
mypy==0.920
mypy==0.942
commands =
mypy swh
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment