Changeset View
Changeset View
Standalone View
Standalone View
swh/web/browse/snapshot_context.py
Show First 20 Lines • Show All 785 Lines • ▼ Show 20 Lines | ): | ||||
if root_directory: | if root_directory: | ||||
nb_files = len(files) | nb_files = len(files) | ||||
nb_dirs = len(dirs) | nb_dirs = len(dirs) | ||||
dir_path = "/" + path | dir_path = "/" + path | ||||
swh_objects = [] | swh_objects = [] | ||||
vault_cooking = {} | vault_cooking = {} | ||||
revision_found = True | revision_found = True | ||||
if sha1_git is None and revision_id is not None: | if sha1_git is None and revision_id is not None: | ||||
try: | try: | ||||
archive.lookup_revision(revision_id) | archive.lookup_revision(revision_id) | ||||
except NotFoundExc: | except NotFoundExc: | ||||
revision_found = False | revision_found = False | ||||
if sha1_git is not None: | if sha1_git is not None: | ||||
swh_objects.append( | swh_objects.append( | ||||
SWHObjectInfo(object_type=ObjectType.DIRECTORY, object_id=sha1_git) | SWHObjectInfo(object_type=ObjectType.DIRECTORY, object_id=sha1_git) | ||||
) | ) | ||||
vault_cooking.update( | vault_cooking.update( | ||||
{"directory_context": True, "directory_swhid": f"swh:1:dir:{sha1_git}",} | {"directory_context": True, "directory_swhid": f"swh:1:dir:{sha1_git}",} | ||||
) | ) | ||||
if revision_found: | if revision_id is not None and revision_found: | ||||
swh_objects.append( | swh_objects.append( | ||||
SWHObjectInfo(object_type=ObjectType.REVISION, object_id=revision_id) | SWHObjectInfo(object_type=ObjectType.REVISION, object_id=revision_id) | ||||
) | ) | ||||
vault_cooking.update( | vault_cooking.update( | ||||
{"revision_context": True, "revision_swhid": f"swh:1:rev:{revision_id}",} | {"revision_context": True, "revision_swhid": f"swh:1:rev:{revision_id}",} | ||||
) | ) | ||||
swh_objects.append( | swh_objects.append( | ||||
SWHObjectInfo(object_type=ObjectType.SNAPSHOT, object_id=snapshot_id) | SWHObjectInfo(object_type=ObjectType.SNAPSHOT, object_id=snapshot_id) | ||||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | if query_string: | ||||
content_raw_url = reverse( | content_raw_url = reverse( | ||||
"browse-content-raw", | "browse-content-raw", | ||||
url_args={"query_string": query_string}, | url_args={"query_string": query_string}, | ||||
query_params={"filename": filename}, | query_params={"filename": filename}, | ||||
) | ) | ||||
content_checksums = content_data.get("checksums", {}) | content_checksums = content_data.get("checksums", {}) | ||||
swh_objects = [ | sha1_git = content_checksums.get("sha1_git") | ||||
SWHObjectInfo( | |||||
object_type=ObjectType.CONTENT, object_id=content_checksums.get("sha1_git") | swh_objects = [] | ||||
), | |||||
SWHObjectInfo(object_type=ObjectType.DIRECTORY, object_id=directory_id), | if sha1_git is not None: | ||||
SWHObjectInfo(object_type=ObjectType.REVISION, object_id=revision_id), | swh_objects.append( | ||||
SWHObjectInfo(object_type=ObjectType.SNAPSHOT, object_id=snapshot_id), | SWHObjectInfo(object_type=ObjectType.CONTENT, object_id=sha1_git) | ||||
] | ) | ||||
if directory_id is not None: | |||||
swh_objects.append( | |||||
SWHObjectInfo(object_type=ObjectType.DIRECTORY, object_id=directory_id) | |||||
) | |||||
if revision_id is not None: | |||||
swh_objects.append( | |||||
SWHObjectInfo(object_type=ObjectType.REVISION, object_id=revision_id) | |||||
) | |||||
swh_objects.append( | |||||
SWHObjectInfo(object_type=ObjectType.SNAPSHOT, object_id=snapshot_id) | |||||
) | |||||
visit_date = None | visit_date = None | ||||
visit_type = None | visit_type = None | ||||
if visit_info: | if visit_info: | ||||
visit_date = format_utc_iso_date(visit_info["date"]) | visit_date = format_utc_iso_date(visit_info["date"]) | ||||
visit_type = visit_info["type"] | visit_type = visit_info["type"] | ||||
release_id = snapshot_context["release_id"] | release_id = snapshot_context["release_id"] | ||||
▲ Show 20 Lines • Show All 476 Lines • Show Last 20 Lines |