public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: lib/portage/dep/
@ 2019-05-04 21:09 Zac Medico
  0 siblings, 0 replies; 10+ messages in thread
From: Zac Medico @ 2019-05-04 21:09 UTC (permalink / raw
  To: gentoo-commits

commit:     7f2c4b0d402be190a9575346a76e3ee9361179ac
Author:     Rolf Eike Beer <eike <AT> sf-mail <DOT> de>
AuthorDate: Sat May  4 17:54:22 2019 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat May  4 21:08:03 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7f2c4b0d

fix some documentation in the dep API

-fix bad parameter names
-fix duplicate @param that should be @type
-move "Example usage:" below the parameter list

Closes: https://github.com/gentoo/portage/pull/424
Signed-off-by: Rolf Eike Beer <eike <AT> sf-mail.de>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/dep/__init__.py | 140 ++++++++++++++++++++++----------------------
 1 file changed, 69 insertions(+), 71 deletions(-)

diff --git a/lib/portage/dep/__init__.py b/lib/portage/dep/__init__.py
index 26595da47..418bfa011 100644
--- a/lib/portage/dep/__init__.py
+++ b/lib/portage/dep/__init__.py
@@ -186,7 +186,6 @@ def _get_useflag_re(eapi):
 
 def cpvequal(cpv1, cpv2):
 	"""
-	
 	@param cpv1: CategoryPackageVersion (no operators) Example: "sys-apps/portage-2.1"
 	@type cpv1: String
 	@param cpv2: CategoryPackageVersion (no operators) Example: "sys-apps/portage-2.1"
@@ -201,7 +200,6 @@ def cpvequal(cpv1, cpv2):
 	>>> from portage.dep import cpvequal
 	>>> cpvequal("sys-apps/portage-2.1","sys-apps/portage-2.1")
 	>>> True
-
 	"""
 
 	try:
@@ -384,15 +382,15 @@ def paren_enclose(mylist, unevaluated_atom=False, opconvert=False):
 	"""
 	Convert a list to a string with sublists enclosed with parens.
 
-	Example usage:
-		>>> test = ['foobar','foo',['bar','baz']]
-		>>> paren_enclose(test)
-		'foobar foo ( bar baz )'
-
 	@param mylist: The list
 	@type mylist: List
 	@rtype: String
 	@return: The paren enclosed string
+
+	Example usage:
+		>>> test = ['foobar','foo',['bar','baz']]
+		>>> paren_enclose(test)
+		'foobar foo ( bar baz )'
 	"""
 	mystrparts = []
 	for x in mylist:
@@ -736,16 +734,16 @@ def dep_opconvert(deplist):
 	dep is a '||' or '&&' operator, combine it with the
 	list of deps that follows..
 
-	Example usage:
-		>>> test = ["blah", "||", ["foo", "bar", "baz"]]
-		>>> dep_opconvert(test)
-		['blah', ['||', 'foo', 'bar', 'baz']]
-
 	@param deplist: A list of deps to format
-	@type mydep: List
+	@type deplist: List
 	@rtype: List
 	@return:
 		The new list with the new ordering
+
+	Example usage:
+		>>> test = ["blah", "||", ["foo", "bar", "baz"]]
+		>>> dep_opconvert(test)
+		['blah', ['||', 'foo', 'bar', 'baz']]
 	"""
 	if portage._internal_caller:
 		warnings.warn(_("%s is deprecated. Use %s with the opconvert parameter set to True instead.") % \
@@ -769,14 +767,14 @@ def flatten(mylist):
 	Recursively traverse nested lists and return a single list containing
 	all non-list elements that are found.
 
-	Example usage:
-		>>> flatten([1, [2, 3, [4]]])
-		[1, 2, 3, 4]
-
 	@param mylist: A list containing nested lists and non-list elements.
 	@type mylist: List
 	@rtype: List
 	@return: A single list containing only non-list elements.
+
+	Example usage:
+		>>> flatten([1, [2, 3, [4]]])
+		[1, 2, 3, 4]
 	"""
 	if portage._internal_caller:
 		warnings.warn(_("%s is deprecated and will be removed without replacement.") % \
@@ -1731,16 +1729,16 @@ def get_operator(mydep):
 	"""
 	Return the operator used in a depstring.
 
-	Example usage:
-		>>> from portage.dep import *
-		>>> get_operator(">=test-1.0")
-		'>='
-
 	@param mydep: The dep string to check
 	@type mydep: String
 	@rtype: String
 	@return: The operator. One of:
 		'~', '=', '>', '<', '=*', '>=', or '<='
+
+	Example usage:
+		>>> from portage.dep import *
+		>>> get_operator(">=test-1.0")
+		'>='
 	"""
 	if not isinstance(mydep, Atom):
 		mydep = Atom(mydep)
@@ -1751,14 +1749,14 @@ def dep_getcpv(mydep):
 	"""
 	Return the category-package-version with any operators/slot specifications stripped off
 
-	Example usage:
-		>>> dep_getcpv('>=media-libs/test-3.0')
-		'media-libs/test-3.0'
-
 	@param mydep: The depstring
 	@type mydep: String
 	@rtype: String
 	@return: The depstring with the operator removed
+
+	Example usage:
+		>>> dep_getcpv('>=media-libs/test-3.0')
+		'media-libs/test-3.0'
 	"""
 	if not isinstance(mydep, Atom):
 		mydep = Atom(mydep)
@@ -1769,14 +1767,14 @@ def dep_getslot(mydep):
 	"""
 	Retrieve the slot on a depend.
 
-	Example usage:
-		>>> dep_getslot('app-misc/test:3')
-		'3'
-
 	@param mydep: The depstring to retrieve the slot of
 	@type mydep: String
 	@rtype: String
 	@return: The slot
+
+	Example usage:
+		>>> dep_getslot('app-misc/test:3')
+		'3'
 	"""
 	slot = getattr(mydep, "slot", False)
 	if slot is not False:
@@ -1798,14 +1796,14 @@ def dep_getrepo(mydep):
 	"""
 	Retrieve the repo on a depend.
 
-	Example usage:
-		>>> dep_getrepo('app-misc/test::repository')
-		'repository'
-
 	@param mydep: The depstring to retrieve the repository of
 	@type mydep: String
 	@rtype: String
 	@return: The repository name
+
+	Example usage:
+		>>> dep_getrepo('app-misc/test::repository')
+		'repository'
 	"""
 	repo = getattr(mydep, "repo", False)
 	if repo is not False:
@@ -1845,15 +1843,15 @@ def remove_slot(mydep):
 def dep_getusedeps( depend ):
 	"""
 	Pull a listing of USE Dependencies out of a dep atom.
-	
-	Example usage:
-		>>> dep_getusedeps('app-misc/test:3[foo,-bar]')
-		('foo', '-bar')
-	
+
 	@param depend: The depstring to process
 	@type depend: String
 	@rtype: List
 	@return: List of use flags ( or [] if no flags exist )
+
+	Example usage:
+		>>> dep_getusedeps('app-misc/test:3[foo,-bar]')
+		('foo', '-bar')
 	"""
 	use_list = []
 	open_bracket = depend.find('[')
@@ -1899,18 +1897,18 @@ def isvalidatom(atom, allow_blockers=False, allow_wildcard=False,
 	"""
 	Check to see if a depend atom is valid
 
-	Example usage:
-		>>> isvalidatom('media-libs/test-3.0')
-		False
-		>>> isvalidatom('>=media-libs/test-3.0')
-		True
-
 	@param atom: The depend atom to check against
 	@type atom: String or Atom
 	@rtype: Boolean
 	@return: One of the following:
 		1) False if the atom is invalid
 		2) True if the atom is valid
+
+	Example usage:
+		>>> isvalidatom('media-libs/test-3.0')
+		False
+		>>> isvalidatom('>=media-libs/test-3.0')
+		True
 	"""
 
 	if eapi is not None and isinstance(atom, Atom) and atom.eapi != eapi:
@@ -1932,18 +1930,18 @@ def isjustname(mypkg):
 	"""
 	Checks to see if the atom is only the package name (no version parts).
 
-	Example usage:
-		>>> isjustname('=media-libs/test-3.0')
-		False
-		>>> isjustname('media-libs/test')
-		True
-
 	@param mypkg: The package atom to check
 	@param mypkg: String or Atom
 	@rtype: Integer
 	@return: One of the following:
 		1) False if the package string is not just the package name
 		2) True if it is
+
+	Example usage:
+		>>> isjustname('=media-libs/test-3.0')
+		False
+		>>> isjustname('media-libs/test')
+		True
 	"""
 	try:
 		if not isinstance(mypkg, Atom):
@@ -1962,18 +1960,18 @@ def isspecific(mypkg):
 	Checks to see if a package is in =category/package-version or
 	package-version format.
 
-	Example usage:
-		>>> isspecific('media-libs/test')
-		False
-		>>> isspecific('=media-libs/test-3.0')
-		True
-
 	@param mypkg: The package depstring to check against
 	@type mypkg: String
 	@rtype: Boolean
 	@return: One of the following:
 		1) False if the package string is not specific
 		2) True if it is
+
+	Example usage:
+		>>> isspecific('media-libs/test')
+		False
+		>>> isspecific('=media-libs/test-3.0')
+		True
 	"""
 	try:
 		if not isinstance(mypkg, Atom):
@@ -1989,14 +1987,14 @@ def dep_getkey(mydep):
 	"""
 	Return the category/package-name of a depstring.
 
-	Example usage:
-		>>> dep_getkey('=media-libs/test-3.0')
-		'media-libs/test'
-
 	@param mydep: The depstring to retrieve the category/package-name of
 	@type mydep: String
 	@rtype: String
 	@return: The package category/package-name
+
+	Example usage:
+		>>> dep_getkey('=media-libs/test-3.0')
+		'media-libs/test'
 	"""
 	if not isinstance(mydep, Atom):
 		mydep = Atom(mydep, allow_wildcard=True, allow_repo=True)
@@ -2010,7 +2008,7 @@ def match_to_list(mypkg, mylist):
 	@param mypkg: The package atom to match
 	@type mypkg: String
 	@param mylist: The list of package atoms to compare against
-	@param mylist: List
+	@type mylist: List
 	@rtype: List
 	@return: A unique list of package atoms that match the given package atom
 	"""
@@ -2107,7 +2105,7 @@ def match_from_list(mydep, candidate_list):
 	@param mydep: The package atom to match
 	@type mydep: String
 	@param candidate_list: The list of package atoms to compare against
-	@param candidate_list: List
+	@type candidate_list: List
 	@rtype: List
 	@return: A list of package atoms that match the given package atom
 	"""
@@ -2524,15 +2522,15 @@ class _RequiredUseBranch(object):
 def check_required_use(required_use, use, iuse_match, eapi=None):
 	"""
 	Checks if the use flags listed in 'use' satisfy all
-	constraints specified in 'constraints'.
+	constraints specified in 'required_use'.
 
 	@param required_use: REQUIRED_USE string
 	@type required_use: String
 	@param use: Enabled use flags
-	@param use: List
+	@type use: List
 	@param iuse_match: Callable that takes a single flag argument and returns
 		True if the flag is matched, false otherwise,
-	@param iuse_match: Callable
+	@type iuse_match: Callable
 	@rtype: Bool
 	@return: Indicates if REQUIRED_USE constraints are satisfied
 	"""
@@ -2711,17 +2709,17 @@ def extract_affecting_use(mystr, atom, eapi=None):
 	Take a dep string and an atom and return the use flags
 	that decide if the given atom is in effect.
 
-	Example usage:
-		>>> extract_affecting_use('sasl? ( dev-libs/cyrus-sasl ) \
-			!minimal? ( cxx? ( dev-libs/cyrus-sasl ) )', 'dev-libs/cyrus-sasl')
-		{'cxx', 'minimal', 'sasl'}
-
 	@param mystr: The dependency string
 	@type mystr: String
 	@param atom: The atom to get into effect
 	@type atom: String
 	@rtype: Set of strings
 	@return: Set of use flags affecting given atom
+
+	Example usage:
+		>>> extract_affecting_use('sasl? ( dev-libs/cyrus-sasl ) \
+			!minimal? ( cxx? ( dev-libs/cyrus-sasl ) )', 'dev-libs/cyrus-sasl')
+		{'cxx', 'minimal', 'sasl'}
 	"""
 	useflag_re = _get_useflag_re(eapi)
 	mysplit = mystr.split()


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/dep/
@ 2019-05-11 20:45 Zac Medico
  0 siblings, 0 replies; 10+ messages in thread
From: Zac Medico @ 2019-05-11 20:45 UTC (permalink / raw
  To: gentoo-commits

commit:     75dfea84dea28ca2e14b6f1cb7bc3ca1c2f87a0c
Author:     Rolf Eike Beer <eike <AT> sf-mail <DOT> de>
AuthorDate: Thu May  9 18:12:14 2019 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat May 11 20:45:26 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=75dfea84

really fix some dep API documentation

-interface description needs to be last for epydoc, even if it works
 at some places when it is not
-fix some other minor things like wrong parameter names and missing types

Closes: https://github.com/gentoo/portage/pull/426
Signed-off-by: Rolf Eike Beer <eike <AT> sf-mail.de>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/dep/__init__.py | 112 +++++++++++++++++++++++---------------------
 1 file changed, 58 insertions(+), 54 deletions(-)

diff --git a/lib/portage/dep/__init__.py b/lib/portage/dep/__init__.py
index 418bfa011..285e0c2ec 100644
--- a/lib/portage/dep/__init__.py
+++ b/lib/portage/dep/__init__.py
@@ -186,20 +186,20 @@ def _get_useflag_re(eapi):
 
 def cpvequal(cpv1, cpv2):
 	"""
+	Example Usage:
+		>>> from portage.dep import cpvequal
+		>>> cpvequal("sys-apps/portage-2.1","sys-apps/portage-2.1")
+		>>> True
+
 	@param cpv1: CategoryPackageVersion (no operators) Example: "sys-apps/portage-2.1"
 	@type cpv1: String
 	@param cpv2: CategoryPackageVersion (no operators) Example: "sys-apps/portage-2.1"
 	@type cpv2: String
 	@rtype: Boolean
 	@return:
-	1.  True if cpv1 = cpv2
-	2.  False Otherwise
-	3.  Throws PortageException if cpv1 or cpv2 is not a CPV
-
-	Example Usage:
-	>>> from portage.dep import cpvequal
-	>>> cpvequal("sys-apps/portage-2.1","sys-apps/portage-2.1")
-	>>> True
+		1.  True if cpv1 = cpv2
+		2.  False Otherwise
+		3.  Throws PortageException if cpv1 or cpv2 is not a CPV
 	"""
 
 	try:
@@ -411,8 +411,8 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
 	Takes a dep string and reduces the use? conditionals out, leaving an array
 	with subarrays. All redundant brackets are removed.
 
-	@param deparray: depstring
-	@type deparray: String
+	@param depstr: depstring
+	@type depstr: String
 	@param uselist: List of use enabled flags
 	@type uselist: List
 	@param masklist: List of masked flags (always treated as disabled)
@@ -734,16 +734,16 @@ def dep_opconvert(deplist):
 	dep is a '||' or '&&' operator, combine it with the
 	list of deps that follows..
 
+	Example usage:
+		>>> test = ["blah", "||", ["foo", "bar", "baz"]]
+		>>> dep_opconvert(test)
+		['blah', ['||', 'foo', 'bar', 'baz']]
+
 	@param deplist: A list of deps to format
 	@type deplist: List
 	@rtype: List
 	@return:
 		The new list with the new ordering
-
-	Example usage:
-		>>> test = ["blah", "||", ["foo", "bar", "baz"]]
-		>>> dep_opconvert(test)
-		['blah', ['||', 'foo', 'bar', 'baz']]
 	"""
 	if portage._internal_caller:
 		warnings.warn(_("%s is deprecated. Use %s with the opconvert parameter set to True instead.") % \
@@ -1434,7 +1434,7 @@ class Atom(_unicode):
 		"""
 		Returns True if slot_operator == "=" and sub_slot is not None.
 		NOTE: foo/bar:2= is unbuilt and returns False, whereas foo/bar:2/2=
-			is built and returns True.
+		is built and returns True.
 		"""
 		return self.slot_operator == "=" and self.sub_slot is not None
 
@@ -1729,16 +1729,16 @@ def get_operator(mydep):
 	"""
 	Return the operator used in a depstring.
 
+	Example usage:
+		>>> from portage.dep import *
+		>>> get_operator(">=test-1.0")
+		'>='
+
 	@param mydep: The dep string to check
 	@type mydep: String
 	@rtype: String
 	@return: The operator. One of:
 		'~', '=', '>', '<', '=*', '>=', or '<='
-
-	Example usage:
-		>>> from portage.dep import *
-		>>> get_operator(">=test-1.0")
-		'>='
 	"""
 	if not isinstance(mydep, Atom):
 		mydep = Atom(mydep)
@@ -1749,14 +1749,14 @@ def dep_getcpv(mydep):
 	"""
 	Return the category-package-version with any operators/slot specifications stripped off
 
+	Example usage:
+		>>> dep_getcpv('>=media-libs/test-3.0')
+		'media-libs/test-3.0'
+
 	@param mydep: The depstring
 	@type mydep: String
 	@rtype: String
 	@return: The depstring with the operator removed
-
-	Example usage:
-		>>> dep_getcpv('>=media-libs/test-3.0')
-		'media-libs/test-3.0'
 	"""
 	if not isinstance(mydep, Atom):
 		mydep = Atom(mydep)
@@ -1767,14 +1767,14 @@ def dep_getslot(mydep):
 	"""
 	Retrieve the slot on a depend.
 
+	Example usage:
+		>>> dep_getslot('app-misc/test:3')
+		'3'
+
 	@param mydep: The depstring to retrieve the slot of
 	@type mydep: String
 	@rtype: String
 	@return: The slot
-
-	Example usage:
-		>>> dep_getslot('app-misc/test:3')
-		'3'
 	"""
 	slot = getattr(mydep, "slot", False)
 	if slot is not False:
@@ -1823,13 +1823,17 @@ def dep_getrepo(mydep):
 		else:
 			return mydep[colon+2:bracket]
 	return None
+
 def remove_slot(mydep):
 	"""
 	Removes dep components from the right side of an atom:
-		* slot
-		* use
-		* repo
+		- slot
+		- use
+		- repo
 	And repo_name from the left side.
+
+	@type mydep: String
+	@rtype: String
 	"""
 	colon = mydep.find(_slot_separator)
 	if colon != -1:
@@ -1897,18 +1901,18 @@ def isvalidatom(atom, allow_blockers=False, allow_wildcard=False,
 	"""
 	Check to see if a depend atom is valid
 
+	Example usage:
+		>>> isvalidatom('media-libs/test-3.0')
+		False
+		>>> isvalidatom('>=media-libs/test-3.0')
+		True
+
 	@param atom: The depend atom to check against
 	@type atom: String or Atom
 	@rtype: Boolean
 	@return: One of the following:
 		1) False if the atom is invalid
 		2) True if the atom is valid
