示例#1
0
class MyConverter(object):
    class_provides(IRepresentationConverter)

    @classmethod
    def convert_from_representation(cls, representation_value, value_type):  # pylint: disable=W0613
        return representation_value

    @classmethod
    def convert_to_representation(cls, value, value_type):  # pylint: disable=W0613
        return value
示例#2
0
class NoOpConverter(object):
    class_provides(IRepresentationConverter)

    @classmethod
    def from_representation(cls, value):
        return value

    @classmethod
    def to_representation(cls, value):
        return value
示例#3
0
class BooleanConverter(object):
    class_provides(IRepresentationConverter)

    @classmethod
    def from_representation(cls, value):
        if value is None:
            py_val = None
        else:
            py_val = False if value == 'false' else True
        return py_val

    @classmethod
    def to_representation(cls, value):
        return str(value).lower()
示例#4
0
class DateTimeConverter(object):
    class_provides(IRepresentationConverter)

    @classmethod
    def from_representation(cls, value):
        if value is None:
            py_val = None
        else:
            py_val = iso8601.parse_date(value)
        return py_val

    @classmethod
    def to_representation(cls, value):
        return rfc3339(value)
示例#5
0
class CsvIntConverter(object):
    """
    Specialized converter coping with the CSV reader's unfortunate habit
    to convert integers to floats upon reading.
    """
    class_provides(IRepresentationConverter)

    @classmethod
    def from_representation(cls, value):
        if isinstance(value, float):
            value = int(value)
        return value

    @classmethod
    def to_representation(cls, value):
        return value
示例#6
0
class ZipMime(object):
    class_provides(IZipMime)
    mime_type_string = 'application/zip'
    file_extension = '.zip'
示例#7
0
class XlsMime(object):
    class_provides(IXlsMime)
    mime_type_string = 'application/vnd.xls'
    file_extension = '.xls'
示例#8
0
class TextPlainMime(object):
    class_provides(ITextPlainMime)
    mime_type_string = 'text/plain'
    file_extension = '.txt'
示例#9
0
class JsonMime(object):
    class_provides(IJsonMime)
    mime_type_string = 'application/json'
    representer_name = 'json'
    file_extension = '.json'
示例#10
0
class CsvMime(object):
    class_provides(ICsvMime)
    mime_type_string = 'application/csv'
    representer_name = 'csv'
    file_extension = '.csv'
示例#11
0
class XmlMime(object):
    class_provides(IXmlMime)
    mime_type_string = 'application/xml'
    representer_name = 'xml'
    file_extension = '.xml'
示例#12
0
class AtomServiceMime(AtomMime):
    class_provides(IAtomServiceMime)
    mime_type_string = 'application/atomsvc+xml'
示例#13
0
class AtomEntryMime(AtomMime):
    class_provides(IAtomEntryMime)
    mime_type_string = 'application/atom+xml;type=entry'
示例#14
0
class AtomFeedMime(AtomMime):
    class_provides(IAtomFeedMime)
    mime_type_string = 'application/atom+xml;type=feed'
示例#15
0
class AtomMime(object):
    class_provides(IAtomMime)
    mime_type_string = 'application/atom+xml'
    representer_name = 'atom'
    file_extension = '.atom'
示例#16
0
class MimeWithDuplicateFileExtensionString(object):
    class_provides(IMime)
    mime_type_string = 'application/xmlish'
    representer_name = 'myxml'
    file_extension = '.xml'
示例#17
0
class HtmlMime(object):
    class_provides(IHtmlMime)
    mime_type_string = 'text/html'
    file_extension = '.html'