Previous topic

libearth.stage — Staging updates and transactions

Next topic

libearth.tz — Basic timezone implementations

This Page

libearth.subscribe — Subscription list

Maintain the subscription list using OPML format, which is de facto standard for the purpose.

Inheritance diagram of Category, Subscription, SubscriptionList, Head, Body

class libearth.subscribe.Body(_parent=None, **attributes)

Bases: libearth.schema.Element

Represent body element of OPML document.

children

(collections.MutableSequence) Child Outline objects.

class libearth.subscribe.Category(_parent=None, **attributes)

Bases: libearth.subscribe.Outline, libearth.subscribe.SubscriptionSet

Category which groups Subscription objects or other Category objects. It implements collections.MutableSet protocol.

children

(collections.MutableSequence) The list of child Outline elements. It’s for internal use.

class libearth.subscribe.CommaSeparatedList

Bases: libearth.schema.Codec

Encode strings e.g. ['a', 'b', 'c'] into a comma-separated list e.g. 'a,b,c', and decode it back to a Python list. Whitespaces between commas are ignored.

>>> codec = CommaSeparatedList()
>>> codec.encode(['technology', 'business'])
'technology,business'
>>> codec.decode('technology, business')
['technology', 'business']
class libearth.subscribe.Head(_parent=None, **attributes)

Bases: libearth.schema.Element

Represent head element of OPML document.

owner_email

(str) The owner’s email.

owner_name

(str) The owner’s name.

owner_uri

(str) The owner’s website url.

title

(str) The title of the subscription list.

class libearth.subscribe.Outline(_parent=None, **attributes)

Bases: libearth.schema.Element

Represent outline element of OPML document.

created_at

(datetime.datetime) The created time.

deleted

(bool) Whether it is deleted (archived) or not.

New in version 0.3.0.

deleted_at

(datetime.datetime) The archived time, if deleted ever. It could be None as well if it’s never deleted. Note that it doesn’t have enough information about whether it’s actually deleted or not. For that you have to use deleted property instead.

New in version 0.3.0.

label

(str) The human-readable text of the outline.

type

(str) Internally-used type identifier.

class libearth.subscribe.Subscription(_parent=None, **attributes)

Bases: libearth.subscribe.Outline

Subscription which holds referring feed_uri.

feed_id

(str) The feed identifier to be used for lookup. It’s intended to be SHA1 digest of Feed.id value (which is UTF-8 encoded).

feed_uri

(str) The feed url.

alternate_uri

(str) The web page url.

icon_uri

(str) Optional favicon url.

New in version 0.3.0.

class libearth.subscribe.SubscriptionList(_parent=None, **kwargs)

Bases: libearth.session.MergeableDocumentElement, libearth.subscribe.SubscriptionSet

The set (exactly, tree) of subscriptions. It consists of Subscriptions and Category objects for grouping. It implements collections.MutableSet protocol.

owner

(Person) The owner of the subscription list.

title

(str) The title of the subscription list.

version

(distutils.version.StrictVersion) The OPML version number.

class libearth.subscribe.SubscriptionSet

Bases: _abcoll.MutableSet

Mixin for SubscriptionList and Category, both can group Subscription object and other Category objects, to implement collections.MutableSet protocol.

categories

(collections.Mapping) Label to Category instance mapping.

children
(collections.MutableSequence) Child Outline
objects.

Note

Every subclass of SubscriptionSet has to override children property to implement details.

contains(outline, recursively=False)

Determine whether the set contains the given outline. If recursively is False (which is by default) it works in the same way to in operator.

Parameters:
  • outline (Outline) – the subscription or category to find
  • recursively (bool) – if it’s True find the outline in the whole tree, or if False find it in only its direct children. False by default
Returns:

True if the set (or tree) contains the given outline, or False

Return type:

bool

New in version 0.2.0.

subscribe(feed, icon_uri=None)

Add a subscription from Feed instance. Prefer this method over add() method.

Parameters:
  • feed (Feed) – feed to subscribe
  • icon_uri (str) – optional favicon url of the feed
Returns:

the created subscription object

Return type:

Subscription

New in version 0.3.0: Optional icon_url parameter was added.

subscriptions

(collections.Set) The subset which consists of only Subscription instances.

Fork me on GitHub