Source code for marshmallow_configparser.fields

from marshmallow import fields

from .compatibility import is_marshmallow3


[docs]class ConfigParserFieldMixin(object): if is_marshmallow3(): def __init__(self, *args, **kwargs): self._data_key = None super(ConfigParserFieldMixin, self).__init__(*args, **kwargs) @property def data_key(self): return self._data_key @data_key.setter def data_key(self, value): if value: self._data_key = self._section + '.' + str(value) else: self._data_key = value else: def __init__(self, *args, **kwargs): self._load_from = None self._dump_to = None super(ConfigParserFieldMixin, self).__init__(*args, **kwargs) @property def load_from(self): return self._load_from @load_from.setter def load_from(self, value): if value: self._load_from = self._section + '.' + str(value) else: self._load_from = value @property def dump_to(self): return self._dump_to @dump_to.setter def dump_to(self, value): if value: self._dump_to = self._section + '.' + str(value) else: self._dump_to = value
[docs]class Dict(ConfigParserFieldMixin, fields.Dict): def __init__(self, section, *args, **kwargs): self._section = section super(Dict, self).__init__(*args, **kwargs)
[docs]class List(ConfigParserFieldMixin, fields.List): def __init__(self, section, *args, **kwargs): self._section = section super(List, self).__init__(*args, **kwargs)
[docs]class String(ConfigParserFieldMixin, fields.String): def __init__(self, section, *args, **kwargs): self._section = section super(String, self).__init__(*args, **kwargs)
[docs]class UUID(ConfigParserFieldMixin, fields.UUID): def __init__(self, section, *args, **kwargs): self._section = section super(UUID, self).__init__(*args, **kwargs)
[docs]class Number(ConfigParserFieldMixin, fields.Number): def __init__(self, section, *args, **kwargs): self._section = section super(Number, self).__init__(*args, **kwargs)
[docs]class Integer(ConfigParserFieldMixin, fields.Integer): def __init__(self, section, *args, **kwargs): self._section = section super(Integer, self).__init__(*args, **kwargs)
[docs]class Decimal(ConfigParserFieldMixin, fields.Decimal): def __init__(self, section, *args, **kwargs): self._section = section super(Decimal, self).__init__(*args, **kwargs)
[docs]class Boolean(ConfigParserFieldMixin, fields.Boolean): def __init__(self, section, *args, **kwargs): self._section = section super(Boolean, self).__init__(*args, **kwargs)
[docs]class FormattedString(ConfigParserFieldMixin, fields.FormattedString): def __init__(self, section, *args, **kwargs): self._section = section super(FormattedString, self).__init__(*args, **kwargs)
[docs]class Float(ConfigParserFieldMixin, fields.Float): def __init__(self, section, *args, **kwargs): self._section = section super(Float, self).__init__(*args, **kwargs)
[docs]class DateTime(ConfigParserFieldMixin, fields.DateTime): def __init__(self, section, *args, **kwargs): self._section = section super(DateTime, self).__init__(*args, **kwargs)
[docs]class LocalDateTime(ConfigParserFieldMixin, fields.LocalDateTime): def __init__(self, section, *args, **kwargs): self._section = section super(LocalDateTime, self).__init__(*args, **kwargs)
[docs]class Time(ConfigParserFieldMixin, fields.Time): def __init__(self, section, *args, **kwargs): self._section = section super(Time, self).__init__(*args, **kwargs)
[docs]class Date(ConfigParserFieldMixin, fields.Date): def __init__(self, section, *args, **kwargs): self._section = section super(Date, self).__init__(*args, **kwargs)
[docs]class TimeDelta(ConfigParserFieldMixin, fields.TimeDelta): def __init__(self, section, *args, **kwargs): self._section = section super(TimeDelta, self).__init__(*args, **kwargs)
[docs]class Url(ConfigParserFieldMixin, fields.Url): def __init__(self, section, *args, **kwargs): self._section = section super(Url, self).__init__(*args, **kwargs)
[docs]class Email(ConfigParserFieldMixin, fields.Email): def __init__(self, section, *args, **kwargs): self._section = section super(Email, self).__init__(*args, **kwargs)
[docs]class Method(ConfigParserFieldMixin, fields.Method): def __init__(self, section, *args, **kwargs): self._section = section super(Method, self).__init__(*args, **kwargs)
[docs]class Function(ConfigParserFieldMixin, fields.Function): def __init__(self, section, *args, **kwargs): self._section = section super(Function, self).__init__(*args, **kwargs)