Now it should be fully compatible with python 2.7 and 3.4

This commit is contained in:
Matan Goldman 2016-02-07 18:05:07 +02:00
parent 59fde5f072
commit 2ddbfa8218
6 changed files with 18 additions and 12 deletions

View File

@ -97,8 +97,9 @@ class {{classname}}(object):
))
elif isinstance(value, dict):
result[attr] = dict(map(
lambda k, v: (k, v.to_dict()) if hasattr(v, "to_dict") else (k, v),
value.iteritems()
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()

View File

@ -108,8 +108,9 @@ class Category(object):
))
elif isinstance(value, dict):
result[attr] = dict(map(
lambda k, v: (k, v.to_dict()) if hasattr(v, "to_dict") else (k, v),
value.iteritems()
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()

View File

@ -214,8 +214,9 @@ class Order(object):
))
elif isinstance(value, dict):
result[attr] = dict(map(
lambda k, v: (k, v.to_dict()) if hasattr(v, "to_dict") else (k, v),
value.iteritems()
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()

View File

@ -214,8 +214,9 @@ class Pet(object):
))
elif isinstance(value, dict):
result[attr] = dict(map(
lambda k, v: (k, v.to_dict()) if hasattr(v, "to_dict") else (k, v),
value.iteritems()
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()

View File

@ -108,8 +108,9 @@ class Tag(object):
))
elif isinstance(value, dict):
result[attr] = dict(map(
lambda k, v: (k, v.to_dict()) if hasattr(v, "to_dict") else (k, v),
value.iteritems()
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()

View File

@ -258,8 +258,9 @@ class User(object):
))
elif isinstance(value, dict):
result[attr] = dict(map(
lambda k, v: (k, v.to_dict()) if hasattr(v, "to_dict") else (k, v),
value.iteritems()
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()