public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/repoman/
Date: Wed, 30 May 2012 23:20:43 +0000 (UTC)	[thread overview]
Message-ID: <1338420027.597826a1cabf654f9b3fff88425d04303e921577.zmedico@gentoo> (raw)

commit:     597826a1cabf654f9b3fff88425d04303e921577
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed May 30 23:20:27 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed May 30 23:20:27 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=597826a1

InheritEclass: move eclass info to a dict

This handles the info more like it will be handled when we parse it
directly from eclasses.

---
 pym/repoman/checks.py |  175 +++++++++++++++++++++++++-----------------------
 1 files changed, 91 insertions(+), 84 deletions(-)

diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py
index 94dcfbe..5d56888 100644
--- a/pym/repoman/checks.py
+++ b/pym/repoman/checks.py
@@ -6,13 +6,14 @@
 and correctness of an ebuild."""
 
 import codecs
+from itertools import chain
 import re
 import time
 import repoman.errors as errors
 import portage
 from portage.eapi import eapi_supports_prefix, eapi_has_implicit_rdepend, \
 	eapi_has_src_prepare_and_src_configure, eapi_has_dosed_dohard, \
-	eapi_exports_AA, eapi_exports_KV
+	eapi_exports_AA
 
 class LineCheck(object):
 	"""Run a check on a line of an ebuild."""
@@ -452,14 +453,19 @@ class InheritEclass(LineCheck):
 	Base class for checking for missing inherits, as well as excess inherits.
 
 	Args:
-		_eclass: Set to the name of your eclass.
-		_funcs: A tuple of functions that this eclass provides.
-		_comprehensive: Is the list of functions complete?
-		_exempt_eclasses: If these eclasses are inherited, disable the missing
+		eclass: Set to the name of your eclass.
+		funcs: A tuple of functions that this eclass provides.
+		comprehensive: Is the list of functions complete?
+		exempt_eclasses: If these eclasses are inherited, disable the missing
 		                  inherit check.
 	"""
 
-	def __init__(self):
+	def __init__(self, eclass, funcs=None, comprehensive=False,
+		exempt_eclasses=None):
+		self._eclass = eclass
+		self._funcs = funcs
+		self._comprehensive = comprehensive
+		self._exempt_eclasses = exempt_eclasses
 		self._inherit_re = re.compile(r'^\s*inherit\s(.*\s)?%s(\s|$)' % self._eclass)
 		self._func_re = re.compile(r'\b(' + '|'.join(self._funcs) + r')\b')
 
@@ -469,7 +475,7 @@ class InheritEclass(LineCheck):
 		# have been inherited and not just the ones we inherit directly.
 		self._inherit = False
 		self._func_call = False
-		if hasattr(self, '_exempt_eclasses'):
+		if self._exempt_eclasses is not None:
 			self._disabled = any(x in pkg.inherited for x in self._exempt_eclasses)
 		else:
 			self._disabled = False
@@ -493,78 +499,80 @@ class InheritEclass(LineCheck):
 			self.repoman_check_name = 'inherit.unused'
 			yield 'no function called from %s.eclass; please drop' % self._eclass
 
