asphalt.feedreader.api

class asphalt.feedreader.api.FeedReader

Bases: object

Interface for feed readers.

Variables:
  • entry_discovered (Signal[EntryEvent]) – a signal dispatched when a resource has been published in this context
  • metadata_changed (Signal[MetadataEvent]) – a signal dispatched when the feed metadata has been changed
  • url (str) – the feed URL
classmethod can_parse(document, content_type)

Determine if this reader class is suitable for parsing the given document as a feed.

This method is only used for autodetection of feed type by create_feed() (ie. when the feed parser has not been specified). Autodetection is skipped when the feed parser has been explicitly given.

Parameters:
  • document (str) – document loaded from the feed URL
  • content_type (str) – MIME type of the loaded document
Return type:

Optional[str]

Returns:

the reason why this class cannot parse the given document, or None if it can parse it

metadata

Return the feed’s metadata.

Return type:FeedMetadata
start(ctx)

Initialize the feed.

This should do the following:

  • Claim any required resources (including the state store if defined)
  • Load the state from the store (if a store was defined)
  • Conditionally start a timer task that calls update() on the configured intervals
Return type:Awaitable[None]
update()

Read the feed from the source and dispatch any events necessary.

Return type:Awaitable[None]
class asphalt.feedreader.api.FeedStateStore

Bases: object

Interface for feed state stores.

load_state(state_id)

Load the named state from the store.

Return type:Awaitable[Optional[Dict[str, Any]]]
Returns:the requested state, or None if it is not found
start(ctx)

Initialize the store.

Return type:Awaitable[None]
store_state(state_id, state)

Add or update the indicated state in the store.

Return type:Awaitable[None]