public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/portage/, pym/portage/dep/
@ 2012-07-18  1:43 Zac Medico
  0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2012-07-18  1:43 UTC (permalink / raw
  To: gentoo-commits

commit:     b5956d62d08882a8565d3ef98afa3a1d65090cb7
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 18 01:42:10 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Jul 18 01:42:10 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b5956d62

portage.update: use isvalidatom for EAPI check

---
 pym/portage/dbapi/bintree.py |   15 ++++++++++-----
 pym/portage/dbapi/vartree.py |   11 +++++++----
 pym/portage/dep/__init__.py  |   12 ++++++++++--
 pym/portage/update.py        |   13 +++++++------
 4 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 8072542..9527b07 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -7,8 +7,7 @@ import portage
 portage.proxy.lazyimport.lazyimport(globals(),
 	'portage.checksum:hashfunc_map,perform_multiple_checksums,verify_all',
 	'portage.dbapi.dep_expand:dep_expand',
-	'portage.dep:dep_getkey,isjustname,match_from_list',
-	'portage.eapi:_get_eapi_attrs',
+	'portage.dep:dep_getkey,isjustname,isvalidatom,match_from_list',
 	'portage.output:EOutput,colorize',
 	'portage.locks:lockfile,unlockfile',
 	'portage.package.ebuild.fetch:_check_distfile,_hide_url_passwd',
@@ -49,8 +48,11 @@ except ImportError:
 	from urlparse import urlparse
 
 if sys.hexversion >= 0x3000000:
+	_unicode = str
 	basestring = str
 	long = int
+else:
+	_unicode = unicode
 
 class bindbapi(fakedbapi):
 	_known_keys = frozenset(list(fakedbapi._known_keys) + \
@@ -389,10 +391,13 @@ class binarytree(object):
 			if repo_match is not None \
 				and not repo_match(mycpv.repo):
 				continue
-			eapi_attrs = _get_eapi_attrs(mycpv.eapi)
-			if not eapi_attrs.dots_in_PN and "." in catsplit(newcp)[1]:
+
+			# Use isvalidatom() to check if this move is valid for the
+			# EAPI (characters allowed in package names may vary).
+			if not isvalidatom(newcp, eapi=mycpv.eapi):
 				continue
-			mynewcpv = mycpv.replace(mycpv_cp, str(newcp), 1)
+
+			mynewcpv = mycpv.replace(mycpv_cp, _unicode(newcp), 1)
 			myoldpkg = catsplit(mycpv)[1]
 			mynewpkg = catsplit(mynewcpv)[1]
 

diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 0ae7dc5..ea62f6b 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -11,7 +11,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
 	'portage.data:portage_gid,portage_uid,secpass',
 	'portage.dbapi.dep_expand:dep_expand',
 	'portage.dbapi._MergeProcess:MergeProcess',
-	'portage.dep:dep_getkey,isjustname,match_from_list,' + \
+	'portage.dep:dep_getkey,isjustname,isvalidatom,match_from_list,' + \
 	 	'use_reduce,_get_slot_re',
 	'portage.eapi:_get_eapi_attrs',
 	'portage.elog:collect_ebuild_messages,collect_messages,' + \
@@ -332,10 +332,13 @@ class vardbapi(dbapi):
 			if repo_match is not None \
 				and not repo_match(mycpv.repo):
 				continue
-			eapi_attrs = _get_eapi_attrs(mycpv.eapi)
-			if not eapi_attrs.dots_in_PN and "." in catsplit(newcp)[1]:
+
+			# Use isvalidatom() to check if this move is valid for the
+			# EAPI (characters allowed in package names may vary).
+			if not isvalidatom(newcp, eapi=mycpv.eapi):
 				continue
-			mynewcpv = mycpv.replace(mycpv_cp, str(newcp), 1)
+
+			mynewcpv = mycpv.replace(mycpv_cp, _unicode(newcp), 1)
 			mynewcat = catsplit(newcp)[0]
 			origpath = self.getpath(mycpv)
 			if not os.path.exists(origpath):

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index d71ec09..f0d07a5 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -1224,6 +1224,7 @@ class Atom(_unicode):
 		eapi_attrs = _get_eapi_attrs(eapi)
 		atom_re = _get_atom_re(eapi_attrs)
 
+		self.__dict__['eapi'] = eapi
 		if eapi is not None:
 			# Ignore allow_repo when eapi is specified.
 			allow_repo = eapi_attrs.repo_deps
@@ -1850,7 +1851,8 @@ def dep_getusedeps( depend ):
 		open_bracket = depend.find( '[', open_bracket+1 )
 	return tuple(use_list)
 
-def isvalidatom(atom, allow_blockers=False, allow_wildcard=False, allow_repo=False):
+def isvalidatom(atom, allow_blockers=False, allow_wildcard=False,
+	allow_repo=False, eapi=None):
 	"""
 	Check to see if a depend atom is valid
 
@@ -1867,9 +1869,15 @@ def isvalidatom(atom, allow_blockers=False, allow_wildcard=False, allow_repo=Fal
 		1) False if the atom is invalid
 		2) True if the atom is valid
 	"""
+
+	if eapi is not None and isinstance(atom, Atom) and atom.eapi != eapi:
+		# We'll construct a new atom with the given eapi.
+		atom = _unicode(atom)
+
 	try:
 		if not isinstance(atom, Atom):
-			atom = Atom(atom, allow_wildcard=allow_wildcard, allow_repo=allow_repo)
+			atom = Atom(atom, allow_wildcard=allow_wildcard,
+				allow_repo=allow_repo, eapi=eapi)
 		if not allow_blockers and atom.blocker:
 			return False
 		return True

diff --git a/pym/portage/update.py b/pym/portage/update.py
index c9c2af9..da8503e 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -36,13 +36,14 @@ else:
 ignored_dbentries = ("CONTENTS", "environment.bz2")
 
 def update_dbentry(update_cmd, mycontent, eapi=None):
-	eapi_attrs = _get_eapi_attrs(eapi)
+
 	if update_cmd[0] == "move":
-		avoid_dots_in_PN = (not eapi_attrs.dots_in_PN and
-			"." in catsplit(update_cmd[2].cp)[1])
-		if not avoid_dots_in_PN and _unicode(update_cmd[1]) in mycontent:
-			old_value = _unicode(update_cmd[1])
-			new_value = _unicode(update_cmd[2])
+		old_value = _unicode(update_cmd[1])
+		new_value = _unicode(update_cmd[2])
+
+		# Use isvalidatom() to check if this move is valid for the
+		# EAPI (characters allowed in package names may vary).
+		if old_value in mycontent and isvalidatom(new_value, eapi=eapi):
 			old_value = re.escape(old_value);
 			mycontent = re.sub(old_value+"(:|$|\\s)", new_value+"\\1", mycontent)
 			def myreplace(matchobj):



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

* [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/portage/, pym/portage/dep/
@ 2013-03-19 19:38 Zac Medico
  0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2013-03-19 19:38 UTC (permalink / raw
  To: gentoo-commits

commit:     f6df65e2d97a42659e4f2f3cb3243e6187d32f5a
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 19 19:33:57 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Mar 19 19:33:57 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f6df65e2

_get_slot_re: relocate due to circular import

---
 pym/portage/dbapi/vartree.py |    4 ++--
 pym/portage/dep/__init__.py  |   21 +--------------------
 pym/portage/update.py        |    4 ++--
 pym/portage/versions.py      |   23 ++++++++++++++++++++++-
 4 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index d011c33..77220bb 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -15,7 +15,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
 	'portage.dbapi._MergeProcess:MergeProcess',
 	'portage.dbapi._SyncfsProcess:SyncfsProcess',
 	'portage.dep:dep_getkey,isjustname,isvalidatom,match_from_list,' + \
-	 	'use_reduce,_get_slot_re,_slot_separator,_repo_separator',
+	 	'use_reduce,_slot_separator,_repo_separator',
 	'portage.eapi:_get_eapi_attrs',
 	'portage.elog:collect_ebuild_messages,collect_messages,' + \
 		'elog_process,_merge_logentries',
@@ -38,7 +38,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
 	'portage.util._eventloop.EventLoop:EventLoop',
 	'portage.util._eventloop.global_event_loop:global_event_loop',
 	'portage.versions:best,catpkgsplit,catsplit,cpv_getkey,vercmp,' + \
-		'_pkgsplit@pkgsplit,_pkg_str,_unknown_repo',
+		'_get_slot_re,_pkgsplit@pkgsplit,_pkg_str,_unknown_repo',
 	'subprocess',
 	'tarfile',
 )

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 1edbab7..6f3b357 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -29,7 +29,7 @@ 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, _unknown_repo
+	vercmp, ververify, _cp, _cpv, _pkg_str, _slot, _unknown_repo
 import portage.cache.mappings
 
 if sys.hexversion >= 0x3000000:
@@ -43,7 +43,6 @@ else:
 # PMS 3.1.3: A slot name may contain any of the characters [A-Za-z0-9+_.-].
 # It must not begin with a hyphen or a dot.
 _slot_separator = ":"
-_slot = r'([\w+][\w+.-]*)'
 # loosly match SLOT, which may have an optional ABI part
 _slot_loose = r'([\w+./*=-]+)'
 
@@ -57,24 +56,6 @@ _repo = r'(?:' + _repo_separator + '(' + _repo_name + ')' + ')?'
 
 _extended_cat = r'[\w+*][\w+.*-]*'
 
-_slot_re_cache = {}
-
-def _get_slot_re(eapi_attrs):
-	cache_key = eapi_attrs.slot_operator
-	slot_re = _slot_re_cache.get(cache_key)
-	if slot_re is not None:
-		return slot_re
-
-	if eapi_attrs.slot_operator:
-		slot_re = _slot + r'(/' + _slot + r')?'
-	else:
-		slot_re = _slot
-
-	slot_re = re.compile('^' + slot_re + '$', re.VERBOSE | re.UNICODE)
-
-	_slot_re_cache[cache_key] = slot_re
-	return slot_re
-
 _slot_dep_re_cache = {}
 
 def _get_slot_dep_re(eapi_attrs):

diff --git a/pym/portage/update.py b/pym/portage/update.py
index be52164..92aba9a 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -16,13 +16,13 @@ from portage import _unicode_decode
 from portage import _unicode_encode
 import portage
 portage.proxy.lazyimport.lazyimport(globals(),
-	'portage.dep:Atom,dep_getkey,isvalidatom,_get_slot_re',
+	'portage.dep:Atom,dep_getkey,isvalidatom,match_from_list',
 	'portage.util:ConfigProtect,new_protect_filename,' + \
 		'normalize_path,write_atomic,writemsg',
+	'portage.versions:_get_slot_re',
 )
 
 from portage.const import USER_CONFIG_PATH, VCS_DIRS
-from portage.dep import match_from_list
 from portage.eapi import _get_eapi_attrs
 from portage.exception import DirectoryNotFound, InvalidAtom, PortageException
 from portage.localization import _

diff --git a/pym/portage/versions.py b/pym/portage/versions.py
index 46c5308..3bfc388 100644
--- a/pym/portage/versions.py
+++ b/pym/portage/versions.py
@@ -21,7 +21,6 @@ else:
 
 import portage
 portage.proxy.lazyimport.lazyimport(globals(),
-	'portage.dep:_get_slot_re',
 	'portage.repository.config:_gen_valid_repo',
 	'portage.util:cmp_sort_key',
 )
@@ -34,6 +33,10 @@ _unknown_repo = "__unknown__"
 
 # \w is [a-zA-Z0-9_]
 
+# PMS 3.1.3: A slot name may contain any of the characters [A-Za-z0-9+_.-].
+# It must not begin with a hyphen or a dot.
+_slot = r'([\w+][\w+.-]*)'
+
 # 2.1.1 A category name may contain any of the characters [A-Za-z0-9+_.-].
 # It must not begin with a hyphen or a dot.
 _cat = r'[\w+][\w+.-]*'
@@ -68,6 +71,24 @@ suffix_regexp = re.compile("^(alpha|beta|rc|pre|p)(\\d*)$")
 suffix_value = {"pre": -2, "p": 0, "alpha": -4, "beta": -3, "rc": -1}
 endversion_keys = ["pre", "p", "alpha", "beta", "rc"]
 
+_slot_re_cache = {}
+
+def _get_slot_re(eapi_attrs):
+	cache_key = eapi_attrs.slot_operator
+	slot_re = _slot_re_cache.get(cache_key)
+	if slot_re is not None:
+		return slot_re
+
+	if eapi_attrs.slot_operator:
+		slot_re = _slot + r'(/' + _slot + r')?'
+	else:
+		slot_re = _slot
+
+	slot_re = re.compile('^' + slot_re + '$', re.VERBOSE | re.UNICODE)
+
+	_slot_re_cache[cache_key] = slot_re
+	return slot_re
+
 _pv_re_cache = {}
 
 def _get_pv_re(eapi_attrs):


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

end of thread, other threads:[~2013-03-19 19:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-19 19:38 [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/portage/, pym/portage/dep/ Zac Medico
  -- strict thread matches above, loose matches on Subject: below --
2012-07-18  1:43 Zac Medico

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