/usr/lib/python3/dist-packages/CloudFlare/exceptions.py is in python3-cloudflare 2.0.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | """ errors for Cloudflare API"""
class CloudFlareError(Exception):
""" errors for Cloudflare API"""
class CodeMessage(object):
""" a small class to save away an interger and string (the code and the message)"""
def __init__(self, code, message):
self.code = code
self.message = message
def __int__(self):
return self.code
def __str__(self):
return self.message
def __init__(self, code, message, error_chain=None):
""" errors for Cloudflare API"""
self.evalue = self.CodeMessage(int(code), str(message))
self.error_chain = None
if error_chain != None:
self.error_chain = []
for evalue in error_chain:
self.error_chain.append(
self.CodeMessage(int(evalue['code']), str(evalue['message'])))
# self.error_chain.append({'code': self.code, 'message': str(self.message)})
def __int__(self):
""" integer value for Cloudflare API errors"""
return int(self.evalue)
def __str__(self):
""" string value for Cloudflare API errors"""
return str(self.evalue)
def __len__(self):
""" Cloudflare API errors can contain a chain of errors"""
if self.error_chain is None:
return 0
else:
return len(self.error_chain)
def __getitem__(self, ii):
""" Cloudflare API errors can contain a chain of errors"""
return self.error_chain[ii]
def __iter__(self):
""" Cloudflare API errors can contain a chain of errors"""
if self.error_chain is None:
raise StopIteration
for evalue in self.error_chain:
yield evalue
def next(self):
""" Cloudflare API errors can contain a chain of errors"""
if self.error_chain is None:
raise StopIteration()
class CloudFlareAPIError(CloudFlareError):
""" errors for Cloudflare API"""
pass
class CloudFlareInternalError(CloudFlareError):
""" errors for Cloudflare API"""
pass
|