API Documentation¶
This page document all the public stuff you can use from PyOPML. For usage documentation, see Usage.
Classes¶
- class opml.OpmlDocument(**kvargs)¶
Class that holds an OPML 2.0 document.
- Parameters:
title (str) – Title of the document
date_created (datetime.datetime) – When the document was created
date_modified (datetime.datetime) – When the document was last modified
owner_name (str) – Owner of the document
owner_email (str) – Email address of the owner of the document
owner_id (str) – Unique URL that contains information that allows a human reader to communicate with the author of the document via email or other means. It also may be used to identify the author
expansion_state (list) – List of line numbers that are expanded. The line numbers in the list tell you which headlines to expand. The order is important. For each element in the list, X, starting at the first summit, navigate flatdown X times and expand. Repeat for each element in the list
vert_scroll_state (int) – Which line of the outline is displayed on the top line of the window. This number is calculated with the expansion state already applied
window_top (int) – Pixel location of the top edge of the window
window_left (int) – Pixel location of the left edge of the window
window_bottom (int) – Pixel location of the bottom edge of the window
window_right (int) – Pixel location of the right edge of the window
- Variables:
title (str) – Title of the document
date_created (datetime.datetime) – When the document was created
date_modified (datetime.datetime) – When the document was last modified
owner_name (str) – Owner of the document
owner_email (str) – Email address of the owner of the document
owner_id (str) – Unique URL that contains information that allows a human reader to communicate with the author of the document via email or other means. It also may be used to identify the author
expansion_state (list) – List of line numbers that are expanded. The line numbers in the list tell you which headlines to expand. The order is important. For each element in the list, X, starting at the first summit, navigate flatdown X times and expand. Repeat for each element in the list
vert_scroll_state (int) – Which line of the outline is displayed on the top line of the window. This number is calculated with the expansion state already applied
window_top (int) – Pixel location of the top edge of the window
window_left (int) – Pixel location of the left edge of the window
window_bottom (int) – Pixel location of the bottom edge of the window
window_right (int) – Pixel location of the right edge of the window
- add_include(text, url, is_comment=False, is_breakpoint=False, created=None, categories=[])¶
Create a new outline of type “include”, append it to this object’s outlines and return it.
- Parameters:
text (str) – Text of the outline
url (str) – An URL to an OPML document
is_comment (bool) – Whether the outline is commented or not
is_breakpoint (bool) – Whether a breakpoint is set on this outline
created (datetime.datetime) – Date-time that the outline node was created
categories (list) – A list of RSS 2.0 categories. To represent a “tag”, the category string should contain no slashes
- Return type:
- add_link(text, url, is_comment=False, is_breakpoint=False, created=None, categories=[])¶
Create a new outline of type “link”, append it to this object’s outlines and return it.
- Parameters:
text (str) – Text of the outline
url (str) – An URL to a web page
is_comment (bool) – Whether the outline is commented or not
is_breakpoint (bool) – Whether a breakpoint is set on this outline
created (datetime.datetime) – Date-time that the outline node was created
categories (list) – A list of RSS 2.0 categories. To represent a “tag”, the category string should contain no slashes
- Return type:
- add_outline(text, **kvargs)¶
Create a new outline, append it to this object’s outlines and return it.
- Parameters:
text (str) – Text of the outline
type (str) – How the other attributes of the outline are interpreted. One of
rss
,link
orinclude
is_comment (bool) – Whether the outline is commented or not
is_breakpoint (bool) – Whether a breakpoint is set on this outline
created (datetime.datetime) – Date-time that the outline node was created
xml_url (str) – URL to the feed when
type
isrss
description (str) – Top-level description element from the feed (if this outline is part of a subscription list)
html_url (str) – Top-level link element from the feed (if this outline is part of a subscription list)
language (str) – Top-level language element from the feed (if this outline is part of a subscription list)
title (str) – Top-level title element from the feed (if this outline is part of a subscription list)
version (str) – RSS version when
type
isrss
. One ofRSS
,RSS1
,RSS2
orscriptingNews
url (str) – An URL to a web page when
type
islink
categories (list) – A list of RSS 2.0 categories. To represent a “tag”, the category string should contain no slashes
- Return type:
- add_rss(text, xml_url, description=None, html_url=None, language=None, title=None, version=None, is_comment=False, is_breakpoint=False, created=None, categories=[])¶
Create a new outline of type “rss”, append it to this object’s outlines and return it.
- Parameters:
text (str) – Text of the outline
xml_url (str) – URL to the feed
description (str) – Top-level description element from the feed (if this outline is part of a subscription list)
html_url (str) – Top-level link element from the feed (if this outline is part of a subscription list)
language (str) – Top-level language element from the feed (if this outline is part of a subscription list)
title (str) – Top-level title element from the feed (if this outline is part of a subscription list)
version (str) – RSS version. One of
RSS
,RSS1
,RSS2
orscriptingNews
is_comment (bool) – Whether the outline is commented or not
is_breakpoint (bool) – Whether a breakpoint is set on this outline
created (datetime.datetime) – Date-time that the outline node was created
categories (list) – A list of RSS 2.0 categories. To represent a “tag”, the category string should contain no slashes
- Return type:
- dump(fp, pretty=False, encoding='UTF-8')¶
Serialize this document to a filename or file-like object.
- Raises:
- Parameters:
- dumps(pretty=False, encoding='UTF-8')¶
Serialize this document to a string.
- Raises:
- Parameters:
- Return type:
- classmethod load(fp)¶
Unserialize OPML 2.0 data from a filename or file-like object.
- Raises:
- Parameters:
fp – A filename or file-like object
- Return type:
- class opml.OpmlOutline(text, **kvargs)¶
Class that holds an OPML 2.0 outline element.
- Parameters:
text (str) – Text of the outline
type (str) – How the other attributes of the outline are interpreted. One of
rss
,link
orinclude
is_comment (bool) – Whether the outline is commented or not
is_breakpoint (bool) – Whether a breakpoint is set on this outline
created (datetime.datetime) – Date-time that the outline node was created
xml_url (str) – URL to the feed when
type
isrss
description (str) – Top-level description element from the feed (if this outline is part of a subscription list)
html_url (str) – Top-level link element from the feed (if this outline is part of a subscription list)
language (str) – Top-level language element from the feed (if this outline is part of a subscription list)
title (str) – Top-level title element from the feed (if this outline is part of a subscription list)
version (str) – RSS version when
type
isrss
. One ofRSS
,RSS1
,RSS2
orscriptingNews
url (str) – An URL to a web page when
type
islink
categories (list) – A list of RSS 2.0 categories. To represent a “tag”, the category string should contain no slashes
- Variables:
text (str) – Text of the outline
type (str) – How the other attributes of the outline are interpreted. One of
rss
,link
orinclude
is_comment (bool) – Whether the outline is commented or not
is_breakpoint (bool) – Whether a breakpoint is set on this outline
created (datetime.datetime) – Date-time that the outline node was created
xml_url (str) – URL to the feed when
type
isrss
description (str) – Top-level description element from the feed (if this outline is part of a subscription list)
html_url (str) – Top-level link element from the feed (if this outline is part of a subscription list)
language (str) – Top-level language element from the feed (if this outline is part of a subscription list)
title (str) – Top-level title element from the feed (if this outline is part of a subscription list)
version (str) – RSS version when
type
isrss
. One ofRSS
,RSS1
,RSS2
orscriptingNews
url (str) – An URL to a web page when
type
islink
categories – A list of RSS 2.0 categories. To represent a “tag”, the category string should contain no slashes
- add_include(text, url, is_comment=False, is_breakpoint=False, created=None, categories=[])¶
Create a new outline of type “include”, append it to this object’s outlines and return it.
- Parameters:
text (str) – Text of the outline
url (str) – An URL to an OPML document
is_comment (bool) – Whether the outline is commented or not
is_breakpoint (bool) – Whether a breakpoint is set on this outline
created (datetime.datetime) – Date-time that the outline node was created
categories (list) – A list of RSS 2.0 categories. To represent a “tag”, the category string should contain no slashes
- Return type:
- add_link(text, url, is_comment=False, is_breakpoint=False, created=None, categories=[])¶
Create a new outline of type “link”, append it to this object’s outlines and return it.
- Parameters:
text (str) – Text of the outline
url (str) – An URL to a web page
is_comment (bool) – Whether the outline is commented or not
is_breakpoint (bool) – Whether a breakpoint is set on this outline
created (datetime.datetime) – Date-time that the outline node was created
categories (list) – A list of RSS 2.0 categories. To represent a “tag”, the category string should contain no slashes
- Return type:
- add_outline(text, **kvargs)¶
Create a new outline, append it to this object’s outlines and return it.
- Parameters:
text (str) – Text of the outline
type (str) – How the other attributes of the outline are interpreted. One of
rss
,link
orinclude
is_comment (bool) – Whether the outline is commented or not
is_breakpoint (bool) – Whether a breakpoint is set on this outline
created (datetime.datetime) – Date-time that the outline node was created
xml_url (str) – URL to the feed when
type
isrss
description (str) – Top-level description element from the feed (if this outline is part of a subscription list)
html_url (str) – Top-level link element from the feed (if this outline is part of a subscription list)
language (str) – Top-level language element from the feed (if this outline is part of a subscription list)
title (str) – Top-level title element from the feed (if this outline is part of a subscription list)
version (str) – RSS version when
type
isrss
. One ofRSS
,RSS1
,RSS2
orscriptingNews
url (str) – An URL to a web page when
type
islink
categories (list) – A list of RSS 2.0 categories. To represent a “tag”, the category string should contain no slashes
- Return type:
- add_rss(text, xml_url, description=None, html_url=None, language=None, title=None, version=None, is_comment=False, is_breakpoint=False, created=None, categories=[])¶
Create a new outline of type “rss”, append it to this object’s outlines and return it.
- Parameters:
text (str) – Text of the outline
xml_url (str) – URL to the feed
description (str) – Top-level description element from the feed (if this outline is part of a subscription list)
html_url (str) – Top-level link element from the feed (if this outline is part of a subscription list)
language (str) – Top-level language element from the feed (if this outline is part of a subscription list)
title (str) – Top-level title element from the feed (if this outline is part of a subscription list)
version (str) – RSS version. One of
RSS
,RSS1
,RSS2
orscriptingNews
is_comment (bool) – Whether the outline is commented or not
is_breakpoint (bool) – Whether a breakpoint is set on this outline
created (datetime.datetime) – Date-time that the outline node was created
categories (list) – A list of RSS 2.0 categories. To represent a “tag”, the category string should contain no slashes
- Return type:
Exceptions¶
PyOPML may raise its own exceptions under specific circumstances in addition of the lxml ones.
- exception opml.exceptions.OpmlReadError¶
This exception is thrown when a blocking OPML-related read error is encountered.
- exception opml.exceptions.OpmlWriteError¶
This exception is thrown when a blocking OPML-related write error is encountered.