news API reference

News.MAX_NEWS: Maximum number of news returned while reading news directory (int), 5

Utilities to create some news for BioMAJ

class biomajmanager.news.News(news_dir=None, config=None, max_news=None)[source]

Bases: object

Class for creating news to be displayed for BioMAJ

__init__(news_dir=None, config=None, max_news=None)[source]

Initiate object building

Parameters:
  • news_dir (str) – Path to directory containing templates
  • config (configParser) – Configuration object
  • max_news (int) – Number of news to get when displaying news (default News.MAX_NEWS)
Raises:
  • SystemExit – If ‘news_dir’ is not a directory
  • SystemExit – If ‘NEWS’ section is not defined in manager.properties
  • SystemExit – If ‘news.dir’ is not set in manager.properties
__weakref__

list of weak references to the object (if defined)

get_news(news_dir=None, reverse=True)[source]

Get the news to be displayed from the specific news.dir directory

Parameters:
  • news_dir (str) – Path to news directory
  • reverse (bool) – Reverse list of news files, default True
Returns:

news_files, list of news files found into ‘news’ directory

Return type:

list

Raises:
  • SystemExit – If path ‘news_dir’ does not exist
  • SystemExit – If ‘news_dir’ not set
class biomajmanager.news.RSS(rss_file=None, *args, **kwargs)[source]

Bases: biomajmanager.news.News

Class for generating RSS feed from news files

__init__(rss_file=None, *args, **kwargs)[source]

Initiate object building

generate_rss(rss_file=None, data=None)[source]

Generate RSS file from news

Parameters:
  • rss_file (str) – Path to file rss.xml
  • data (dict data['news'] = { ... }) – Data to create RSS from
Returns:

Boolean

Return type:

bool

Raises:
  • SystemExit – If ‘news’ key is not found in ‘data’ dict
  • SystemExit – If rss file cannot be opened