portage.news module

class portage.news.DisplayInstalledRestriction(atom, news_format)

Bases: portage.news.DisplayRestriction

An Installation restriction where a particular item shall only be displayed if the user has that item installed.

checkRestriction(**kwargs)
isValid()
class portage.news.DisplayKeywordRestriction(keyword, news_format)

Bases: portage.news.DisplayRestriction

A keyword restriction where a particular item shall only be displayed if the user is running a specific keyword.

checkRestriction(**kwargs)
isValid()
class portage.news.DisplayProfileRestriction(profile, news_format)

Bases: portage.news.DisplayRestriction

A profile restriction where a particular item shall only be displayed if the user is running a specific profile.

checkRestriction(**kwargs)
isValid()
class portage.news.DisplayRestriction

Bases: object

A base restriction object representing a restriction of display. news items may have ‘relevancy restrictions’ preventing them from being important. In this case we need a manner of figuring out if a particular item is relevant or not. If any of it’s restrictions are met, then it is displayed

checkRestriction(**kwargs)
isValid()
class portage.news.NewsItem(path, name)

Bases: object

This class encapsulates a GLEP 42 style news item. It’s purpose is to wrap parsing of these news items such that portage can determine whether a particular item is ‘relevant’ or not. This requires parsing the item and determining ‘relevancy restrictions’; these include “Display if Installed” or “display if arch: x86” and so forth.

Creation of a news item involves passing in the path to the particular news item.

isRelevant(vardb, config, profile)

This function takes a dict of keyword arguments; one should pass in any objects need to do to lookups (like what keywords we are on, what profile, and a vardb so we can look at installed packages). Each restriction will pluck out the items that are required for it to match or raise a ValueError exception if the required object is not present.

Restrictions of the form Display-X are OR’d with like-restrictions; otherwise restrictions are AND’d. any_match is the ORing and all_match is the ANDing.

isValid()
parse()
class portage.news.NewsManager(portdb, vardb, news_path, unread_path, language_id='en')

Bases: object

This object manages GLEP 42 style news items. It will cache news items that have previously shown up and notify users when there are relevant news items that apply to their packages that the user has not previously read.

Creating a news manager requires: root - typically ${ROOT} see man make.conf and man emerge for details news_path - path to news items; usually $REPODIR/metadata/news unread_path - path to the news.repoid.unread file; this helps us track news items

_news_dir(repoid)
_skip_filename(repoid)
_unread_filename(repoid)
getUnreadItems(repoid, update=False)

Determine if there are unread relevant items in news.repoid.unread. If there are unread items return their number. If update is specified, updateNewsItems( repoid ) will be called to check for new items.

updateItems(repoid)

Figure out which news items from NEWS_PATH are both unread and relevant to the user (according to the GLEP 42 standards of relevancy). Then add these items into the news.repoid.unread file.

portage.news.count_unread_news(portdb, vardb, repos=None, update=True)

Returns a dictionary mapping repos to integer counts of unread news items. By default, this will scan all repos and check for new items that have appeared since the last scan.

Parameters
  • portdb (pordbapi) – an ebuild database

  • vardb (vardbapi) – an installed package database

  • repos (list or None) – names of repos to scan (None means to scan all available repos)

  • update (boolean) – check for new items (default is True)

Return type

dict

Returns

dictionary mapping repos to integer counts of unread news items

portage.news.display_news_notifications(news_counts)

Display a notification for unread news items, using a dictionary mapping repos to integer counts, like that returned from count_unread_news().