def package_get(owner, package_name, package_hash):
subpath = request.args.get('subpath')
instance = _get_instance(g.auth, owner, package_name, package_hash)
contents = json.loads(instance.contents, object_hook=decode_node)
subnode = contents
for component in subpath.split('/') if subpath else []:
try:
subnode = subnode.children[component]
except (AttributeError, KeyError):
raise ApiException(requests.codes.not_found, "Invalid subpath: %r" % component)
all_hashes = set(find_object_hashes(subnode))
urls = {
blob_hash: _generate_presigned_url(S3_GET_OBJECT, owner, blob_hash)
for blob_hash in all_hashes
}
_mp_track(
type="install",
package_owner=owner,
package_name=package_name,
subpath=subpath,
)
return dict(
contents=contents,
urls=urls,
created_by=instance.created_by,
created_at=_utc_datetime_to_ts(instance.created_at),
updated_by=instance.updated_by,
updated_at=_utc_datetime_to_ts(instance.updated_at),
)
评论列表
文章目录