Changeset View
Changeset View
Standalone View
Standalone View
swh/web/api/views/directory.py
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | .. http:get:: /api/1/directory/(sha1_git)/[(path)/] | ||||
**Example:** | **Example:** | ||||
.. parsed-literal:: | .. parsed-literal:: | ||||
:swh_web_api:`directory/977fc4b98c0e85816348cebd3b12026407c368b6/` | :swh_web_api:`directory/977fc4b98c0e85816348cebd3b12026407c368b6/` | ||||
""" | """ | ||||
if path: | if path: | ||||
# query directory entry | |||||
error_msg_path = ( | error_msg_path = ( | ||||
"Entry with path %s relative to directory " "with sha1_git %s not found." | "Entry with path %s relative to directory " "with sha1_git %s not found." | ||||
) % (path, sha1_git) | ) % (path, sha1_git) | ||||
return api_lookup( | return api_lookup( | ||||
archive.lookup_directory_with_path, | archive.lookup_directory_with_path, | ||||
sha1_git, | sha1_git, | ||||
path, | path, | ||||
notfound_msg=error_msg_path, | notfound_msg=error_msg_path, | ||||
enrich_fn=utils.enrich_directory_entry, | enrich_fn=utils.enrich_directory_entry, | ||||
request=request, | request=request, | ||||
) | ) | ||||
else: | else: | ||||
# query directory | |||||
error_msg_nopath = "Directory with sha1_git %s not found." % sha1_git | error_msg_nopath = "Directory with sha1_git %s not found." % sha1_git | ||||
return api_lookup( | return api_lookup( | ||||
archive.lookup_directory, | archive.lookup_directory, | ||||
sha1_git, | sha1_git, | ||||
notfound_msg=error_msg_nopath, | notfound_msg=error_msg_nopath, | ||||
enrich_fn=utils.enrich_directory_entry, | enrich_fn=utils.enrich_directory_entry, | ||||
request=request, | request=request, | ||||
) | ) |