Changeset View
Changeset View
Standalone View
Standalone View
swh/graph/tests/dataset/generate_dataset.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (C) 2021 The Software Heritage developers | # Copyright (C) 2021-2022 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 | ||||
# type: ignore | # type: ignore | ||||
import argparse | import argparse | ||||
import datetime | import datetime | ||||
▲ Show 20 Lines • Show All 274 Lines • ▼ Show 20 Lines | Release( | ||||
name=b"v2.0", | name=b"v2.0", | ||||
date=None, | date=None, | ||||
author=PERSONS[1], | author=PERSONS[1], | ||||
target_type=ObjectType.REVISION, | target_type=ObjectType.REVISION, | ||||
target=h(18), | target=h(18), | ||||
message=b"Version 2.0", | message=b"Version 2.0", | ||||
synthetic=False, | synthetic=False, | ||||
), | ), | ||||
Release( | |||||
id=h(21), | |||||
name=b"v2.0-anonymous", | |||||
date=None, | |||||
author=None, | |||||
target_type=ObjectType.REVISION, | |||||
target=h(18), | |||||
message=b"Version 2.0 but with no author", | |||||
synthetic=False, | |||||
), | |||||
Snapshot( | Snapshot( | ||||
id=h(20), | id=h(20), | ||||
branches={ | branches={ | ||||
b"refs/heads/master": SnapshotBranch( | b"refs/heads/master": SnapshotBranch( | ||||
target=h(9), target_type=TargetType.REVISION | target=h(9), target_type=TargetType.REVISION | ||||
), | ), | ||||
b"refs/tags/v1.0": SnapshotBranch( | b"refs/tags/v1.0": SnapshotBranch( | ||||
target=h(10), target_type=TargetType.RELEASE | target=h(10), target_type=TargetType.RELEASE | ||||
Show All 15 Lines | OriginVisitStatus( | ||||
), | ), | ||||
visit=1, | visit=1, | ||||
type="git", | type="git", | ||||
status="full", | status="full", | ||||
snapshot=h(20), | snapshot=h(20), | ||||
metadata=None, | metadata=None, | ||||
), | ), | ||||
Origin(url="https://example.com/swh/graph"), | Origin(url="https://example.com/swh/graph"), | ||||
Snapshot( | |||||
id=h(22), | |||||
branches={ | |||||
b"refs/heads/master": SnapshotBranch( | |||||
target=h(9), target_type=TargetType.REVISION | |||||
), | |||||
b"refs/tags/v1.0": SnapshotBranch( | |||||
target=h(10), target_type=TargetType.RELEASE | |||||
), | |||||
b"refs/tags/v2.0-anonymous": SnapshotBranch( | |||||
target=h(21), target_type=TargetType.RELEASE | |||||
), | |||||
}, | |||||
), | |||||
OriginVisit( | |||||
origin="https://example.com/swh/graph2", | |||||
date=datetime.datetime( | |||||
2013, 5, 7, 4, 20, 39, 369271, tzinfo=datetime.timezone.utc | |||||
), | |||||
visit=1, | |||||
type="git", | |||||
), | |||||
OriginVisitStatus( | |||||
origin="https://example.com/swh/graph2", | |||||
date=datetime.datetime( | |||||
2013, 5, 7, 4, 20, 41, 369271, tzinfo=datetime.timezone.utc | |||||
), | |||||
visit=1, | |||||
type="git", | |||||
status="full", | |||||
snapshot=h(22), | |||||
metadata=None, | |||||
), | |||||
Origin(url="https://example.com/swh/graph2"), | |||||
] | ] | ||||
def main(): | def main(): | ||||
logging.basicConfig(level=logging.INFO) | logging.basicConfig(level=logging.INFO) | ||||
parser = argparse.ArgumentParser(description="Generate a test dataset") | parser = argparse.ArgumentParser(description="Generate a test dataset") | ||||
parser.add_argument( | parser.add_argument( | ||||
Show All 26 Lines |