(input_str, si, ei)
| 211 | return [_deserialize_input(param, 0, len(param)-1) for param in input_str.split(WRAPPED_PARAMETER_DELIMITER)] |
| 212 | |
| 213 | def _deserialize_input(input_str, si, ei): |
| 214 | if ei - si < 1: |
| 215 | #Handle all of the cases where you can have valid empty input. |
| 216 | if ei == si: |
| 217 | if input_str[si] == TYPE_CHARARRAY: |
| 218 | return u"" |
| 219 | elif input_str[si] == TYPE_BYTEARRAY: |
| 220 | return bytearray("") |
| 221 | else: |
| 222 | raise Exception("Got input type flag %s, but no data to go with it.\nInput string: %s\nSlice: %s" % (input_str[si], input_str, input_str[si:ei+1])) |
| 223 | else: |
| 224 | raise Exception("Start index %d greater than end index %d.\nInput string: %s\n, Slice: %s" % (si, ei, input_str[si:ei+1])) |
| 225 | |
| 226 | first = input_str[si] |
| 227 | schema = input_str[si+1] if first == PRE_WRAP_DELIM else first |
| 228 | |
| 229 | if schema == NULL_BYTE: |
| 230 | return None |
| 231 | elif schema == TYPE_TUPLE or schema == TYPE_MAP or schema == TYPE_BAG: |
| 232 | return _deserialize_collection(input_str, schema, si+3, ei-3) |
| 233 | elif schema == TYPE_CHARARRAY: |
| 234 | return unicode(input_str[si+1:ei+1], 'utf-8') |
| 235 | elif schema == TYPE_BYTEARRAY: |
| 236 | return bytearray(input_str[si+1:ei+1]) |
| 237 | elif schema == TYPE_INTEGER: |
| 238 | return int(input_str[si+1:ei+1]) |
| 239 | elif schema == TYPE_LONG or schema == TYPE_BIGINTEGER: |
| 240 | return long(input_str[si+1:ei+1]) |
| 241 | elif schema == TYPE_FLOAT or schema == TYPE_DOUBLE or schema == TYPE_BIGDECIMAL: |
| 242 | return float(input_str[si+1:ei+1]) |
| 243 | elif schema == TYPE_BOOLEAN: |
| 244 | return input_str[si+1:ei+1] == "true" |
| 245 | elif schema == TYPE_DATETIME: |
| 246 | #Format is "yyyy-MM-ddTHH:mm:ss.SSS+00:00" or "2013-08-23T18:14:03.123+ZZ" |
| 247 | if USE_DATEUTIL: |
| 248 | return parser.parse(input_str[si+1:ei+1]) |
| 249 | else: |
| 250 | #Try to use datetime even though it doesn't handle time zones properly, |
| 251 | #We only use the first 3 microsecond digits and drop time zone (first 23 characters) |
| 252 | return datetime.strptime(input_str[si+1:si+24], "%Y-%m-%dT%H:%M:%S.%f") |
| 253 | else: |
| 254 | raise Exception("Can't determine type of input: %s" % input_str[si:ei+1]) |
| 255 | |
| 256 | def _deserialize_collection(input_str, return_type, si, ei): |
| 257 | list_result = [] |
no test coverage detected