Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not top_level:
colls[0].hideSectionTitle = True # the topmost one should be hidden
# if top_level:
# print("Fetching top-level collection ", topcollection)
# else:
# colls = self.traverse(self.zot.collections_sub(topcollection))
else:
log("Fetching all collections:")
colls = self.traverse(self.zot.collections())
colls = filter(lambda e: e, colls) # remove empties
return colls
except zotero_errors.UserNotAuthorised:
error("UserNotAuthorised: Set correct Zotero API key in settings.py and allow access.")
raise SystemExit(1)
def error_handler(zot, req):
""" Error handler for HTTP requests
"""
error_codes = {
400: ze.UnsupportedParams,
401: ze.UserNotAuthorised,
403: ze.UserNotAuthorised,
404: ze.ResourceNotFound,
409: ze.Conflict,
412: ze.PreConditionFailed,
413: ze.RequestEntityTooLarge,
428: ze.PreConditionRequired,
429: ze.TooManyRequests,
}
def err_msg(req):
""" Return a nicely-formatted error message
"""
return "\nCode: %s\nURL: %s\nMethod: %s\nResponse: %s" % (
req.status_code,
# error.msg,
req.url,
req.request.method,
req.text,
)
if error_codes.get(req.status_code):
# check to see whether its 429
def error_handler(req):
""" Error handler for HTTP requests
"""
error_codes = {
400: ze.UnsupportedParams,
401: ze.UserNotAuthorised,
403: ze.UserNotAuthorised,
404: ze.ResourceNotFound,
409: ze.Conflict,
412: ze.PreConditionFailed,
413: ze.RequestEntityTooLarge,
428: ze.PreConditionRequired,
429: ze.TooManyRequests,
}
def err_msg(req):
""" Return a nicely-formatted error message
"""
return "\nCode: %s\nURL: %s\nMethod: %s\nResponse: %s" % (
req.status_code,
# error.msg,
req.url,
req.request.method,
def error_handler(zot, req):
""" Error handler for HTTP requests
"""
error_codes = {
400: ze.UnsupportedParams,
401: ze.UserNotAuthorised,
403: ze.UserNotAuthorised,
404: ze.ResourceNotFound,
409: ze.Conflict,
412: ze.PreConditionFailed,
413: ze.RequestEntityTooLarge,
428: ze.PreConditionRequired,
429: ze.TooManyRequests,
}
def err_msg(req):
""" Return a nicely-formatted error message
"""
return "\nCode: %s\nURL: %s\nMethod: %s\nResponse: %s" % (
req.status_code,
# error.msg,
req.url,
req.request.method,
req.text,
)
def error_handler(zot, req):
""" Error handler for HTTP requests
"""
error_codes = {
400: ze.UnsupportedParams,
401: ze.UserNotAuthorised,
403: ze.UserNotAuthorised,
404: ze.ResourceNotFound,
409: ze.Conflict,
412: ze.PreConditionFailed,
413: ze.RequestEntityTooLarge,
428: ze.PreConditionRequired,
429: ze.TooManyRequests,
}
def err_msg(req):
""" Return a nicely-formatted error message
"""
return "\nCode: %s\nURL: %s\nMethod: %s\nResponse: %s" % (
req.status_code,
# error.msg,
req.url,
req.request.method,
req.text,
)