Skip to content

Commit

Permalink
add support for str_format to Double and Integer types as well
Browse files Browse the repository at this point in the history
  • Loading branch information
plq committed Jul 28, 2015
1 parent fbd1314 commit 2237d7b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions spyne/protocol/_outbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def unicode_to_unicode(self, cls, value, **_):
def decimal_to_string(self, cls, value, **_):
D(value) # sanity check
cls_attrs = self.get_cls_attrs(cls)

if cls_attrs.str_format is not None:
return cls_attrs.str_format.format(value)
elif cls_attrs.format is not None:
Expand All @@ -281,7 +282,9 @@ def double_to_string(self, cls, value, **_):
float(value) # sanity check
cls_attrs = self.get_cls_attrs(cls)

if cls_attrs.format is None:
if cls_attrs.str_format is not None:
return cls_attrs.str_format.format(value)
elif cls_attrs.format is None:
return repr(value)
else:
return cls_attrs.format % value
Expand All @@ -290,7 +293,9 @@ def integer_to_string(self, cls, value, **_):
int(value) # sanity check
cls_attrs = self.get_cls_attrs(cls)

if cls_attrs.format is None:
if cls_attrs.str_format is not None:
return cls_attrs.str_format.format(value)
elif cls_attrs.format is None:
return str(value)
else:
return cls_attrs.format % value
Expand Down

0 comments on commit 2237d7b

Please # to comment.