Previous topic

libearth — The shared common library for Earth Reader apps

Next topic

libearth.compat — Compatibility layer

This Page

libearth.codecs — Common codecs

This module provides commonly used codecs to parse RSS-related standard formats.

class libearth.codecs.Boolean(true='true', false='false', default_value=None)

Codec to interpret boolean representation in strings e.g. 'true', 'no', and encode bool values back to string.

  • true (str, tuple) – text to parse as True. 'true' by default
  • false (str, tuple) – text to parse as False. 'false' by default
  • default_value (bool) – default value when it cannot be parsed
class libearth.codecs.Enum(values)

Codec that accepts only predefined fixed types of values:

gender = Enum(['male', 'female'])

Actually it doesn’t any encoding nor decoding, but it simply validates all values from XML and Python both.

Note that values have to consist of only strings.

Parameters:values (collections.Iterable) – any iterable that yields all possible values
class libearth.codecs.Integer

Codec to encode and decode integer numbers.

class libearth.codecs.Rfc3339(prefer_utc=False)

Codec to store datetime.datetime values to RFC 3339 format.

Parameters:prefer_utc (bool) – normalize all timezones to UTC. False by default
PATTERN = <_sre.SRE_Pattern object at 0x364bc70>

(re.RegexObject) The regular expression pattern that matches to valid RFC 3339 date time string.

class libearth.codecs.Rfc822

Codec to encode/decode datetime.datetime values to/from RFC 822 format.

Fork me on GitHub