summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-09-12 16:09:40 +0000
committerZac Medico <zmedico@gentoo.org>2009-09-12 16:09:40 +0000
commit903edae2a5f4b34a0ed8b1a552f3307c23735672 (patch)
tree011597962e44ff702e02893868cb54f383eae447
parent66df844e6366fdc0650b2404bcd9a0e4e6563fe1 (diff)
downloadportage-903edae2a5f4b34a0ed8b1a552f3307c23735672.tar.gz
portage-903edae2a5f4b34a0ed8b1a552f3307c23735672.tar.bz2
portage-903edae2a5f4b34a0ed8b1a552f3307c23735672.zip
Make parse_updates() and update_dbentry() use Atom instances.
svn path=/main/trunk/; revision=14230
-rw-r--r--pym/portage/update.py36
1 files changed, 27 insertions, 9 deletions
diff --git a/pym/portage/update.py b/pym/portage/update.py
index 56e6709c0..9b51eb75f 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -13,7 +13,7 @@ from portage import _unicode_decode
from portage import _unicode_encode
import portage
portage.proxy.lazyimport.lazyimport(globals(),
- 'portage.dep:dep_getkey,get_operator,isvalidatom,isjustname,remove_slot',
+ 'portage.dep:Atom,dep_getkey,get_operator,isvalidatom,remove_slot',
'portage.util:ConfigProtect,grabfile,new_protect_filename,' + \
'normalize_path,write_atomic,writemsg',
'portage.versions:ververify'
@@ -27,8 +27,9 @@ ignored_dbentries = ("CONTENTS", "environment.bz2")
def update_dbentry(update_cmd, mycontent):
if update_cmd[0] == "move":
- old_value, new_value = update_cmd[1], update_cmd[2]
+ old_value = str(update_cmd[1])
if old_value in mycontent:
+ new_value = str(update_cmd[2])
old_value = re.escape(old_value);
mycontent = re.sub(old_value+"(:|$|\\s)", new_value+"\\1", mycontent)
def myreplace(matchobj):
@@ -41,7 +42,7 @@ def update_dbentry(update_cmd, mycontent):
else:
return "".join(matchobj.groups())
mycontent = re.sub("(%s-)(\\S*)" % old_value, myreplace, mycontent)
- elif update_cmd[0] == "slotmove" and get_operator(update_cmd[1]) is None:
+ elif update_cmd[0] == "slotmove" and update_cmd[1].operator is None:
pkg, origslot, newslot = update_cmd[1:]
old_value = "%s:%s" % (pkg, origslot)
if old_value in mycontent:
@@ -137,21 +138,38 @@ def parse_updates(mycontent):
if len(mysplit) != 3:
errors.append(_("ERROR: Update command invalid '%s'") % myline)
continue
- orig_value, new_value = mysplit[1], mysplit[2]
- for cp in (orig_value, new_value):
- if not (isvalidatom(cp) and isjustname(cp)):
+ for i in (1, 2):
+ try:
+ atom = Atom(mysplit[i])
+ except InvalidAtom:
+ atom = None
+ else:
+ if atom.blocker or atom != atom.cp:
+ atom = None
+ if atom is not None:
+ mysplit[i] = atom
+ else:
errors.append(
_("ERROR: Malformed update entry '%s'") % myline)
- continue
+ break
if mysplit[0] == "slotmove":
if len(mysplit)!=4:
errors.append(_("ERROR: Update command invalid '%s'") % myline)
continue
pkg, origslot, newslot = mysplit[1], mysplit[2], mysplit[3]
- if not isvalidatom(pkg):
+ try:
+ atom = Atom(pkg)
+ except InvalidAtom:
+ atom = None
+ else:
+ if atom.blocker:
+ atom = None
+ if atom is not None:
+ mysplit[1] = atom
+ else:
errors.append(_("ERROR: Malformed update entry '%s'") % myline)
continue
-
+
# The list of valid updates is filtered by continue statements above.
myupd.append(mysplit)
return myupd, errors