Skip to content

adjunct.opml

A simple, nay, simplistic! OPML parser.

OpmlError

Bases: Exception

Raised when there's a problem parsing an OPML document.

Outline

Bases: list

An outline.

Contains the element's attributes in the attrs member and the outlines nested within it as elements.

Parameters:

Name Type Description Default
attrs dict[str, str] | None

any attributes on the element

None
items Sequence[Outline]

any child outlines nested within this outline

()
root bool

is this outline the root outline?

False

Attributes:

Name Type Description
attrs dict[str, str]

any attributes on the element

root bool

is this outline the root outline?

parse(fh)

Parse an OPML file from the given file object.

Parameters:

Name Type Description Default
fh TextIO

a file-like object containing an OPML document

required

Returns:

Type Description
Outline | None

An outline if the document could be parsed, otherwise None.

parse_string(s)

Parse an OPML document from the given string.

Parameters:

Name Type Description Default
s str

an OPML document.

required

Returns:

Type Description
Outline | None

An outline if the document could be parsed, otherwise None.

parse_timestamp(ts)

Convert an RFC 2822 timestamp (as used in OPML) to a UTC DateTime object.

Parameters:

Name Type Description Default
ts str

an RFC 2822 timestamp

required

Returns:

Type Description
datetime | None

A timezone-aware datetime, or None if the timestamp could not be parsed.