def pointer_to_json(dl_url):
content_req = urllib2.Request(dl_url)
content_result = urllib2.urlopen(content_req)
output = content_result.read()
content_result.close()
oid = (re.search('(?m)^oid sha256:([a-z0-9]+)$', output)).group(1)
size = (re.search('(?m)^size ([0-9]+)$', output)).group(1)
json_data = (
'{"operation": "download", '
'"transfers": ["basic"], '
'"objects": [{"oid": "%s", "size": %s}]}' % (oid, size))
return json_data
# the get_lfs_url function makes a request the the lfs API of the github repo,
# receives a JSON response then gets the download URL from the JSON response
# and returns it.
评论列表
文章目录