Skip to content

Commit 6ca00e2

Browse files
committed
Merge pull request #20 from h1ppo/master
python 2to3 changes
2 parents 1a6d136 + 10fe6ef commit 6ca00e2

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

flask_restful_swagger/swagger.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import inspect
44
import functools
55
import re
6-
import flask_restful
76
from flask_restful_swagger import registry, registered, api_spec_endpoint
87
from flask_restful_swagger import html
98

@@ -106,8 +105,8 @@ def extract_operations(resource, path_arguments=[]):
106105
if '__swagger_attr' in method_impl.__dict__:
107106
# This method was annotated with @swagger.operation
108107
decorators = method_impl.__dict__['__swagger_attr']
109-
for att_name, att_value in decorators.items():
110-
if isinstance(att_value, (basestring, int, list)):
108+
for att_name, att_value in list(decorators.items()):
109+
if isinstance(att_value, (str, int, list)):
111110
if att_name == 'parameters':
112111
op['parameters'] = merge_parameter_list(op['parameters'], att_value)
113112
else:
@@ -119,7 +118,7 @@ def extract_operations(resource, path_arguments=[]):
119118

120119
def merge_parameter_list(base, override):
121120
base = list(base)
122-
names = map(lambda x: x['name'], base)
121+
names = [x['name'] for x in base]
123122
for o in override:
124123
if o['name'] in names:
125124
for n, i in enumerate(base):
@@ -192,7 +191,7 @@ def add_model(model_class):
192191
# of this attribute
193192
properties = model['properties'] = {}
194193
nested = model_class.nested() if isinstance(model_class, _Nested) else {}
195-
for field_name, field_type in model_class.resource_fields.iteritems():
194+
for field_name, field_type in list(model_class.resource_fields.items()):
196195
nested_type = nested[field_name] if field_name in nested else None
197196
properties[field_name] = deduce_swagger_type(field_type, nested_type)
198197
elif '__init__' in dir(model_class):
@@ -206,7 +205,7 @@ def add_model(model_class):
206205
defaults = {}
207206
required = model['required'] = []
208207
if argspec.defaults:
209-
defaults = zip(argspec.args[-len(argspec.defaults):], argspec.defaults)
208+
defaults = list(zip(argspec.args[-len(argspec.defaults):], argspec.defaults))
210209
properties = model['properties'] = {}
211210
for arg in argspec.args[:-len(defaults)]:
212211
required.append(arg)
@@ -223,7 +222,7 @@ def deduce_swagger_type(python_type_or_object, nested_type=None):
223222
predicate = issubclass
224223
else:
225224
predicate = isinstance
226-
if predicate(python_type_or_object, (basestring,
225+
if predicate(python_type_or_object, (str,
227226
fields.String,
228227
fields.FormattedString,
229228
fields.Url,
@@ -258,7 +257,7 @@ def deduce_swagger_type_flat(python_type_or_object, nested_type=None):
258257
predicate = issubclass
259258
else:
260259
predicate = isinstance
261-
if predicate(python_type_or_object, (basestring,
260+
if predicate(python_type_or_object, (str,
262261
fields.String,
263262
fields.FormattedString,
264263
fields.Url)):
@@ -312,4 +311,4 @@ def split_arg(arg):
312311
'dataType': spl[0],
313312
'paramType': 'path'}
314313

315-
return map(split_arg, args)
314+
return list(map(split_arg, args))

0 commit comments

Comments
 (0)