From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 3737858973 for ; Wed, 27 Jan 2016 23:16:03 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D188121C09E; Wed, 27 Jan 2016 23:15:50 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3424D21C09E for ; Wed, 27 Jan 2016 23:15:45 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3E2C2340A26 for ; Wed, 27 Jan 2016 23:15:39 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2B9311250 for ; Wed, 27 Jan 2016 23:15:34 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1453934665.20b86b331841e540b9fca8b22c0e615ed1fb7c77.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/metadata/, pym/repoman/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/modules/scan/metadata/__init__.py pym/repoman/modules/scan/metadata/unused.py pym/repoman/scanner.py X-VCS-Directories: pym/repoman/ pym/repoman/modules/scan/metadata/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 20b86b331841e540b9fca8b22c0e615ed1fb7c77 X-VCS-Branch: repoman Date: Wed, 27 Jan 2016 23:15:34 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 1c3da80b-75a5-484a-b2c9-9880ee1611ee X-Archives-Hash: 30c8c59530e87958219fb37ec4b99faf commit: 20b86b331841e540b9fca8b22c0e615ed1fb7c77 Author: Brian Dolbec gentoo org> AuthorDate: Mon Jan 4 08:37:22 2016 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Wed Jan 27 22:44:25 2016 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=20b86b33 repoman: Create a metadata UnusedCheck and final pkg checks Create a plugin loop for any final pkg checks. Create the one plugin for the unused use-descriptions in mteadata.xml pym/repoman/modules/scan/metadata/__init__.py | 9 +++++++ pym/repoman/modules/scan/metadata/unused.py | 32 ++++++++++++++++++++++++ pym/repoman/scanner.py | 36 ++++++++++++++++++++------- 3 files changed, 68 insertions(+), 9 deletions(-) diff --git a/pym/repoman/modules/scan/metadata/__init__.py b/pym/repoman/modules/scan/metadata/__init__.py index 4f376e1..f619764 100644 --- a/pym/repoman/modules/scan/metadata/__init__.py +++ b/pym/repoman/modules/scan/metadata/__init__.py @@ -55,6 +55,15 @@ module_spec = { 'func_desc': { }, }, + 'unused-metadata': { + 'name': "unused", + 'sourcefile': "unused", + 'class': "UnusedCheck", + 'description': doc, + 'functions': ['check'], + 'func_desc': { + }, + }, } } diff --git a/pym/repoman/modules/scan/metadata/unused.py b/pym/repoman/modules/scan/metadata/unused.py new file mode 100644 index 0000000..5eb6716 --- /dev/null +++ b/pym/repoman/modules/scan/metadata/unused.py @@ -0,0 +1,32 @@ + + +class UnusedCheck(object): + + def __init__(self, **kwargs): + self.qatracker = kwargs.get('qatracker') + + def check(self, **kwargs): + xpkg = kwargs.get('xpkg') + muselist = kwargs.get('muselist') + used_useflags = kwargs.get('used_useflags') + # check if there are unused local USE-descriptions in metadata.xml + # (unless there are any invalids, to avoid noise) + if kwargs.get('allvalid'): + for myflag in muselist.difference(used_useflags): + self.qatracker.add_error( + "metadata.warning", + "%s/metadata.xml: unused local USE-description: '%s'" + % (xpkg, myflag)) + return {'continue': False} + + @property + def runInPkgs(self): + return (False, []) + + @property + def runInEbuilds(self): + return (False, []) + + @property + def runInFinal(self): + return (True, [self.check]) diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py index 4472f88..e486282 100644 --- a/pym/repoman/scanner.py +++ b/pym/repoman/scanner.py @@ -272,7 +272,6 @@ class Scanner(object): def _scan_ebuilds(self, ebuildlist, dynamic_data): - xpkg = dynamic_data['xpkg'] # detect unused local USE-descriptions dynamic_data['used_useflags'] = set() @@ -320,11 +319,30 @@ class Scanner(object): if y_ebuild_continue: continue - # check if there are unused local USE-descriptions in metadata.xml - # (unless there are any invalids, to avoid noise) - if dynamic_data['allvalid']: - for myflag in dynamic_data['muselist'].difference(dynamic_data['used_useflags']): - self.qatracker.add_error( - "metadata.warning", - "%s/metadata.xml: unused local USE-description: '%s'" - % (xpkg, myflag)) + # Final checks + # initialize per pkg plugin final checks here + # need to set it up for ==> self.modules_list or some other ordered list + xpkg_complete = False + for mod in [('unused', 'UnusedChecks')]: + if mod[0]: + mod_class = MODULE_CONTROLLER.get_class(mod[0]) + print("Initializing class name:", mod_class.__name__) + self.modules[mod[1]] = mod_class(**self.kwargs) + print("scan_ebuilds final checks: module:", mod[1]) + do_it, functions = self.modules[mod[1]].runInFinal + # print("do_it", do_it, "functions", functions) + if do_it: + for func in functions: + print("\tRunning function:", func) + rdata = func(**dynamic_data) + if rdata.get('continue', False): + xpkg_complete = True + print("\t>>> Continuing") + break + #print("rdata:", rdata) + dynamic_data.update(rdata) + #print("dynamic_data", dynamic_data) + + if xpkg_complete: + return + return