From 5c33fbc34acca869ec9fe80c4f470edfe560d9a0 Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Sat, 10 Mar 2012 16:14:09 -0800 Subject: Add news reporting capability to meet GLEP 42 requirement. --- etc/layman.cfg | 26 ++++++++++++++++++++++++++ layman/api.py | 8 ++++++++ layman/config.py | 1 + 3 files changed, 35 insertions(+) diff --git a/etc/layman.cfg b/etc/layman.cfg index 1b74f96..7f7baab 100644 --- a/etc/layman.cfg +++ b/etc/layman.cfg @@ -80,6 +80,32 @@ nocheck : yes # #umask : 0022 +#----------------------------------------------------------- +# News reporting settings +# +# This is for when layman is adding/syncing overlays. +# It is required for GLEP 42. +# Currently there are 3 possible values: +# portage, pkgcore, custom +# +# portage: uses portage to report news only from overlay(s) in +# versions >=2.2.0_alpha72 or >=2.1.10.32 +# or all repositories (including gentoo) for older portage versions. +# pkgcore: does not yet support glep 42, no news is reported +# custom: requires that you provide a suitable python function +# to 'custom_news_func' using the api's config.set_option() +# or define the python package to import it from in custom_news_pkg + +news_reporter: portage + +#----------------------------------------------------------- +# News reporting custom function setting +# +# the pkg name that contains the layman_news_function() +# for it to import and use. It must be found in PYTHONPATH + +#custom_news_pkg : + #----------------------------------------------------------- # Command overrides # diff --git a/layman/api.py b/layman/api.py index 4ff62dd..3f33a42 100755 --- a/layman/api.py +++ b/layman/api.py @@ -562,9 +562,17 @@ class LaymanAPI(object): settings, trees, mtimedb = load_emerge_config() display_news_notification( trees[settings["ROOT"]]["root_config"], {}) + elif self.config['news_reporter'] == 'custom': + if self.config['custom_news_func'] is None: + _temp = __import__( + 'custom_news_pkg', globals(), locals(), + ['layman_news_func'], -1) + self.config['custom_news_func'] = _temp.custom_news_func self.config['custom_news_func'](repos) + elif self.config['news_reporter'] == 'pkgcore': + # pkgcore is not yet capable return except Exception as err: msg = "update_news() failed running %s news reporter function\n" +\ diff --git a/layman/config.py b/layman/config.py index c245853..0541d92 100644 --- a/layman/config.py +++ b/layman/config.py @@ -96,6 +96,7 @@ class BareConfig(object): 'proxy' : '', 'umask' : '0022', 'news_reporter': 'portage', + 'custom_news_pkg': '', 'overlays' : 'http://www.gentoo.org/proj/en/overlays/repositories.xml', 'overlay_defs': '%(configdir)s/overlays', -- cgit v1.2.3-1-g7c22