Skip to content

Commit

Permalink
small pylint changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtin committed Jun 14, 2016
1 parent 02a13a5 commit 8168029
Showing 1 changed file with 90 additions and 24 deletions.
114 changes: 90 additions & 24 deletions CloudFlare/cloudflare.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,16 @@ def _call(self, method, headers,
response = requests.delete(url, headers=headers)
elif method == 'PATCH':
if data:
response = requests.request('PATCH', url, headers=headers, params=params, json=data)
response = requests.request('PATCH',
url,
headers=headers,
params=params,
json=data)
else:
response = requests.request('PATCH', url, headers=headers, params=params)
response = requests.request('PATCH',
url,
headers=headers,
params=params)
else:
# should never happen
raise CloudFlareAPIError(0, 'method not supported')
Expand All @@ -168,10 +175,11 @@ def _call(self, method, headers,
raise CloudFlareAPIError(0, 'JSON parse failed.')

if response_data['success'] is False:
code = response_data['errors'][0]['code']
message = response_data['errors'][0]['message']
if self.logger:
self.logger.debug("response_data error: %d %s" % (response_data['errors'][0]['code'],
response_data['errors'][0]['message']))
raise CloudFlareAPIError(response_data['errors'][0]['code'], response_data['errors'][0]['message'])
self.logger.debug("response_data error: %d %s" % (code, message))
raise CloudFlareAPIError(code, message)

return response_data['result']

Expand All @@ -181,8 +189,6 @@ class _unused(object):
def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=None):
""" CloudFlare v4 API"""

#if self.logger:
# self.logger.debug("_unused %s,%s,%s" % (str(base), str(api_call_part1), str(api_call_part2)))
self.base = base
self.api_call_part1 = api_call_part1
self.api_call_part2 = api_call_part2
Expand All @@ -194,8 +200,6 @@ class _client_noauth(object):
def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=None):
""" CloudFlare v4 API"""

#if self.logger:
# self.logger.debug("_client_noauth %s,%s,%s" % (str(base), str(api_call_part1), str(api_call_part2)))
self.base = base
self.api_call_part1 = api_call_part1
self.api_call_part2 = api_call_part2
Expand All @@ -204,16 +208,20 @@ def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=Non
def get(self, identifier1=None, identifier2=None, params=None, data=None):
""" CloudFlare v4 API"""

return self.base._call_with_no_auth('GET', self.api_call_part1, self.api_call_part2, self.api_call_part3, identifier1, identifier2, params, data)
return self.base._call_with_no_auth('GET',
self.api_call_part1,
self.api_call_part2,
self.api_call_part3,
identifier1,
identifier2,
params, data)

class _client_with_auth(object):
""" CloudFlare v4 API"""

def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=None):
""" CloudFlare v4 API"""

#if self.logger:
# self.logger.debug("_client_with_auth %s,%s,%s" % (str(base), str(api_call_part1), str(api_call_part2)))
self.base = base
self.api_call_part1 = api_call_part1
self.api_call_part2 = api_call_part2
Expand All @@ -222,36 +230,64 @@ def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=Non
def get(self, identifier1=None, identifier2=None, params=None, data=None):
""" CloudFlare v4 API"""

return self.base._call_with_auth('GET', self.api_call_part1, self.api_call_part2, self.api_call_part3, identifier1, identifier2, params, data)
return self.base._call_with_auth('GET',
self.api_call_part1,
self.api_call_part2,
self.api_call_part3,
identifier1,
identifier2,
params, data)

def patch(self, identifier1=None, identifier2=None, params=None, data=None):
""" CloudFlare v4 API"""

return self.base._call_with_auth('PATCH', self.api_call_part1, self.api_call_part2, self.api_call_part3, identifier1, identifier2, params, data)
return self.base._call_with_auth('PATCH',
self.api_call_part1,
self.api_call_part2,
self.api_call_part3,
identifier1,
identifier2,
params, data)

