Changeset View
Changeset View
Standalone View
Standalone View
swh/web/common/identifiers.py
Show First 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | for swh_object in swh_objects: | ||||
if snapshot_context["origin_info"] is not None: | if snapshot_context["origin_info"] is not None: | ||||
swhid_context["origin"] = quote( | swhid_context["origin"] = quote( | ||||
snapshot_context["origin_info"]["url"], safe="/?:@&" | snapshot_context["origin_info"]["url"], safe="/?:@&" | ||||
) | ) | ||||
if object_type != SNAPSHOT: | if object_type != SNAPSHOT: | ||||
swhid_context["visit"] = get_swh_persistent_id( | swhid_context["visit"] = get_swh_persistent_id( | ||||
SNAPSHOT, snapshot_context["snapshot_id"] | SNAPSHOT, snapshot_context["snapshot_id"] | ||||
) | ) | ||||
if object_type not in (RELEASE, REVISION, SNAPSHOT): | if object_type in (CONTENT, DIRECTORY): | ||||
if snapshot_context["release_id"] is not None: | if snapshot_context["release_id"] is not None: | ||||
swhid_context["anchor"] = get_swh_persistent_id( | swhid_context["anchor"] = get_swh_persistent_id( | ||||
RELEASE, snapshot_context["release_id"] | RELEASE, snapshot_context["release_id"] | ||||
) | ) | ||||
elif snapshot_context["revision_id"] is not None: | elif snapshot_context["revision_id"] is not None: | ||||
swhid_context["anchor"] = get_swh_persistent_id( | swhid_context["anchor"] = get_swh_persistent_id( | ||||
REVISION, snapshot_context["revision_id"] | REVISION, snapshot_context["revision_id"] | ||||
) | ) | ||||
if object_type in (CONTENT, DIRECTORY): | if object_type in (CONTENT, DIRECTORY): | ||||
if ( | if ( | ||||
extra_context | extra_context | ||||
and "revision" in extra_context | and "revision" in extra_context | ||||
and extra_context["revision"] | and extra_context["revision"] | ||||
and "anchor" not in swhid_context | |||||
): | ): | ||||
swhid_context["anchor"] = get_swh_persistent_id( | swhid_context["anchor"] = get_swh_persistent_id( | ||||
REVISION, extra_context["revision"] | REVISION, extra_context["revision"] | ||||
) | ) | ||||
elif ( | elif ( | ||||
extra_context | extra_context | ||||
and "root_directory" in extra_context | and "root_directory" in extra_context | ||||
and extra_context["root_directory"] | and extra_context["root_directory"] | ||||
and "anchor" not in swhid_context | |||||
and ( | and ( | ||||
object_type != DIRECTORY | object_type != DIRECTORY | ||||
or extra_context["root_directory"] != object_id | or extra_context["root_directory"] != object_id | ||||
) | ) | ||||
): | ): | ||||
swhid_context["anchor"] = get_swh_persistent_id( | swhid_context["anchor"] = get_swh_persistent_id( | ||||
DIRECTORY, extra_context["root_directory"] | DIRECTORY, extra_context["root_directory"] | ||||
) | ) | ||||
Show All 33 Lines |