commit: 02395b0dea31388acbc5ae58ebc5d90f64b2d10a Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> AuthorDate: Mon Jan 4 08:37:22 2016 +0000 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> CommitDate: Thu Jan 21 02:53:44 2016 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=02395b0d
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 | 8 ++++++ pym/repoman/modules/scan/metadata/unused.py | 32 ++++++++++++++++++++++++ pym/repoman/scanner.py | 36 ++++++++++++++++++++------- 3 files changed, 67 insertions(+), 9 deletions(-) diff --git a/pym/repoman/modules/scan/metadata/__init__.py b/pym/repoman/modules/scan/metadata/__init__.py index 6ab44f6..ed4a967 100644 --- a/pym/repoman/modules/scan/metadata/__init__.py +++ b/pym/repoman/modules/scan/metadata/__init__.py @@ -50,6 +50,14 @@ module_spec = { 'func_desc': { }, }, + 'unused-metadata': { + 'name': "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 1cd37d0..4cc2e67 100644 --- a/pym/repoman/scanner.py +++ b/pym/repoman/scanner.py @@ -269,7 +269,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() @@ -317,11 +316,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