mirror of
https://github.com/Unidata/python-awips.git
synced 2025-02-23 14: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 six
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.time import DataTime
|
||||
|
||||
|
||||
|
@ -208,14 +209,24 @@ class RequestConstraint(object):
|
|||
|
||||
@staticmethod
|
||||
def _stringify(value):
|
||||
if isinstance(value, (str, int, long, float)):
|
||||
return str(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:
|
||||
# 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')
|
||||
if isinstance(value, (str, int, long, float)):
|
||||
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')
|
||||
|
||||
@classmethod
|
||||
def _constructIn(cls, constraintType, constraintValue):
|
||||
|
|
Loading…
Add table
Reference in a new issue