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
class NoOpConverter(object): class_provides(IRepresentationConverter) @classmethod def from_representation(cls, value): return value @classmethod def to_representation(cls, value): return value
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()
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)
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
class ZipMime(object): class_provides(IZipMime) mime_type_string = 'application/zip' file_extension = '.zip'
class XlsMime(object): class_provides(IXlsMime) mime_type_string = 'application/vnd.xls' file_extension = '.xls'
class TextPlainMime(object): class_provides(ITextPlainMime) mime_type_string = 'text/plain' file_extension = '.txt'
class JsonMime(object): class_provides(IJsonMime) mime_type_string = 'application/json' representer_name = 'json' file_extension = '.json'
class CsvMime(object): class_provides(ICsvMime) mime_type_string = 'application/csv' representer_name = 'csv' file_extension = '.csv'
class XmlMime(object): class_provides(IXmlMime) mime_type_string = 'application/xml' representer_name = 'xml' file_extension = '.xml'
class AtomServiceMime(AtomMime): class_provides(IAtomServiceMime) mime_type_string = 'application/atomsvc+xml'
class AtomEntryMime(AtomMime): class_provides(IAtomEntryMime) mime_type_string = 'application/atom+xml;type=entry'
class AtomFeedMime(AtomMime): class_provides(IAtomFeedMime) mime_type_string = 'application/atom+xml;type=feed'
class AtomMime(object): class_provides(IAtomMime) mime_type_string = 'application/atom+xml' representer_name = 'atom' file_extension = '.atom'
class MimeWithDuplicateFileExtensionString(object): class_provides(IMime) mime_type_string = 'application/xmlish' representer_name = 'myxml' file_extension = '.xml'
class HtmlMime(object): class_provides(IHtmlMime) mime_type_string = 'text/html' file_extension = '.html'