Convert value to a string based on JSON Schema type. See http://tools.ietf.org/html/draft-zyp-json-schema-03 for more details on JSON Schema. Args: value: any, the value to convert schema_type: string, the type that value should be interpreted as Returns: A strin
(value, schema_type)
| 740 | |
| 741 | |
| 742 | def _cast(value, schema_type): |
| 743 | """Convert value to a string based on JSON Schema type. |
| 744 | |
| 745 | See http://tools.ietf.org/html/draft-zyp-json-schema-03 for more details on |
| 746 | JSON Schema. |
| 747 | |
| 748 | Args: |
| 749 | value: any, the value to convert |
| 750 | schema_type: string, the type that value should be interpreted as |
| 751 | |
| 752 | Returns: |
| 753 | A string representation of 'value' based on the schema_type. |
| 754 | """ |
| 755 | if schema_type == "string": |
| 756 | if type(value) == type("") or type(value) == type(""): |
| 757 | return value |
| 758 | else: |
| 759 | return str(value) |
| 760 | elif schema_type == "integer": |
| 761 | return str(int(value)) |
| 762 | elif schema_type == "number": |
| 763 | return str(float(value)) |
| 764 | elif schema_type == "boolean": |
| 765 | return str(bool(value)).lower() |
| 766 | else: |
| 767 | if type(value) == type("") or type(value) == type(""): |
| 768 | return value |
| 769 | else: |
| 770 | return str(value) |
| 771 | |
| 772 | |
| 773 | def _media_size_to_long(maxSize): |
no outgoing calls
no test coverage detected
searching dependent graphs…