Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_gist(slug, version, fresh):
"""Download a gist"""
if '/' in slug:
parts = slug.split('/')
username, title = parts[0], parts[1]
url = _u('user/' + username + '/gist/' + title + _v(version))
else:
url = _u('gist/' + slug + _v(version))
res = get(url, headers=_h(fresh))
if res.status_code == 200:
return res.json()['data']
raise Exception('Failed to retrieve Gist: ' + pretty(res))
def get_gist_access(slug):
"""Get the access permission of a gist"""
res = get(url=_u('/gist/' + slug + '/check-access'), headers=_h())
if res.status_code == 200:
return res.json()['data']
raise Exception('Failed to retrieve access permission for notebook "' +
slug + '" (retry with new_project=True to create a new notebook): ' + pretty(res))
def get_current_user():
res = get(url=_u('/user/profile'), headers=_h())
if res.status_code == 200:
return res.json()['data']
raise Exception('Failed to fetch current user profile. ' + pretty(res))