module rss.rss_helper

Short summary

module pyrsslocal.rss.rss_helper

Various function to automate the collection of blog posts.

source on GitHub

Functions

function

truncated documentation

enumerate_post_from_rss

Parses a RSS stream.

enumerate_rss_merge

Merges many rss file or url.

rss_download_post_to_database

Downloads all posts from a list of blogs stored in a database by function rss_from_xml_to_database().

rss_from_xml_to_database

Parses a list of blogs stored in a XML file using Google Reader format, stores the results in a :epkg:`SQLite`

rss_run_server

Starts a server and open a browser on a page reading blog posts.

rss_update_run_server

Creates a database if it does not exists, add a table for blogs and posts, update the database, starts a server …

to_html

Produces a HTML.

to_rss

Converts something into RSS.

Documentation

Various function to automate the collection of blog posts.

source on GitHub

pyrsslocal.rss.rss_helper.enumerate_post_from_rss(content, rss_stream=None)

Parses a RSS stream.

Parameters:

contentRSS content

Returns:

list of BlogPost

source on GitHub

pyrsslocal.rss.rss_helper.enumerate_rss_merge(rss_urls, title='compilation', min_size=None)

Merges many rss file or url.

Parameters:
  • rss_urlsrss files or urls

  • title – title

  • min_size – fails if the downloaded file is below this size

Returns:

new RSS

source on GitHub

pyrsslocal.rss.rss_helper.rss_download_post_to_database(database='database_rss.db3', table_blog='blogs', table_post='posts', fLOG=None)

Downloads all posts from a list of blogs stored in a database by function rss_from_xml_to_database.

Parameters:
  • database – database file name (SQLite format)

  • table_blog – table name of the blogs

  • table_post – table name of the post

  • fLOG – logging function

Returns:

number of posts downloaded

source on GitHub

pyrsslocal.rss.rss_helper.rss_from_xml_to_database(file, database='database_rss.db3', table='blogs', fLOG=None)

Parses a list of blogs stored in a XML file using Google Reader format, stores the results in a :epkg:`SQLite` database.

Parameters:
  • file – (str) xml file containing the list of blogs, example:

  • database – database file (sqlite)

  • table – table name

  • fLOG – logging function

Returns:

number of stored blogs

The XML file should contain the following:

<outline text="XD blog"
        title="XD blog" type="rss"
        xmlUrl="http://www.xavierdupre.fr/blog/xdbrss.xml"
        htmlUrl="http://www.xavierdupre.fr/blog/xd_blog.html" />

The function does not check whether or not the blogs were already added to the database, they will be added a second time. If the table does not exist, it will be created.

source on GitHub

pyrsslocal.rss.rss_helper.rss_run_server(dbfile, port=8093, browser=None, period='today', server=None, thread=False, fLOG=None)

Starts a server and open a browser on a page reading blog posts.

Parameters:
  • dbfile – (str) sqllite database to create

  • port – the main page will be http://localhost:port/

  • browser – (str) to choose a different browser than the default one

  • period – (str) when opening the browser, it can show the results for last day or last week

  • server – to set up your own server

  • thread – to start the server in a separate thread

  • fLOG – logging function

You can read the blog post RSS Reader.

If browser is “none”, the browser is not started.

source on GitHub

pyrsslocal.rss.rss_helper.rss_update_run_server(dbfile, xml_blogs, port=8093, browser=None, period='today', server=None, thread=False, fLOG=None)

Creates a database if it does not exists, add a table for blogs and posts, update the database, starts a server and open a browser.

Parameters:
  • dbfile – (str) sqllite database to create

  • xml_blogs – (str) xml description of blogs (google format) (file or string)

  • port – the main page will be http://localhost:port/

  • browser – (str) to choose a different browser than the default one

  • period – (str) when opening the browser, it can show the results for last day or last week

  • server – to set up your own server

  • thread – to start the server in a separate thread

  • fLOG – logging function

Returns:

see rss_run_server

You can read the blog post pyhome3 RSS Reader.

source on GitHub

pyrsslocal.rss.rss_helper.to_html(items, template=None, title='BLOG', author='AUTHOR', keywords='blog,python', header='', rssfile='rssfile.xml', **context)

Produces a HTML.

Parameters:
  • items – list of blog post

  • template – template or None to get the default one

  • title – blog title

  • author – author

  • keywords – keywords

  • header – blog description

  • rssfile – file RSS

  • context – other information

Returns:

pages

source on GitHub

pyrsslocal.rss.rss_helper.to_rss(obj, link, description)

Converts something into RSS.

Parameters:
  • obj – object

  • link – link

  • description – description

Returns:

content

source on GitHub