Base Models

class whalesong.models.Base64Field(name=None, alias=None, getter=None, setter=None, read_only=False, default=None, doc=None)

Bases: dirty_models.fields.BytesField

Byte field which allows to set base64 string data.

convert_value(value)

Converts value to field type

class whalesong.models.DateTimeField(parse_format=None, default_timezone=None, force_timezone=False, **kwargs)

Bases: dirty_models.fields.DateTimeField

Date time field that allow timestamps in microseconds.

Parameters:
  • parse_format (str or dict) –

    String format to cast string to datetime. It could be an string format or a dict with two keys:

    • parser key to set how string must be parsed. It could be a callable.
    • formatter key to set how datetime must be formatted. It could be a callable.
  • default_timezone (datetime.tzinfo) – Default timezone to use when value does not have one.
  • force_timezone – If it is True value will be converted to timezone defined on default_timezone parameter. It default_timezone is not defined it is ignored.
Type:

bool

convert_value(value)

Converts value to field type

Model whalesong.models.BaseModel(data=None, flat=False, *args, **kwargs)

Bases: dirty_models.models.BaseModel

Base model which convert field name from underscore-style to camelCase-style automatically.

property id: str [READ ONLY]

Unique identifier.

class whalesong.models.ModelFormatterIter(model)

Bases: dirty_models.utils.ModelFormatterIter

format_field(field, value)
class whalesong.models.JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Bases: dirty_models.utils.JSONEncoder

Constructor for JSONEncoder, with sensible defaults.

If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, float or None. If skipkeys is True, such items are simply skipped.

If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If ensure_ascii is false, the output can contain non-ASCII characters.

If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an OverflowError). Otherwise, no such check takes place.

If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.

If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.

If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.

If specified, separators should be an (item_separator, key_separator) tuple. The default is (‘, ‘, ‘: ‘) if indent is None and (‘,’, ‘: ‘) otherwise. To get the most compact JSON representation, you should specify (‘,’, ‘:’) to eliminate whitespace.

If specified, default is a function that gets called for objects that can’t otherwise be serialized. It should return a JSON encodable version of the object or raise a TypeError.

default_model_iter

alias of ModelFormatterIter