Skip to content

oldas.articles

Provides a class for getting article data.

Direction module-attribute

Direction = Literal['ltr', 'rtl']

Possible values for the summary direction.

Alternate dataclass

Alternate(href: str, mime_type: str)

Holds details of an alternate for an Article.

href instance-attribute

href: str

The URL for the alternate.

mime_type instance-attribute

mime_type: str

The MIME type of the alternate.

from_json classmethod

from_json(data: RawData) -> Alternate

Load the alternate data from JSON data.

Parameters:

Name Type Description Default

data

RawData

The data to load the alternate data from.

required

Returns:

Type Description
Alternate

The alternates.

Alternates

Alternates(data: Iterable[OldData] | None = None)

Bases: OldList[Alternate]

Holds a list of alternates

Used within an Article.

Article dataclass

Article(
    id: str,
    title: str,
    published: datetime,
    updated: datetime,
    author: str,
    summary: Summary,
    categories: list[State | str],
    origin: Origin,
    alternate: Alternates,
)

Holds details about an article.

alternate instance-attribute

alternate: Alternates

Alternates for the article.

author instance-attribute

author: str

The author of the article.

categories instance-attribute

categories: list[State | str]

The list of categories associated with this article.

html_url property

html_url: str | None

The best guess at the HTML URL for the article.

id instance-attribute

id: str

The ID of the article.

is_fresh property

is_fresh: bool

Is the article considered fresh?

is_read property

is_read: bool

Has this article been read?

is_stale property

is_stale: bool

Is the article considered stale?

is_unread property

is_unread: bool

Is the article still unread?

is_updated property

is_updated: bool

Does the article look like it's been updated?

origin instance-attribute

origin: Origin

The origin of the article.

published instance-attribute

published: datetime

The time when the article was published.

summary instance-attribute

summary: Summary

The summary of the article.

title instance-attribute

title: str

The title of the article.

updated instance-attribute

updated: datetime

The time when the article was updated.

clean_categories staticmethod

clean_categories(
    categories: Iterable[str],
) -> list[State | str]

Clean up a collection of categories.

Parameters:

Name Type Description Default

categories

Iterable[str]

The categories to clean up.

required

Returns:

Type Description
list[State | str]

The cleaned categories.

The incoming list of categories will simply be a list of strings, but each of them may refer to a folder or a state, etc. This method will clean the list, turning relevant values into their specific type.

Note

For the moment only values matching a State will be turned into their related type.

from_json classmethod

from_json(data: RawData) -> Article

Load the article from JSON data.

Parameters:

Name Type Description Default

data

RawData

The data to load the article from.

required

Returns:

Type Description
Article

The article.

mark_read async

mark_read(session: Session) -> bool

Mark the article as read.

Parameters:

Name Type Description Default

session

Session

The API session object.

required

Returns:

Type Description
bool

True if the request to mark as read worked,

bool

False if not.

mark_unread async

mark_unread(session: Session) -> bool

Mark the article as unread.

Parameters:

Name Type Description Default

session

Session

The API session object.

required

Returns:

Type Description
bool

True if the request to mark as unread worked,

bool

False if not.

Articles

Articles(data: Iterable[OldData] | None = None)

Bases: OldList[Article]

Loads and holds a full list of articles.

full_id staticmethod

full_id(article: str | Article) -> str

Get the full ID for a given article.

Parameters:

Name Type Description Default

article

str | Article

The article to get the full ID for.

required

Returns:

Type Description
str

The full ID for the article.

stream async classmethod

stream(
    session: Session,
    stream: str | Subscription | Folder = "",
    **filters: Any,
) -> AsyncIterator[Article]

Load articles from a given stream.

Parameters:

Name Type Description Default

session

Session

The API session object.

required

stream

str | Subscription | Folder

The stream identifier to load from.

''

filters

Any

Any other filters to pass to the API.

{}

Yields:

Type Description
AsyncIterator[Article]

The articles matching the request.

stream_new_since async classmethod

stream_new_since(
    session: Session,
    since: datetime,
    stream: str | Subscription | Folder = "",
    **filters: Any,
) -> AsyncIterator[Article]

Stream all articles newer than a given time.

Parameters:

Name Type Description Default

session

Session

The API session object.

required

since

datetime

Time from which to load articles.

required

stream

str | Subscription | Folder

The stream identifier to stream from.

''

filters

Any

Any other filters to pass to the API.

{}

Yields:

Type Description
AsyncIterator[Article]

The articles matching the request.

Origin dataclass

Origin(stream_id: str | None, title: str, html_url: str)

The origin details for an Article.

html_url instance-attribute

html_url: str

The URL of the HTML of the origin of the article.

stream_id instance-attribute

stream_id: str | None

The stream ID for the article's origin.

title instance-attribute

title: str

The title of the origin of the article.

from_json classmethod

from_json(data: RawData) -> Origin

Load the origin from JSON data.

Parameters:

Name Type Description Default

data

RawData

The data to load the origin from.

required

Returns:

Type Description
Origin

The origin data.

Summary dataclass

Summary(direction: Direction, content: str)

The summary details for an Article.

content instance-attribute

content: str

The content of the summary.

direction instance-attribute

direction: Direction

The direction for the text in the summary.

from_json classmethod

from_json(data: RawData) -> Summary

Load the summary from JSON data.

Parameters:

Name Type Description Default

data

RawData

The data to load the summary from.

required

Returns:

Type Description
Summary

The summary.