def post(self, identifier1=None, identifier2=None, params=None, data=None):
""" CloudFlare v4 API"""

return self.base._call_with_auth('POST', self.api_call_part1, self.api_call_part2, self.api_call_part3, identifier1, identifier2, params, data)
return self.base._call_with_auth('POST',
self.api_call_part1,
self.api_call_part2,
self.api_call_part3,
identifier1,
identifier2,
params, data)

def put(self, identifier1=None, identifier2=None, params=None, data=None):
""" CloudFlare v4 API"""

return self.base._call_with_auth('PUT', self.api_call_part1, self.api_call_part2, self.api_call_part3, identifier1, identifier2, params, data)
return self.base._call_with_auth('PUT',
self.api_call_part1,
self.api_call_part2,
self.api_call_part3,
identifier1,
identifier2,
params, data)

def delete(self, identifier1=None, identifier2=None, params=None, data=None):
""" CloudFlare v4 API"""

return self.base._call_with_auth('DELETE', self.api_call_part1, self.api_call_part2, self.api_call_part3, identifier1, identifier2, params, data)
return self.base._call_with_auth('DELETE',
self.api_call_part1,
self.api_call_part2,
self.api_call_part3,
identifier1,
identifier2,
params, data)

class _client_with_cert_auth(object):
""" CloudFlare v4 API"""

def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=None):
""" CloudFlare v4 API"""

#if self.logger:
# self.logger.debug("_client_with_cert_auth %s,%s,%s" % (str(base), str(api_call_part1), str(api_call_part2)))
self.base = base
self.api_call_part1 = api_call_part1
self.api_call_part2 = api_call_part2
Expand All @@ -260,27 +296,57 @@ def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=Non
def get(self, identifier1=None, identifier2=None, params=None, data=None):
""" CloudFlare v4 API"""

return self.base._call_with_certauth('GET', self.api_call_part1, self.api_call_part2, self.api_call_part3, identifier1, identifier2, params, data)
return self.base._call_with_certauth('GET',
self.api_call_part1,
self.api_call_part2,
self.api_call_part3,
identifier1,
identifier2,
params, data)

def patch(self, identifier1=None, identifier2=None, params=None, data=None):
""" CloudFlare v4 API"""

return self.base._call_with_certauth('PATCH', self.api_call_part1, self.api_call_part2, self.api_call_part3, identifier1, identifier2, params, data)
return self.base._call_with_certauth('PATCH',
self.api_call_part1,
self.api_call_part2,
self.api_call_part3,
identifier1,
identifier2,
params, data)

def post(self, identifier1=None, identifier2=None, params=None, data=None):
""" CloudFlare v4 API"""

return self.base._call_with_certauth('POST', self.api_call_part1, self.api_call_part2, self.api_call_part3, identifier1, identifier2, params, data)
return self.base._call_with_certauth('POST',
self.api_call_part1,
self.api_call_part2,
self.api_call_part3,
identifier1,
identifier2,
params, data)

def put(self, identifier1=None, identifier2=None, params=None, data=None):
""" CloudFlare v4 API"""

return self.base._call_with_certauth('PUT', self.api_call_part1, self.api_call_part2, self.api_call_part3, identifier1, identifier2, params, data)
return self.base._call_with_certauth('PUT',
self.api_call_part1,
self.api_call_part2,
self.api_call_part3,
identifier1,
identifier2,
params, data)

def delete(self, identifier1=None, identifier2=None, params=None, data=None):
""" CloudFlare v4 API"""

return self.base._call_with_certauth('DELETE', self.api_call_part1, self.api_call_part2, self.api_call_part3, identifier1, identifier2, params, data)
return self.base._call_with_certauth('DELETE',
self.api_call_part1,
self.api_call_part2,
self.api_call_part3,
identifier1,
identifier2,
params, data)

def __init__(self, email=None, token=None, certtoken=None, debug=False):
""" CloudFlare v4 API"""
Expand Down

0 comments on commit 8168029

Please sign in to comment.