public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/modules/scan/use/, pym/repoman/
Date: Sat, 30 Jan 2016 08:00:01 +0000 (UTC)	[thread overview]
Message-ID: <1454140217.93c291f79572c27c51d90ead0b203c3560e25649.dolsen@gentoo> (raw)

commit:     93c291f79572c27c51d90ead0b203c3560e25649
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  8 01:37:39 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 30 07:50:17 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=93c291f7

repoman: Create USEFlagChecks class plugin

 pym/repoman/modules/scan/use/__init__.py           | 24 +++++++++++++++
 .../ebuilds => modules/scan/use}/use_flags.py      | 36 ++++++++++++++--------
 pym/repoman/scanner.py                             |  8 ++---
 3 files changed, 50 insertions(+), 18 deletions(-)

diff --git a/pym/repoman/modules/scan/use/__init__.py b/pym/repoman/modules/scan/use/__init__.py
new file mode 100644
index 0000000..80fa213
--- /dev/null
+++ b/pym/repoman/modules/scan/use/__init__.py
@@ -0,0 +1,24 @@
+# Copyright 2015-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+doc = """Use plug-in module for repoman.
+Performs use flag checks on ebuilds."""
+__doc__ = doc[:]
+
+
+module_spec = {
+	'name': 'use',
+	'description': doc,
+	'provides':{
+		'use-module': {
+			'name': "use_flags",
+			'sourcefile': "use_flags",
+			'class': "USEFlagChecks",
+			'description': doc,
+			'functions': ['check', 'getUsedUseFlags'],
+			'func_desc': {
+			},
+		},
+	}
+}
+

diff --git a/pym/repoman/checks/ebuilds/use_flags.py b/pym/repoman/modules/scan/use/use_flags.py
similarity index 74%
rename from pym/repoman/checks/ebuilds/use_flags.py
rename to pym/repoman/modules/scan/use/use_flags.py
index ac21b47..acc7dd3 100644
--- a/pym/repoman/checks/ebuilds/use_flags.py
+++ b/pym/repoman/modules/scan/use/use_flags.py
@@ -9,31 +9,39 @@ from repoman._portage import portage
 
 from portage import eapi
 from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use
+from repoman.modules.scan.scanbase import ScanBase
 
 
-class USEFlagChecks(object):
+class USEFlagChecks(ScanBase):
 	'''Performs checks on USE flags listed in the ebuilds and metadata.xml'''
 
-	def __init__(self, qatracker, globalUseFlags):
-		'''
+	def __init__(self, **kwargs):
+		'''Class init
+
 		@param qatracker: QATracker instance
 		@param globalUseFlags: Global USE flags
 		'''
-		self.qatracker = qatracker
-		self.globalUseFlags = globalUseFlags
+		super(USEFlagChecks, self).__init__(**kwargs)
+		self.qatracker = kwargs.get('qatracker')
+		self.globalUseFlags = kwargs.get('uselist')
 		self.useFlags = []
 		self.defaultUseFlags = []
 		self.usedUseFlags = set()
 
-	def check(self, pkg, package, ebuild, y_ebuild, localUseFlags):
+	def check(self, **kwargs):
 		'''Perform the check.
 
 		@param pkg: Package in which we check (object).
-		@param package: Package in which we check (string).
+		@param xpkg: Package in which we check (string).
 		@param ebuild: Ebuild which we check (object).
 		@param y_ebuild: Ebuild which we check (string).
-		@param localUseFlags: Local USE flags of the package
+		@param muselist: Local USE flags of the package
 		'''
+		pkg = kwargs.get('pkg')
+		package = kwargs.get('xpkg')
+		ebuild = kwargs.get('ebuild')
+		y_ebuild = kwargs.get('y_ebuild')
+		localUseFlags = kwargs.get('muselist')
 		# reset state variables for the run
 		self.useFlags = []
 		self.defaultUseFlags = []
@@ -41,10 +49,9 @@ class USEFlagChecks(object):
 		self._checkGlobal(pkg)
 		self._checkMetadata(package, ebuild, y_ebuild, localUseFlags)
 		self._checkRequiredUSE(pkg, ebuild)
-
-	def getUsedUseFlags(self):
-		'''Get the USE flags that this check has seen'''
-		return self.usedUseFlags
+		used_useflags = kwargs.get('used_useflags').union(self.usedUseFlags)
+		return {'continue': False, 'ebuild_UsedUseFlags': self.usedUseFlags,
+			'used_useflags': used_useflags}
 
 	def _checkGlobal(self, pkg):
 		for myflag in pkg._metadata["IUSE"].split():
@@ -88,3 +95,8 @@ class USEFlagChecks(object):
 					"REQUIRED_USE.syntax",
 					"%s: REQUIRED_USE: %s" % (ebuild.relative_path, e))
 				del e
+
+	@property
+	def runInEbuilds(self):
+		'''Ebuild level scans'''
+		return (True, [self.check])

diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index 40aafcc..23642c3 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -19,7 +19,6 @@ from portage.dep import Atom
 from portage.output import green
 from repoman.checks.ebuilds.checks import run_checks
 from repoman.checks.ebuilds.eclasses.ruby import RubyEclassChecks
-from repoman.checks.ebuilds.use_flags import USEFlagChecks
 from repoman.checks.ebuilds.variables.license import LicenseChecks
 from repoman.checks.ebuilds.variables.restrict import RestrictChecks
 from repoman.modules.commit import repochecks
@@ -215,7 +214,6 @@ class Scanner(object):
 			self.modules[mod_class.__name__] = mod_class(**self.kwargs)
 
 		# initialize our checks classes here before the big xpkg loop
-		self.use_flag_checks = USEFlagChecks(self.qatracker, uselist)
 		self.rubyeclasscheck = RubyEclassChecks(self.qatracker)
 		self.licensecheck = LicenseChecks(self.qatracker, liclist, liclist_deprecated)
 		self.restrictcheck = RestrictChecks(self.qatracker)
@@ -303,6 +301,7 @@ class Scanner(object):
 				('thirdpartymirrors', 'ThirdPartyMirrors'),
 				('description', 'DescriptionChecks'), (None, 'KeywordChecks'),
 				('arches', 'ArchChecks'), ('depend', 'DependChecks'),
+				('use_flags', 'USEFlagChecks'),
 				]:
 				if mod[0]:
 					mod_class = MODULE_CONTROLLER.get_class(mod[0])
@@ -365,10 +364,7 @@ class Scanner(object):
 			badlicsyntax = badlicsyntax > 0
 			badprovsyntax = badprovsyntax > 0
 
-			self.use_flag_checks.check(dynamic_data['pkg'], xpkg, dynamic_data['ebuild'], y_ebuild, dynamic_data['muselist'])
-
-			ebuild_used_useflags = self.use_flag_checks.getUsedUseFlags()
-			used_useflags = used_useflags.union(ebuild_used_useflags)
+			used_useflags = used_useflags.union(dynamic_data['ebuild_used_useflags'])
 
 			self.rubyeclasscheck.check(dynamic_data['pkg'], dynamic_data['ebuild'])
 


             reply	other threads:[~2016-01-30  8:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-30  8:00 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-01-30  6:58 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/modules/scan/use/, pym/repoman/ Brian Dolbec
2016-01-27 23:15 Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454140217.93c291f79572c27c51d90ead0b203c3560e25649.dolsen@gentoo \
    --to=dolsen@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox