# HG changeset patch # User Oscar Cortez # Date 1538683126 21600 # Thu Oct 04 13:58:46 2018 -0600 # Node ID e0735d34a20d39b8bb0fda8f09e2db2dd1d6904d # Parent 1ffa50cdc890fda335344ec0a757146cc848b816 Use single quotes instead of double quotes diff --git a/sendy/api.py b/sendy/api.py --- a/sendy/api.py +++ b/sendy/api.py @@ -8,86 +8,86 @@ class SendyAPI: - """ Class used to map to all Sendy API endpoints - """ + ''' Class used to map to all Sendy API endpoints + ''' def __init__(self, host, api_key=None, debug=False): self.host = host - if self.host[-1] != "/": - self.host = "{0}/".format(self.host) + if self.host[-1] != '/': + self.host = '{0}/'.format(self.host) self.api_key = api_key self.debug = debug subscribe = bind_api( - path="subscribe", + path='subscribe', allowed_param=[ - "list", - "email", - "name", - "country", - "ipaddress", - "referrer", - "gdpr", - "hp", + 'list', + 'email', + 'name', + 'country', + 'ipaddress', + 'referrer', + 'gdpr', + 'hp', ], - extra_param={"boolean": "true"}, - success_message="1", + extra_param={'boolean': 'true'}, + success_message='1', require_auth=False, - method="POST", + method='POST', ) unsubscribe = bind_api( - path="unsubscribe", - allowed_param=["list", "email"], - extra_param={"boolean": "true"}, - success_message="1", + path='unsubscribe', + allowed_param=['list', 'email'], + extra_param={'boolean': 'true'}, + success_message='1', require_auth=False, - method="POST", + method='POST', ) delete = bind_api( - path="api/subscribers/delete.php", - allowed_param=["list_id", "email"], - success_message="1", - method="POST", + path='api/subscribers/delete.php', + allowed_param=['list_id', 'email'], + success_message='1', + method='POST', ) subscription_status = bind_api( - path="api/subscribers/subscription-status.php", - allowed_param=["list_id", "email"], + path='api/subscribers/subscription-status.php', + allowed_param=['list_id', 'email'], success_message=[ - "Subscribed", - "Unsubscribed", - "Unconfirmed", - "Bounced", - "Soft bounced", - "Complained", + 'Subscribed', + 'Unsubscribed', + 'Unconfirmed', + 'Bounced', + 'Soft bounced', + 'Complained', ], - method="POST", + method='POST', ) subscriber_count = bind_api( - path="api/subscribers/active-subscriber-count.php", - allowed_param=["list_id"], + path='api/subscribers/active-subscriber-count.php', + allowed_param=['list_id'], success_message=int, - method="POST", + method='POST', ) create_campaign = bind_api( - path="api/campaigns/create.php", + path='api/campaigns/create.php', allowed_param=[ - "from_name", - "from_email", - "reply_to", - "title", - "subject", - "plain_text", - "html_text", - "list_ids", - "brand_id", - "query_string", - "send_campaign", + 'from_name', + 'from_email', + 'reply_to', + 'title', + 'subject', + 'plain_text', + 'html_text', + 'list_ids', + 'brand_id', + 'query_string', + 'send_campaign', ], - success_message=["Campaign created", "Campaign created and now sending"], - method="POST", + success_message=['Campaign created', 'Campaign created and now sending'], + method='POST', ) diff --git a/sendy/binder.py b/sendy/binder.py --- a/sendy/binder.py +++ b/sendy/binder.py @@ -24,25 +24,25 @@ if isinstance(value, str): value = unicode(value) if isinstance(value, unicode): - return value.decode("utf-8") + return value.decode('utf-8') return value def bind_api(**config): class APIMethod: - path = config["path"] - allowed_param = config.get("allowed_param", []) - method = config.get("method", "GET") - require_auth = config.get("require_auth", True) - success_status_code = config.get("success_status_code", 200) - success_message = config.get("success_message", None) - extra_param = config.get("extra_param", None) - fail_silently = config.get("fail_silently", True) + path = config['path'] + allowed_param = config.get('allowed_param', []) + method = config.get('method', 'GET') + require_auth = config.get('require_auth', True) + success_status_code = config.get('success_status_code', 200) + success_message = config.get('success_message', None) + extra_param = config.get('extra_param', None) + fail_silently = config.get('fail_silently', True) def __init__(self, api, args, kwargs): self.api = api - self.headers = kwargs.pop("headers", {}) - self.post_data = kwargs.pop("post_data", None) + self.headers = kwargs.pop('headers', {}) + self.post_data = kwargs.pop('post_data', None) self.build_parameters(args, kwargs) self.path = self.path.format(**self.parameters) # Sub any URL vars self.host = api.host @@ -59,14 +59,14 @@ try: self.parameters[self.allowed_param[idx]] = convert_to_utf8(arg) except IndexError: - raise ValueError("Too many parameters supplied!") + raise ValueError('Too many parameters supplied!') for k, arg in kwargs.items(): if arg is None: continue if k in self.parameters: raise ValueError( - "Multiple values for parameter {0} supplied!".format(k) + 'Multiple values for parameter {0} supplied!'.format(k) ) self.parameters[k] = convert_to_utf8(arg) @@ -75,7 +75,7 @@ self.parameters.update(self.extra_param) if self.require_auth and self.api.api_key is not None: - self.parameters["api_key"] = self.api.api_key + self.parameters['api_key'] = self.api.api_key def execute(self): # Build the request URL @@ -83,7 +83,7 @@ if self.api.debug: log.info( - "* Sending {0}: {1}\nHeaders: {2}\nData:{3}".format( + '* Sending {0}: {1}\nHeaders: {2}\nData:{3}'.format( self.method, url, self.headers, self.post_data ) )