-
-	Example usage:
-		>>> isvalidatom('media-libs/test-3.0')
-		False
-		>>> isvalidatom('>=media-libs/test-3.0')
-		True
 	"""
 
 	if eapi is not None and isinstance(atom, Atom) and atom.eapi != eapi:
@@ -1930,18 +1934,18 @@ def isjustname(mypkg):
 	"""
 	Checks to see if the atom is only the package name (no version parts).
 
+	Example usage:
+		>>> isjustname('=media-libs/test-3.0')
+		False
+		>>> isjustname('media-libs/test')
+		True
+
 	@param mypkg: The package atom to check
 	@param mypkg: String or Atom
 	@rtype: Integer
 	@return: One of the following:
 		1) False if the package string is not just the package name
 		2) True if it is
-
-	Example usage:
-		>>> isjustname('=media-libs/test-3.0')
-		False
-		>>> isjustname('media-libs/test')
-		True
 	"""
 	try:
 		if not isinstance(mypkg, Atom):
@@ -1960,18 +1964,18 @@ def isspecific(mypkg):
 	Checks to see if a package is in =category/package-version or
 	package-version format.
 
+	Example usage:
+		>>> isspecific('media-libs/test')
+		False
+		>>> isspecific('=media-libs/test-3.0')
+		True
+
 	@param mypkg: The package depstring to check against
 	@type mypkg: String
 	@rtype: Boolean
 	@return: One of the following:
 		1) False if the package string is not specific
 		2) True if it is
-
-	Example usage:
-		>>> isspecific('media-libs/test')
-		False
-		>>> isspecific('=media-libs/test-3.0')
-		True
 	"""
 	try:
 		if not isinstance(mypkg, Atom):
