Skip to content

Commit 9d69029

Browse files
author
Doug Black
committed
whitespace fixes. one space in classes, else two
1 parent c019c80 commit 9d69029

File tree

13 files changed

+85
-189
lines changed

13 files changed

+85
-189
lines changed

flask_restful/__init__.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,11 @@ def _complete_url(self, url_part, registration_prefix):
120120
:param registration_prefix: The part of the url contributed by the
121121
blueprint. Generally speaking, BlueprintSetupState.url_prefix
122122
"""
123-
124-
parts = {'b' : registration_prefix,
125-
'a' : self.prefix,
126-
'e' : url_part}
123+
parts = {
124+
'b': registration_prefix,
125+
'a': self.prefix,
126+
'e': url_part
127+
}
127128
return ''.join(parts[key] for key in self.url_part_order if parts[key])
128129

129130
@staticmethod
@@ -230,7 +231,6 @@ def _should_use_fr_error_handler(self):
230231
# Werkzeug throws other kinds of exceptions, such as Redirect
231232
pass
232233

233-
234234
def _has_fr_route(self):
235235
"""Encapsulating the rules for whether the request was to a Flask endpoint"""
236236
# 404's, 405's, which might not have a url_rule
@@ -300,9 +300,10 @@ def handle_error(self, e):
300300
data["message"] = ""
301301

302302
data['message'] += 'You have requested this URI [' + request.path + \
303-
'] but did you mean ' + \
304-
' or '.join((rules[match]
305-
for match in close_matches)) + ' ?'
303+
'] but did you mean ' + \
304+
' or '.join((
305+
rules[match] for match in close_matches)
306+
) + ' ?'
306307

307308
resp = self.make_response(data, code)
308309

@@ -345,7 +346,6 @@ def add_resource(self, resource, *urls, **kwargs):
345346
else:
346347
self.resources.append((resource, urls, kwargs))
347348

348-
349349
def _register_view(self, app, resource, *urls, **kwargs):
350350
endpoint = kwargs.pop('endpoint', None) or resource.__name__.lower()
351351
self.endpoints.add(endpoint)
@@ -364,7 +364,6 @@ def _register_view(self, app, resource, *urls, **kwargs):
364364
for decorator in self.decorators:
365365
resource_func = decorator(resource_func)
366366

367-
368367
for url in urls:
369368
# If this Api has a blueprint
370369
if self.blueprint:
@@ -528,8 +527,8 @@ def make(cls):
528527
return [marshal(d, fields) for d in data]
529528

530529
items = ((k, marshal(data, v) if isinstance(v, dict)
531-
else make(v).output(k, data))
532-
for k, v in fields.items())
530+
else make(v).output(k, data))
531+
for k, v in fields.items())
533532
return OrderedDict(items)
534533

535534

flask_restful/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def __init__(self, endpoint, absolute=False, scheme=None):
229229
def output(self, key, obj):
230230
try:
231231
data = to_marshallable_type(obj)
232-
o = urlparse(url_for(self.endpoint, _external = self.absolute, **data))
232+
o = urlparse(url_for(self.endpoint, _external=self.absolute, **data))
233233
if self.absolute:
234234
scheme = self.scheme if self.scheme is not None else o.scheme
235235
return urlunparse((scheme, o.netloc, o.path, "", "", ""))

flask_restful/representations/json.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# function, used below.
88
settings = {}
99

10+
1011
def output_json(data, code, headers=None):
1112
"""Makes a Flask response with a JSON encoded body"""
1213

flask_restful/reqparse.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
import inspect
55
import six
66

7+
78
class Namespace(dict):
89
def __getattr__(self, name):
910
try:
1011
return self[name]
1112
except KeyError:
1213
raise AttributeError(name)
14+
1315
def __setattr__(self, name, value):
1416
self[name] = value
1517

@@ -24,6 +26,7 @@ def __setattr__(self, name, value):
2426

2527
text_type = lambda x: six.text_type(x)
2628

29+
2730
class Argument(object):
2831

2932
def __init__(self, name, default=None, dest=None, required=False,
@@ -155,7 +158,7 @@ def parse(self, request):
155158
_friendly_location.get(self.location, self.location)
156159
)
157160
else:
158-
friendly_locations = [_friendly_location.get(loc, loc) \
161+
friendly_locations = [_friendly_location.get(loc, loc)
159162
for loc in self.location]
160163
error_msg = u"Missing required parameter {0} in {1}".format(
161164
self.name,

flask_restful/utils/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from werkzeug.http import HTTP_STATUS_CODES
22

3+
34
def http_status_message(code):
45
"""Maps an HTTP status code to the textual status"""
56
return HTTP_STATUS_CODES.get(code, '')
67

8+
79
def error_data(code):
810
"""Constructs a dictionary with status and message for returning in an
911
error response"""

flask_restful/utils/cors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from flask import make_response, request, current_app
33
from functools import update_wrapper
44

5+
56
def crossdomain(origin=None, methods=None, headers=None,
67
max_age=21600, attach_to_all=True,
78
automatic_options=True):

flask_restful/utils/crypto.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,34 @@
22
from Crypto.Cipher import AES
33
from base64 import b64encode, b64decode
44

5+
56
__all__ = "encrypt", "decrypt"
67

78
BLOCK_SIZE = 16
89
INTERRUPT = b'\0' # something impossible to put in a string
910
PADDING = b'\1'
1011

12+
1113
def pad(data):
1214
return data + INTERRUPT + PADDING * (BLOCK_SIZE - (len(data) + 1) % BLOCK_SIZE)
1315

16+
1417
def strip(data):
1518
return data.rstrip(PADDING).rstrip(INTERRUPT)
1619

20+
1721
def create_cipher(key, seed):
1822
if len(seed) != 16:
1923
raise ValueError("Choose a seed of 16 bytes")
2024
if len(key) != 32:
2125
raise ValueError("Choose a key of 32 bytes")
2226
return AES.new(key, AES.MODE_CBC, seed)
2327

28+
2429
def encrypt(plaintext_data, key, seed):
2530
plaintext_data = pickle.dumps(plaintext_data, pickle.HIGHEST_PROTOCOL) # whatever you give me I need to be able to restitute it
2631
return b64encode(create_cipher(key, seed).encrypt(pad(plaintext_data)))
2732

33+
2834
def decrypt(encrypted_data, key, seed):
2935
return pickle.loads(strip(create_cipher(key, seed).decrypt(b64decode(encrypted_data))))

flask_restful/utils/ordereddict.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from UserDict import DictMixin
2424
import six
2525

26+
2627
class OrderedDict(dict, DictMixin):
2728

2829
#noinspection PyMissingConstructor
@@ -120,7 +121,7 @@ def __eq__(self, other):
120121
if isinstance(other, OrderedDict):
121122
if len(self) != len(other):
122123
return False
123-
for p, q in zip(self.items(), other.items()):
124+
for p, q in zip(self.items(), other.items()):
124125
if p != q:
125126
return False
126127
return True

0 commit comments

Comments
 (0)