Changeset View
Changeset View
Standalone View
Standalone View
swh/web/common/identifiers.py
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | ) -> ResolvedSWHID: | ||||
browse_url = None | browse_url = None | ||||
url_args = {} | url_args = {} | ||||
query_dict = QueryDict("", mutable=True) | query_dict = QueryDict("", mutable=True) | ||||
fragment = "" | fragment = "" | ||||
process_lines = object_type == ObjectType.CONTENT | process_lines = object_type == ObjectType.CONTENT | ||||
if query_params and len(query_params) > 0: | if query_params and len(query_params) > 0: | ||||
for k in sorted(query_params.keys()): | for k in sorted(query_params.keys()): | ||||
query_dict[k] = query_params[k] | query_dict[k] = str(query_params[k]) | ||||
jayeshv: There is a mypy error in the same line when using psycopg2 latest version.
https://jenkins. | |||||
Done Inline ActionsThis errors are unrelated to psycopg2 but to the upgrade of django stubs for mypy. FYI, we cannot use psycopg2 >= 2.9 with Django 2.2 (see D7927#206118). anlambert: This errors are unrelated to psycopg2 but to the upgrade of django stubs for mypy.
FYI, we… | |||||
if swhid_parsed.origin: | if swhid_parsed.origin: | ||||
origin_url = unquote(swhid_parsed.origin) | origin_url = unquote(swhid_parsed.origin) | ||||
origin_url = archive.lookup_origin({"url": origin_url})["url"] | origin_url = archive.lookup_origin({"url": origin_url})["url"] | ||||
query_dict["origin_url"] = origin_url | query_dict["origin_url"] = origin_url | ||||
if swhid_parsed.path and swhid_parsed.path != b"/": | if swhid_parsed.path and swhid_parsed.path != b"/": | ||||
query_dict["path"] = swhid_parsed.path.decode("utf8", errors="replace") | query_dict["path"] = swhid_parsed.path.decode("utf8", errors="replace") | ||||
Show All 18 Lines | if swhid_parsed.path and swhid_parsed.path != b"/": | ||||
not swhid_parsed.origin | not swhid_parsed.origin | ||||
and swhid_parsed.anchor.object_type != ObjectType.REVISION | and swhid_parsed.anchor.object_type != ObjectType.REVISION | ||||
): | ): | ||||
# when no origin or revision context, content objects need to have | # when no origin or revision context, content objects need to have | ||||
# their path prefixed by root directory id for breadcrumbs display | # their path prefixed by root directory id for breadcrumbs display | ||||
query_dict["path"] = hash_to_hex(directory) + query_dict["path"] | query_dict["path"] = hash_to_hex(directory) + query_dict["path"] | ||||
else: | else: | ||||
# remove leading slash from SWHID content path | # remove leading slash from SWHID content path | ||||
query_dict["path"] = query_dict["path"][1:] | query_dict["path"] = str(query_dict["path"]).lstrip("/") | ||||
elif object_type == ObjectType.DIRECTORY: | elif object_type == ObjectType.DIRECTORY: | ||||
object_id = directory | object_id = directory | ||||
# remove leading and trailing slashes from SWHID directory path | # remove leading and trailing slashes from SWHID directory path | ||||
if query_dict["path"].endswith("/"): | query_dict["path"] = str(query_dict["path"]).strip("/") | ||||
query_dict["path"] = query_dict["path"][1:-1] | |||||
else: | |||||
query_dict["path"] = query_dict["path"][1:] | |||||
# snapshot context | # snapshot context | ||||
if swhid_parsed.visit: | if swhid_parsed.visit: | ||||
if swhid_parsed.visit.object_type != ObjectType.SNAPSHOT: | if swhid_parsed.visit.object_type != ObjectType.SNAPSHOT: | ||||
raise BadInputExc("Visit must be a snapshot SWHID.") | raise BadInputExc("Visit must be a snapshot SWHID.") | ||||
query_dict["snapshot"] = hash_to_hex(swhid_parsed.visit.object_id) | query_dict["snapshot"] = hash_to_hex(swhid_parsed.visit.object_id) | ||||
if swhid_parsed.anchor: | if swhid_parsed.anchor: | ||||
▲ Show 20 Lines • Show All 222 Lines • Show Last 20 Lines |
There is a mypy error in the same line when using psycopg2 latest version.
https://jenkins.softwareheritage.org/blue/organizations/jenkins/DWAPPS%2Ftests-on-diff/detail/tests-on-diff/1861/pipeline
will this fix that as well?