Skip to content

Commit 471027e

Browse files
author
Tome Petrovski
committed
ARTMXCICH-149/minor code polish
1 parent 8789f75 commit 471027e

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

ckanext/resource_docs/views.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ def get(self, package_id: str, resource_id: str) -> str:
2727
except (tk.ObjectNotFound, tk.NotAuthorized):
2828
return tk.abort(404, tk._("Resource not found"))
2929

30-
resource = None
31-
for res in pkg_dict.get(u'resources', []):
32-
if res["id"] == resource_id:
33-
resource = res
34-
break
30+
resources = {res["id"]: res for res in pkg_dict.get("resources", [])}
31+
resource = resources.get(resource_id)
3532

3633
if not resource:
3734
return tk.abort(404, tk._("Resource not found"))

0 commit comments

Comments
 (0)