@@ -1987,14 +1991,14 @@ def dep_getkey(mydep):
 	"""
 	Return the category/package-name of a depstring.
 
+	Example usage:
+		>>> dep_getkey('=media-libs/test-3.0')
+		'media-libs/test'
+
 	@param mydep: The depstring to retrieve the category/package-name of
 	@type mydep: String
 	@rtype: String
 	@return: The package category/package-name
-
-	Example usage:
-		>>> dep_getkey('=media-libs/test-3.0')
-		'media-libs/test'
 	"""
 	if not isinstance(mydep, Atom):
 		mydep = Atom(mydep, allow_wildcard=True, allow_repo=True)


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/dep/
@ 2019-10-23 17:03 Zac Medico
  0 siblings, 0 replies; 10+ messages in thread
From: Zac Medico @ 2019-10-23 17:03 UTC (permalink / raw
  To: gentoo-commits

commit:     8663207ddef5124466ac8943f6b61789d8ab54a4
Author:     Justin Turner Arthur <justinarthur <AT> gmail <DOT> com>
AuthorDate: Tue Oct 22 02:59:34 2019 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Oct 23 17:01:39 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=8663207d

Improve runtime performance of portage.dep module functions.

Use tuple vs list, reduce dot-refs, remove unused, use operators
instead of function calls where possible.

Signed-off-by: Justin Turner Arthur <justinarthur <AT> gmail.com>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/dep/__init__.py | 108 ++++++++++++++++++++++----------------------
 1 file changed, 55 insertions(+), 53 deletions(-)

diff --git a/lib/portage/dep/__init__.py b/lib/portage/dep/__init__.py
index 285e0c2ec..f08f6ba4c 100644
--- a/lib/portage/dep/__init__.py
+++ b/lib/portage/dep/__init__.py
@@ -17,7 +17,6 @@ __all__ = [
 
 import re, sys
 import warnings
-from itertools import chain
 
 import portage
 portage.proxy.lazyimport.lazyimport(globals(),
@@ -28,8 +27,8 @@ from portage import _encodings, _unicode_decode, _unicode_encode
 from portage.eapi import _get_eapi_attrs
 from portage.exception import InvalidAtom, InvalidData, InvalidDependString
 from portage.localization import _
-from portage.versions import catpkgsplit, catsplit, \
-	vercmp, ververify, _cp, _cpv, _pkg_str, _slot, _unknown_repo, _vr
+from portage.versions import _cp, _cpv, _pkg_str, _slot, _unknown_repo, _vr, \
+	catpkgsplit, vercmp, ververify
 import portage.cache.mappings
 
 if sys.hexversion >= 0x3000000:
@@ -405,7 +404,7 @@ def paren_enclose(mylist, unevaluated_atom=False, opconvert=False):
 			mystrparts.append(x)
 	return " ".join(mystrparts)
 
-def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], is_src_uri=False, \
+def use_reduce(depstr, uselist=(), masklist=(), matchall=False, excludeall=(), is_src_uri=False, \
 	eapi=None, opconvert=False, flat=False, is_valid_flag=None, token_class=None, matchnone=False):
 	"""
 	Takes a dep string and reduces the use? conditionals out, leaving an array
@@ -413,14 +412,14 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
 
 	@param depstr: depstring
 	@type depstr: String
-	@param uselist: List of use enabled flags
-	@type uselist: List
-	@param masklist: List of masked flags (always treated as disabled)
-	@type masklist: List
+	@param uselist: Sequence of use enabled flags
+	@type uselist: Sequence
+	@param masklist: Sequence of masked flags (always treated as disabled)
+	@type masklist: Sequence
 	@param matchall: Treat all conditionals as active. Used by repoman. 
 	@type matchall: Bool
-	@param excludeall: List of flags for which negated conditionals are always treated as inactive.
-	@type excludeall: List
+	@param excludeall: Sequence of flags for which negated conditionals are always treated as inactive.
+	@type excludeall: Sequence
 	@param is_src_uri: Indicates if depstr represents a SRC_URI
 	@type is_src_uri: Bool
 	@param eapi: Indicates the EAPI the dep string has to comply to
@@ -903,7 +902,7 @@ class _use_dep(object):
 		if conditional:
 			self.conditional = self._conditionals_class()
 			for k in "enabled", "disabled", "equal", "not_equal":
-				setattr(self.conditional, k, frozenset(conditional.get(k, [])))
+				setattr(self.conditional, k, frozenset(conditional.get(k, ())))
 
 	def __bool__(self):
 		return bool(self.tokens)
@@ -1012,7 +1011,7 @@ class _use_dep(object):
 		conditional = {}
 		tokens = []
 
-		all_defaults = frozenset(chain(self.missing_enabled, self.missing_disabled))
+		all_defaults = self.missing_enabled | self.missing_disabled
 		
 		def validate_flag(flag):
 			return is_valid_flag(flag) or flag in all_defaults
@@ -1249,35 +1248,36 @@ class Atom(_unicode):
 				m = atom_re.match(s)
 				if m is None:
 					raise InvalidAtom(self)
-				gdict = m.groupdict()
-				if m.group('star') is not None:
+				m_group = m.group
+				if m_group('star') is not None:
 					op = '=*'
 					base = atom_re.groupindex['star']
-					cp = m.group(base + 1)
-					cpv = m.group('star')[1:]
-					extended_version = m.group(base + 4)
+					cp = m_group(base + 1)
+					cpv = m_group('star')[1:]
+					extended_version = m_group(base + 4)
 				else:
 					op = None
-					cpv = cp = m.group('simple')
-					if m.group(atom_re.groupindex['simple'] + 3) is not None:
+					cpv = cp = m_group('simple')
+					if m_group(atom_re.groupindex['simple'] + 3) is not None:
 						raise InvalidAtom(self)
 				if cpv.find("**") != -1:
 					raise InvalidAtom(self)
-				slot = m.group('slot')
-				repo = m.group('repo')
+				slot = m_group('slot')
+				repo = m_group('repo')
 				use_str = None
 				extended_syntax = True
 			else:
 				raise InvalidAtom(self)
 		elif m.group('op') is not None:
+			m_group = m.group
 			base = atom_re.groupindex['op']
-			op = m.group(base + 1)
-			cpv = m.group(base + 2)
-			cp = m.group(base + 3)
-			slot = m.group(atom_re.groups - 2)
-			repo = m.group(atom_re.groups - 1)
-			use_str = m.group(atom_re.groups)
-			version = m.group(base + 4)
+			op = m_group(base + 1)
+			cpv = m_group(base + 2)
+			cp = m_group(base + 3)
+			slot = m_group(atom_re.groups - 2)
+			repo = m_group(atom_re.groups - 1)
+			use_str = m_group(atom_re.groups)
+			version = m_group(base + 4)
 			if version is not None:
 				if allow_build_id:
 					cpv_build_id = cpv
@@ -1296,20 +1296,22 @@ class Atom(_unicode):
 		elif m.group('star') is not None:
 			base = atom_re.groupindex['star']
 			op = '=*'
-			cpv = m.group(base + 1)
-			cp = m.group(base + 2)
-			slot = m.group(atom_re.groups - 2)
-			repo = m.group(atom_re.groups - 1)
-			use_str = m.group(atom_re.groups)
-			if m.group(base + 3) is not None:
+			m_group = m.group
+			cpv = m_group(base + 1)
+			cp = m_group(base + 2)
+			slot = m_group(atom_re.groups - 2)
+			repo = m_group(atom_re.groups - 1)
+			use_str = m_group(atom_re.groups)
+			if m_group(base + 3) is not None:
 				raise InvalidAtom(self)
 		elif m.group('simple') is not None:
 			op = None
-			cpv = cp = m.group(atom_re.groupindex['simple'] + 1)
-			slot = m.group(atom_re.groups - 2)
-			repo = m.group(atom_re.groups - 1)
-			use_str = m.group(atom_re.groups)
-			if m.group(atom_re.groupindex['simple'] + 2) is not None:
+			m_group = m.group
+			cpv = cp = m_group(atom_re.groupindex['simple'] + 1)
+			slot = m_group(atom_re.groups - 2)
+			repo = m_group(atom_re.groups - 1)
+			use_str = m_group(atom_re.groups)
+			if m_group(atom_re.groupindex['simple'] + 2) is not None:
 				raise InvalidAtom(self)
 
 		else:
@@ -1600,7 +1602,7 @@ class Atom(_unicode):
 		@return: True if this atom matches pkg, otherwise False
 		@rtype: bool
 		"""
-		return bool(match_from_list(self, [pkg]))
+		return bool(match_from_list(self, (pkg,)))
 
 _extended_cp_re_cache = {}
 
@@ -2017,12 +2019,14 @@ def match_to_list(mypkg, mylist):
 	@return: A unique list of package atoms that match the given package atom
 	"""
 	matches = set()
-	result = []
-	pkgs = [mypkg]
-	for x in mylist:
-		if x not in matches and match_from_list(x, pkgs):
-			matches.add(x)
-			result.append(x)
+	matches_add = matches.add
+	pkgs = (mypkg,)
+	result = [
+		x
+		for x in mylist
+		if not (x in matches or matches_add(x))
+		and match_from_list(x, pkgs)
+	]
 	return result
 
 def best_match_to_list(mypkg, mylist):
@@ -2127,13 +2131,11 @@ def match_from_list(mydep, candidate_list):
 
 	mycpv     = mydep.cpv
 	mycpv_cps = catpkgsplit(mycpv) # Can be None if not specific
-	slot      = mydep.slot
 	build_id  = mydep.build_id
 
 	if not mycpv_cps:
-		cat, pkg = catsplit(mycpv)
-		ver      = None
-		rev      = None
+		ver = None
+		rev = None
 	else:
 		cat, pkg, ver, rev = mycpv_cps
 		if mydep == mycpv:
@@ -2267,7 +2269,7 @@ def match_from_list(mydep, candidate_list):
 				continue
 			mylist.append(x)
 
-	elif operator in [">", ">=", "<", "<="]:
+	elif operator in (">", ">=", "<", "<="):
 		for x in candidate_list:
 			if hasattr(x, 'cp'):
 				pkg = x
@@ -2352,7 +2354,7 @@ def match_from_list(mydep, candidate_list):
 					if mydep.use.enabled:
 						if any(f in mydep.use.enabled for f in missing_disabled):
 							continue
-						need_enabled = mydep.use.enabled.difference(use.enabled)
+						need_enabled = mydep.use.enabled - use.enabled
 						if need_enabled:
 							if any(f not in missing_enabled for f in need_enabled):
 								continue
@@ -2360,7 +2362,7 @@ def match_from_list(mydep, candidate_list):
 					if mydep.use.disabled:
 						if any(f in mydep.use.disabled for f in missing_enabled):
 							continue
-						need_disabled = mydep.use.disabled.intersection(use.enabled)
+						need_disabled = mydep.use.disabled & use.enabled
 						if need_disabled:
 							if any(f not in missing_disabled for f in need_disabled):
 								continue


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/dep/
@ 2020-03-03  6:29 Zac Medico
  0 siblings, 0 replies; 10+ messages in thread
From: Zac Medico @ 2020-03-03  6:29 UTC (permalink / raw
  To: gentoo-commits

commit:     e762752a8bf5c19e0d6d7b22de86306bfa4270ba
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Mar  3 06:25:45 2020 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Mar  3 06:27:12 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=e762752a

dep_zapdeps: skip want_update_pkg if parent is None (bug 711400)

Skip the want_update_pkg call when parent is None, since passing
a None parent to want_update_pkg results in an error like this:

  File "libdep/dep_check.py", line 513, in dep_zapdeps
    if graph_interface.want_update_pkg(parent, avail_pkg):
  File "lib/_emerge/depgraph.py", line 5850, in _want_update_pkg
    depth = parent.depth or 0
AttributeError: 'NoneType' object has no attribute 'depth'

Fixes: f7d83d75c6b0 ("dep_zapdeps: adjust || preference for slot upgrades (bug 706278)")
Bug: https://bugs.gentoo.org/711400
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/dep/dep_check.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/portage/dep/dep_check.py b/lib/portage/dep/dep_check.py
index 1dd289eec..9534590bf 100644
--- a/lib/portage/dep/dep_check.py
+++ b/lib/portage/dep/dep_check.py
@@ -510,7 +510,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None,
 		else:
 			new_slot_count = 0
 			for slot_atom, avail_pkg in slot_map.items():
-				if graph_interface.want_update_pkg(parent, avail_pkg):
+				if parent is not None and graph_interface.want_update_pkg(parent, avail_pkg):
 					want_update = True
 				if (not slot_atom.cp.startswith("virtual/")
 					and not graph_db.match_pkgs(slot_atom)):


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/dep/
@ 2020-08-03 19:30 Zac Medico
  0 siblings, 0 replies; 10+ messages in thread
From: Zac Medico @ 2020-08-03 19:30 UTC (permalink / raw
  To: gentoo-commits

commit:     8296e641d825d90b3140599e30701ca625edb6e7
Author:     Aaron Bauman <bman <AT> gentoo <DOT> org>
AuthorDate: Mon Aug  3 19:05:52 2020 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Aug  3 19:22:00 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=8296e641

lib/portage/dep/dep_check.py: drop unused-import

Signed-off-by: Aaron Bauman <bman <AT> gentoo.org>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/dep/dep_check.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/portage/dep/dep_check.py b/lib/portage/dep/dep_check.py
index 625599725..b6491a430 100644
--- a/lib/portage/dep/dep_check.py
+++ b/lib/portage/dep/dep_check.py
@@ -19,7 +19,7 @@ from portage.localization import _
 from portage.util import writemsg, writemsg_level
 from portage.util.digraph import digraph
 from portage.util.SlotObject import SlotObject
-from portage.versions import vercmp, _pkg_str
+from portage.versions import vercmp
 
 def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
 	trees=None, use_mask=None, use_force=None, **kwargs):


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/dep/
@ 2020-08-06  7:02 Zac Medico
  0 siblings, 0 replies; 10+ messages in thread
From: Zac Medico @ 2020-08-06  7:02 UTC (permalink / raw
  To: gentoo-commits

commit:     766683ccfee145b356928eb11cd6969c7928d369
Author:     Aaron Bauman <bman <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  5 23:51:57 2020 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Aug  6 05:57:53 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=766683cc

lib/portage/dep/__init__.py: fix multiple-imports

Signed-off-by: Aaron Bauman <bman <AT> gentoo.org>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/dep/__init__.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/portage/dep/__init__.py b/lib/portage/dep/__init__.py
index 50266a21b..c0ed2dd3c 100644
--- a/lib/portage/dep/__init__.py
+++ b/lib/portage/dep/__init__.py
@@ -13,8 +13,10 @@ __all__ = [
 	'_repo_separator', '_slot_separator',
 ]
 
-import re, sys
+import re
+import sys
 import warnings
+
 from functools import lru_cache
 
 import portage


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/dep/
@ 2020-11-28 20:37 Zac Medico
  0 siblings, 0 replies; 10+ messages in thread
From: Zac Medico @ 2020-11-28 20:37 UTC (permalink / raw
  To: gentoo-commits

commit:     b59e2545a88dccf70e546d49e08a5a99110dd628
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 28 01:04:07 2020 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Nov 28 03:13:02 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=b59e2545

backtracking: fix virtual choices for circular deps (bug 757306)

Fix virtual choices to be consistent with circular dependency
backtracking choices.

Fixes: f78a91e44e3e ("backtracking: adjust || preference to break dependency cycles")
Bug: https://bugs.gentoo.org/757306
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/dep/dep_check.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/portage/dep/dep_check.py b/lib/portage/dep/dep_check.py
index 60c8ec6d0..b89d5d651 100644
--- a/lib/portage/dep/dep_check.py
+++ b/lib/portage/dep/dep_check.py
@@ -356,6 +356,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None,
 
 	# Alias the trees we'll be checking availability against
 	parent   = trees[myroot].get("parent")
+	virt_parent = trees[myroot].get("virt_parent")
 	priority = trees[myroot].get("priority")
 	graph_db = trees[myroot].get("graph_db")
 	graph    = trees[myroot].get("graph")
@@ -596,8 +597,10 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None,
 							if match_from_list(atom, cpv_slot_list):
 								circular_atom = atom
 								break
-						else:
-							for circular_child in circular_dependency.get(parent, []):
+				if circular_atom is None and circular_dependency is not None:
+					for circular_child in itertools.chain(
+								circular_dependency.get(parent, []),
+								circular_dependency.get(virt_parent, [])):
 								for atom in atoms:
 									if not atom.blocker and atom.match(circular_child):
 										circular_atom = atom


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/dep/
@ 2022-03-15  2:52 Matt Turner
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Turner @ 2022-03-15  2:52 UTC (permalink / raw
  To: gentoo-commits

commit:     afcdeffeb038523df511ee4efc3a98cc602499ed
Author:     Wolfgang E. Sanyer <WolfgangESanyer <AT> gmail <DOT> com>
AuthorDate: Thu Sep 23 15:36:10 2021 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Tue Mar 15 02:52:03 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=afcdeffe

portage.dep.Atom: Clean up __new__ parameters

Reviewed-by: Matt Turner <mattst88 <AT> gentoo.org>
Signed-off-by: Wolfgang E. Sanyer <WolfgangESanyer <AT> gmail.com>
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 lib/portage/dep/__init__.py | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/lib/portage/dep/__init__.py b/lib/portage/dep/__init__.py
index 3b3577025..13c0f4ef7 100644
--- a/lib/portage/dep/__init__.py
+++ b/lib/portage/dep/__init__.py
@@ -1489,17 +1489,7 @@ class Atom(str):
         def __init__(self, forbid_overlap=False):
             self.overlap = self._overlap(forbid=forbid_overlap)
 
-    def __new__(
-        cls,
-        s,
-        unevaluated_atom=None,
-        allow_wildcard=False,
-        allow_repo=None,
-        _use=None,
-        eapi=None,
-        is_valid_flag=None,
-        allow_build_id=None,
-    ):
+    def __new__(cls, s, *args, **kwargs):
         return str.__new__(cls, s)
 
     def __init__(


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/dep/
@ 2023-06-29  8:19 Sam James
  0 siblings, 0 replies; 10+ messages in thread
From: Sam James @ 2023-06-29  8:19 UTC (permalink / raw
  To: gentoo-commits

commit:     ca68d224094a6227b27ca90a0827d2abe4ca6177
Author:     Berin Aniesh <berinaniesh <AT> gmail <DOT> com>
AuthorDate: Fri Jun 16 10:41:38 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 29 08:19:27 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=ca68d224

portage: dep: A few type annotations

Signed-off-by: Berin Aniesh <berinaniesh <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/dep/__init__.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/lib/portage/dep/__init__.py b/lib/portage/dep/__init__.py
index d0c5a45cc..b196dd340 100644
--- a/lib/portage/dep/__init__.py
+++ b/lib/portage/dep/__init__.py
@@ -1,7 +1,8 @@
-# deps.py -- Portage dependency resolution functions
-# Copyright 2003-2021 Gentoo Authors
+# Copyright 2003-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
+"""deps.py -- Portage dependency resolution functions"""
+
 __all__ = [
     "Atom",
     "best_match_to_list",
@@ -79,7 +80,7 @@ _extended_cat = r"[\w+*][\w+.*-]*"
 _slot_dep_re_cache = {}
 
 
-def _get_slot_dep_re(eapi_attrs):
+def _get_slot_dep_re(eapi_attrs: portage.eapi._eapi_attrs) -> re.Pattern:
     cache_key = eapi_attrs.slot_operator
     slot_re = _slot_dep_re_cache.get(cache_key)
     if slot_re is not None:
@@ -96,7 +97,11 @@ def _get_slot_dep_re(eapi_attrs):
     return slot_re
 
 
-def _match_slot(atom, pkg):
+def _match_slot(atom, pkg) -> bool:
+    """
+    @type atom: portage.dep.Atom
+    @type pkg: _emerge.Package.Package 
+    """
     if pkg.slot == atom.slot:
         if not atom.sub_slot:
             return True
@@ -108,7 +113,7 @@ def _match_slot(atom, pkg):
 _atom_re = None
 
 
-def _get_atom_re(eapi_attrs):
+def _get_atom_re(eapi_attrs: portage.eapi._eapi_attrs) -> re.Pattern:
     global _atom_re
     if _atom_re is not None:
         return _atom_re


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/dep/
@ 2023-12-10 22:01 Sam James
  0 siblings, 0 replies; 10+ messages in thread
From: Sam James @ 2023-12-10 22:01 UTC (permalink / raw
  To: gentoo-commits

commit:     ee127db438307c133fcf650c148ed594ceb68591
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Sep  4 17:40:06 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Dec 10 22:01:48 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=ee127db4

dep: add comment to _eval_deps wrt binding slot deps in any-of || ( ... )

Bug: https://bugs.gentoo.org/455904
Bug: https://bugs.gentoo.org/489458
Bug: https://bugs.gentoo.org/586238
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/dep/_slot_operator.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/portage/dep/_slot_operator.py b/lib/portage/dep/_slot_operator.py
index 82dd7d66c9..d3f506450f 100644
--- a/lib/portage/dep/_slot_operator.py
+++ b/lib/portage/dep/_slot_operator.py
@@ -91,6 +91,7 @@ def _eval_deps(dep_struct, vardbs):
     # and B installed should record subslot on A only since the package is
     # supposed to link against that anyway, and we have no guarantee that B
     # has matching ABI.
+    # See bug #455904, bug #489458, bug #586238.
 
     for i, x in enumerate(dep_struct):
         if isinstance(x, list):


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-12-10 22:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-15  2:52 [gentoo-commits] proj/portage:master commit in: lib/portage/dep/ Matt Turner
  -- strict thread matches above, loose matches on Subject: below --
2023-12-10 22:01 Sam James
2023-06-29  8:19 Sam James
2020-11-28 20:37 Zac Medico
2020-08-06  7:02 Zac Medico
2020-08-03 19:30 Zac Medico
2020-03-03  6:29 Zac Medico
2019-10-23 17:03 Zac Medico
2019-05-11 20:45 Zac Medico
2019-05-04 21:09 Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox