8000 manual pep8 · shopro/wp-api-python@04a34d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 04a34d2

Browse files
author
derwentx
committed
manual pep8
1 parent b92854d commit 04a34d2

File tree

6 files changed

+180
-94
lines changed

6 files changed

+180
-94
lines changed

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
VERSION = ""
1313
with open("wordpress/__init__.py", "r") as fd:
1414
VERSION = re.search(
15-
r"^__version__\s*=\s*['\"]([^\"]*)['\"]", fd.read(), re.MULTILINE).group(1)
15+
r"^__version__\s*=\s*['\"]([^\"]*)['\"]", fd.read(), re.MULTILINE
16+
).group(1)
1617

1718
if not VERSION:
1819
raise RuntimeError("Cannot find version information")

tests.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import functools
33
import logging
44
import pdb
5-
import platform
65
import random
76
import sys
87
import traceback
@@ -542,7 +541,10 @@ def setUp(self):
542541
)
543542

544543
self.twitter_method = "POST"
545-
self.twitter_target_url = "https://api.twitter.com/1/statuses/update.json?include_entities=true"
544+
self.twitter_target_url = (
545+
"https://api.twitter.com/1/statuses/update.json?"
546+
"include_entities=true"
547+
)
546548
self.twitter_params_raw = [
547549
("status", "Hello Ladies + Gentlemen, a signed OAuth request!"),
548550
("include_entities", "true"),
@@ -617,7 +619,10 @@ def setUp(self):
617619
('oauth_version', self.lexev_version),
618620
]
619621
self.lexev_request_signature = b"iPdHNIu4NGOjuXZ+YCdPWaRwvJY="
620-
self.lexev_resource_url = 'https://api.bitbucket.org/1.0/repositories/st4lk/django-articles-transmeta/branches'
622+
self.lexev_resource_url = (
623+
'https://api.bitbucket.org/1.0/repositories/st4lk/'
624+
'django-articles-transmeta/branches'
625+
)
621626

622627
def test_get_sign_key(self):
623628
self.assertEqual(
@@ -1122,7 +1127,7 @@ def test_APIPostBadData(self):
11221127
}
11231128

11241129
with self.assertRaises(UserWarning):
1125-
response = self.wpapi.post('posts', data)
1130+
self.wpapi.post('posts', data)
11261131

11271132

11281133
class WPAPITestCasesBasic(WPAPITestCasesBase):

wordpress/api.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import logging
1111
from json import dumps as jsonencode
1212

13-
from six import binary_type, text_type
14-
from wordpress.auth import BasicAuth, OAuth, OAuth_3Leg, NoAuth
13+
from six import text_type
14+
from wordpress.auth import BasicAuth, NoAuth, OAuth, OAuth_3Leg
1515
from wordpress.helpers import StrUtils, UrlUtils
1616
from wordpress.transport import API_Requests_Wrapper
1717

@@ -38,7 +38,10 @@ def __init__(self, url, consumer_key, consumer_secret, **kwargs):
3838
elif kwargs.get('no_auth'):
3939
auth_class = NoAuth
4040

41-
if kwargs.get('version', '').startswith('wc') and kwargs.get('oauth1a_3leg'):
41+
if (
42+
kwargs.get('version', '').startswith('wc')
43+
and kwargs.get('oauth1a_3leg')
44+
):
4245
self.logger.warn(
4346
"WooCommerce JSON Api does not seem to support 3leg")
4447

@@ -106,9 +109,13 @@ def request_post_mortem(self, response=None):
106109

107110
try_hostname_mismatch = False
108111

109-
if isinstance(response_json, dict) and ('code' in response_json or 'message' in response_json):
112+
if (
113+
isinstance(response_json, dict)
114+
and ('code' in response_json or 'message' in response_json)
115+
):
110116
reason = u" - ".join([
111-
text_type(response_json.get(key)) for key in ['code', 'message', 'data']
117+
text_type(response_json.get(key))
118+
for key in ['code', 'message', 'data']
112119
if key in response_json
113120
])
114121
code = text_type(response_json.get('code'))
@@ -126,16 +133,19 @@ def request_post_mortem(self, response=None):
126133
remedy = "Try enabling query_string_auth"
127134
else:
128135
remedy = (
129-
"This error is super generic and can be caused by just "
130-
"about anything. Here are some things to try: \n"
136+
"This error is super generic and can be caused by "
137+
"just about anything. Here are some things to try: \n"
131138
" - Check that the account which as assigned to your "
132139
"oAuth creds has the correct access level\n"
133140
" - Enable logging and check for error messages in "
134141
"wp-content and wp-content/uploads/wc-logs\n"
135-
" - Check that your query string parameters are valid\n"
136-
" - Make sure your server is not messing with authentication headers\n"
142+
" - Check that your query string parameters are "
143+
"valid\n"
144+
" - Make sure your server is not messing with "
145+
"authentication headers\n"
137146
" - Try a different endpoint\n"
138-
" - Try enabling HTTPS and using basic authentication\n"
147+
" - Try enabling HTTPS and using basic "
148+
"authentication\n"
139149
)
140150

141151
elif code == 'woocommerce_rest_authentication_error':
@@ -169,7 +179,10 @@ def request_post_mortem(self, response=None):
169179
header_url = StrUtils.eviscerate(header_url, '/')
170180
remedy = "try changing url to %s" % header_url
171181

172-
msg = u"API call to %s returned \nCODE: %s\nRESPONSE:%s \nHEADERS: %s\nREQ_BODY:%s" % (
182+
msg = (
183+
u"API call to %s returned \nCODE: "
184+
"%s\nRESPONSE:%s \nHEADERS: %s\nREQ_BODY:%s"
185+
) % (
173186
request_url,
174187
text_type(response.status_code),
175188
UrlUtils.beautify_response(response),

0 commit comments

Comments
 (0)
0