Skip to content

Commit

Permalink
pylint work
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtin committed Dec 22, 2016
1 parent b8fe4da commit 1420966
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions CloudFlare/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class CloudFlareError(Exception):
""" errors for Cloudflare API"""

class code_and_message(object):
class CodeMessage(object):
""" a small class to save away an interger and string (the code and the message)"""

def __init__(self, code, message):
Expand All @@ -17,23 +17,24 @@ def __str__(self):
def __init__(self, code, message, error_chain=None):
""" errors for Cloudflare API"""

self.e = self.code_and_message(int(code), str(message))
self.evalue = self.CodeMessage(int(code), str(message))
self.error_chain = None
if error_chain != None:
self.error_chain = []
for e in error_chain:
self.error_chain.append(self.code_and_message(int(e['code']), str(e['message'])))
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.e)
return int(self.evalue)

def __str__(self):
""" string value for Cloudflare API errors"""

return str(self.e)
return str(self.evalue)

def __len__(self):
""" Cloudflare API errors can contain a chain of errors"""
Expand All @@ -53,10 +54,12 @@ def __iter__(self):

if self.error_chain is None:
raise StopIteration
for e in self.error_chain:
yield e
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()

Expand Down

0 comments on commit 1420966

Please sign in to comment.