Fix ba7d00f5 for gentoo pkg.installed

The commit ba7d00f5 change _cpv_to_cp inner implementation, but the
original parameter cpv is not changed, its format is `<p>-<v>`, and
`dep_getkey` need format for `=<p>-<v>` if `cpv` with version, so it cause
`InvalidAtom` exception and actually return cpv itself. So I add the
original implementation back to fix this problem and still keep
`dep_getkey` if the cpv format will be fixed in the future
This commit is contained in:
Tanky Woo 2018-04-13 14:41:54 +08:00
parent 5b7544eaa0
commit 551f4e10cf
2 changed files with 21 additions and 0 deletions

View file

@ -90,6 +90,13 @@ def _p_to_cp(p):
except portage.exception.InvalidAtom:
pass
try:
ret = _porttree().dbapi.xmatch("match-all", p)
if ret:
return portage.cpv_getkey(ret[0])
except portage.exception.InvalidAtom:
pass
return None
@ -110,6 +117,13 @@ def _cpv_to_cp(cpv):
except portage.exception.InvalidAtom:
pass
try:
ret = portage.cpv_getkey(cpv)
if ret:
return ret
except portage.exception.InvalidAtom:
pass
return cpv

View file

@ -111,6 +111,13 @@ def _p_to_cp(p):
except portage.exception.InvalidAtom:
pass
try:
ret = _porttree().dbapi.xmatch("match-all", p)
if ret:
return portage.cpv_getkey(ret[0])
except portage.exception.InvalidAtom:
pass
return None