-class InheritAutotools(InheritEclass):
-	_eclass = 'autotools'
-	_funcs = (
-		'eaclocal', 'eautoconf', 'eautoheader',
-		'eautomake', 'eautoreconf', '_elibtoolize',
-		'eautopoint'
-	)
-	_comprehensive = True
-
-	# Exempt eclasses:
-	# git - An EGIT_BOOTSTRAP variable may be used to call one of
-	#       the autotools functions.
-	# subversion - An ESVN_BOOTSTRAP variable may be used to call one of
-	#       the autotools functions.
-	_exempt_eclasses = frozenset(['git', 'subversion', 'autotools-utils'])
-
-class InheritEutils(InheritEclass):
-	_eclass = 'eutils'
-	_funcs = (
-		'estack_push', 'estack_pop', 'eshopts_push', 'eshopts_pop',
-		'eumask_push', 'eumask_pop', 'epatch', 'epatch_user',
-		'emktemp', 'edos2unix', 'in_iuse', 'use_if_iuse', 'usex',
-		'makeopts_jobs'
-	)
-	_comprehensive = False
-
-	# These are "eclasses are the whole ebuild" type thing.
-	_exempt_eclasses = frozenset(['toolchain', 'toolchain-binutils'])
-
-class InheritFlagOMatic(InheritEclass):
-	_eclass = 'flag-o-matic'
-	_funcs = (
-		'filter-(ld)?flags', 'strip-flags', 'strip-unsupported-flags',
-		'append-((ld|c(pp|xx)?))?flags', 'append-libs',
-	)
-	_comprehensive = False
-
-class InheritLibtool(InheritEclass):
-	_eclass = 'libtool'
-	_funcs = (
-		'elibtoolize',
-	)
-	_comprehensive = True
-
-class InheritMultilib(InheritEclass):
-	_eclass = 'multilib'
-	_funcs = (
-		'get_libdir',
-	)
-	_comprehensive = False
-
-class InheritPrefix(InheritEclass):
-	_eclass = 'prefix'
-	_funcs = (
-		'eprefixify',
-	)
-	_comprehensive = True
-
-class InheritToolchainFuncs(InheritEclass):
-	_eclass = 'toolchain-funcs'
-	_funcs = (
-		'gen_usr_ldscript',
-	)
-	_comprehensive = False
-
-class InheritUser(InheritEclass):
-	_eclass = 'user'
-	_funcs = (
-		'enewuser', 'enewgroup',
-		'egetent', 'egethome', 'egetshell'
-	)
-	_comprehensive = True
+_eclass_info = {
+	'autotools': {
+		'funcs': (
+			'eaclocal', 'eautoconf', 'eautoheader',
+			'eautomake', 'eautoreconf', '_elibtoolize',
+			'eautopoint'
+		),
+		'comprehensive': True,
+
+		# Exempt eclasses:
+		# git - An EGIT_BOOTSTRAP variable may be used to call one of
+		#       the autotools functions.
+		# subversion - An ESVN_BOOTSTRAP variable may be used to call one of
+		#       the autotools functions.
+		'exempt_eclasses': ('git', 'subversion', 'autotools-utils')
+	},
+
+	'eutils': {
+		'funcs': (
+			'estack_push', 'estack_pop', 'eshopts_push', 'eshopts_pop',
+			'eumask_push', 'eumask_pop', 'epatch', 'epatch_user',
+			'emktemp', 'edos2unix', 'in_iuse', 'use_if_iuse', 'usex',
+			'makeopts_jobs'
+		),
+		'comprehensive': False,
+
+		# These are "eclasses are the whole ebuild" type thing.
+		'exempt_eclasses': frozenset(['toolchain', 'toolchain-binutils'])
+	},
+
+	'flag-o-matic': {
+		'funcs': (
+			'filter-(ld)?flags', 'strip-flags', 'strip-unsupported-flags',
+			'append-((ld|c(pp|xx)?))?flags', 'append-libs',
+		),
+		'comprehensive': False
+	},
+
+	'libtool': {
+		'funcs': (
+			'elibtoolize',
+		),
+		'comprehensive': True
+	},
+
+	'multilib': {
+		'funcs': (
+			'get_libdir',
+		),
+		'comprehensive': False
+	},
+
+	'prefix': {
+		'funcs': (
+			'eprefixify',
+		),
+		'comprehensive': True
+	},
+
+	'toolchain-funcs': {
+		'funcs': (
+			'gen_usr_ldscript',
+		),
+		'comprehensive': False
+	},
+
+	'user': {
+		'funcs': (
+			'enewuser', 'enewgroup',
+			'egetent', 'egethome', 'egetshell'
+		),
+		'comprehensive': True
+	}
+}
 
 class IUseUndefined(LineCheck):
 	"""
@@ -739,20 +747,19 @@ class PortageInternal(LineCheck):
 		if m is not None:
 			return ("'%s'" % m.group(2)) + " called on line: %d"
 
-_constant_checks = tuple((c() for c in (
+_constant_checks = tuple(chain((c() for c in (
 	EbuildHeader, EbuildWhitespace, EbuildBlankLine, EbuildQuote,
 	EbuildAssignment, Eapi3EbuildAssignment, EbuildUselessDodoc,
 	EbuildUselessCdS, EbuildNestedDie,
 	EbuildPatches, EbuildQuotedA, EapiDefinition,
-	ImplicitRuntimeDeps, InheritAutotools, InheritDeprecated, InheritEutils,
-	InheritFlagOMatic, InheritMultilib, InheritLibtool, InheritPrefix,
-	InheritToolchainFuncs, InheritUser, IUseUndefined,
+	ImplicitRuntimeDeps, IUseUndefined,
 	EMakeParallelDisabled, EMakeParallelDisabledViaMAKEOPTS, NoAsNeeded,
 	DeprecatedBindnowFlags, SrcUnpackPatches, WantAutoDefaultValue,
 	SrcCompileEconf, Eapi3DeprecatedFuncs, NoOffsetWithHelpers,
 	Eapi4IncompatibleFuncs, Eapi4GoneVars, BuiltWithUse,
 	PreserveOldLib, SandboxAddpredict, PortageInternal,
-	DeprecatedUseq, DeprecatedHasq)))
+	DeprecatedUseq, DeprecatedHasq)),
+	(InheritEclass(k, **kwargs) for k, kwargs in _eclass_info.items())))
 
 _here_doc_re = re.compile(r'.*\s<<[-]?(\w+)$')
 _ignore_comment_re = re.compile(r'^\s*#')



             reply	other threads:[~2012-05-30 23:20 UTC|newest]

Thread overview: 123+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-30 23:20 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-04-29 17:24 [gentoo-commits] proj/portage:master commit in: pym/repoman/ Brian Dolbec
2016-04-29 17:24 Brian Dolbec
2016-04-29 17:24 Brian Dolbec
2016-04-29 17:24 Brian Dolbec
2016-04-28 15:05 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2016-04-29 17:24 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2016-03-10 22:39 Brian Dolbec
2016-01-30 16:44 Brian Dolbec
2016-01-29 23:04 Brian Dolbec
2016-01-29  5:34 Brian Dolbec
2016-01-27 20:39 Brian Dolbec
2015-12-29 20:29 Zac Medico
2015-12-24 14:30 Brian Dolbec
2015-10-13 16:27 Michał Górny
2015-10-07 23:22 Brian Dolbec
2015-10-07 23:09 Brian Dolbec
2015-10-04 21:15 Brian Dolbec
2015-09-26 20:53 Brian Dolbec
2015-09-26 20:53 Brian Dolbec
2015-09-26 20:49 Brian Dolbec
2015-09-26 20:49 Brian Dolbec
2015-09-24 16:19 Brian Dolbec
2015-09-24 16:19 Brian Dolbec
2015-09-24 15:24 Brian Dolbec
2015-09-21 23:51 Brian Dolbec
2015-09-21 23:51 Brian Dolbec
2015-09-21 23:51 Brian Dolbec
2015-09-21 23:51 Brian Dolbec
2015-09-21 23:51 Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-08-10 14:44 Michał Górny
2015-02-11  8:00 Michał Górny
2014-09-11 23:45 Brian Dolbec
2014-04-04 23:01 Brian Dolbec
2014-04-04 23:01 Brian Dolbec
2014-01-27  3:13 Chris Reffett
2013-08-08 17:33 Zac Medico
2013-05-24 19:00 Zac Medico
2013-04-22 21:08 Zac Medico
2013-03-19 16:50 Zac Medico
2013-03-15  3:30 Arfrever Frehtes Taifersar Arahesis
2013-03-14 17:18 Zac Medico
2013-02-11  9:50 Zac Medico
2013-01-19 19:11 Zac Medico
2013-01-01 23:40 Zac Medico
2013-01-01 23:23 Zac Medico
2012-12-15 20:08 Zac Medico
2012-11-22 22:12 Arfrever Frehtes Taifersar Arahesis
2012-11-22 21:53 Arfrever Frehtes Taifersar Arahesis
2012-11-22 21:51 Arfrever Frehtes Taifersar Arahesis
2012-10-31 14:11 Zac Medico
2012-10-08 14:17 Zac Medico
2012-09-12  4:56 Zac Medico
2012-09-10 21:07 Zac Medico
2012-09-10  5:52 Zac Medico
2012-09-10  5:46 Zac Medico
2012-06-21  1:02 Zac Medico
2012-06-09  2:03 Zac Medico
2012-06-08  2:52 Zac Medico
2012-06-04  4:06 Zac Medico
2012-06-04  3:25 Zac Medico
2012-06-02  6:24 Zac Medico
2012-06-02  6:24 Zac Medico
2012-06-02  5:14 Zac Medico
2012-06-01  3:32 Zac Medico
2012-06-01  2:23 Zac Medico
2012-05-31 22:27 Zac Medico
2012-05-31  0:59 Zac Medico
2012-05-30 23:56 Zac Medico
2012-05-25 16:18 Mike Frysinger
2012-04-23 20:18 Zac Medico
2012-04-23 20:16 Zac Medico
2012-04-23 20:08 Zac Medico
2012-04-22 23:01 Zac Medico
2012-04-22 22:58 Zac Medico
2012-04-22 22:53 Zac Medico
2012-03-05  0:01 Zac Medico
2012-02-15  0:04 Zac Medico
2012-02-12 23:32 Zac Medico
2011-10-26 18:13 Zac Medico
2011-10-21  8:11 Zac Medico
2011-10-21  7:38 Zac Medico
2011-10-21  7:20 Zac Medico
2011-10-21  7:06 Zac Medico
2011-10-21  4:53 Zac Medico
2011-10-21  1:27 Zac Medico
2011-10-20 21:51 Zac Medico
2011-10-20 21:29 Zac Medico
2011-10-20 21:26 Zac Medico
2011-10-20 20:40 Fabian Groffen
2011-10-20 20:40 Fabian Groffen
2011-10-20 19:11 Zac Medico
2011-10-17 15:53 Zac Medico
2011-10-17  3:47 Zac Medico
2011-10-17  1:11 Zac Medico
2011-10-17  0:14 Zac Medico
2011-10-15 12:42 Fabian Groffen
2011-09-24 19:30 Zac Medico
2011-09-10 19:40 Zac Medico
2011-08-30 16:26 Zac Medico
2011-08-09  6:44 Zac Medico
2011-07-08  8:08 Zac Medico
2011-07-08  7:47 Zac Medico
2011-07-08  7:13 Zac Medico
2011-05-31 22:25 Zac Medico
2011-04-20 23:58 Zac Medico
2011-02-28 20:39 Zac Medico
2011-02-28  5:27 Zac Medico
2011-02-19 23:49 Zac Medico
2011-02-13  7:52 Zac Medico
2011-02-05  0:58 Zac Medico
2011-02-04  5:02 zmedico

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=1338420027.597826a1cabf654f9b3fff88425d04303e921577.zmedico@gentoo \
    --to=zmedico@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