mirror of
https://github.com/Unidata/python-awips.git
synced 2025-02-23 22:57:56 -05:00
six conditional for RequestConstraint types
This commit is contained in:
parent
96aa8266b9
commit
6e99c3cc44
1 changed files with 18 additions and 7 deletions
|
@ -11,6 +11,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import six
|
||||||
from dynamicserialize.dstypes.com.raytheon.uf.common.time import DataTime
|
from dynamicserialize.dstypes.com.raytheon.uf.common.time import DataTime
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,6 +209,16 @@ class RequestConstraint(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _stringify(value):
|
def _stringify(value):
|
||||||
|
if six.PY2:
|
||||||
|
if type(value) in {str, int, long, bool, float, unicode}:
|
||||||
|
return str(value)
|
||||||
|
else:
|
||||||
|
# Collections are not allowed; they are handled separately.
|
||||||
|
# Arbitrary objects are not allowed because the string
|
||||||
|
# representation may not be sufficient to reconstruct the object.
|
||||||
|
raise TypeError('Constraint values of type ' + repr(type(value)) +
|
||||||
|
'are not allowed')
|
||||||
|
else:
|
||||||
if isinstance(value, (str, int, long, float)):
|
if isinstance(value, (str, int, long, float)):
|
||||||
return str(value)
|
return str(value)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue