From e5998321056d36efdc0f8c4d554f166c3516c438 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 21 Jul 2006 05:59:27 +0000 Subject: Move parse_updates from the core portage module to portage_update. svn path=/main/trunk/; revision=3977 --- pym/portage.py | 36 +----------------------------------- pym/portage_update.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/pym/portage.py b/pym/portage.py index cb8e239a9..83aa0c993 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -91,7 +91,7 @@ try: from portage_checksum import perform_md5,perform_checksum,prelink_capable import eclass_cache from portage_localization import _ - from portage_update import fixdbentries, update_dbentries, grab_updates + from portage_update import fixdbentries, grab_updates, parse_updates, update_dbentries # Need these functions directly in portage namespace to not break every external tool in existence from portage_versions import ververify,vercmp,catsplit,catpkgsplit,pkgsplit,pkgcmp @@ -6703,40 +6703,6 @@ def getvirtuals(myroot): writemsg("--- DEPRECATED call to getvirtual\n") return settings.getvirtuals(myroot) -def parse_updates(mycontent): - """Valid updates are returned as a list of split update commands.""" - myupd = [] - errors = [] - mylines = mycontent.splitlines() - for myline in mylines: - mysplit = myline.split() - if len(mysplit) == 0: - continue - if mysplit[0] not in ("move", "slotmove"): - errors.append("ERROR: Update type not recognized '%s'" % myline) - continue - if mysplit[0]=="move": - 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)): - errors.append("ERROR: Malformed update entry '%s'" % myline) - continue - 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): - 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 - def commit_mtimedb(mydict=None, filename=None): if mydict is None: global mtimedb diff --git a/pym/portage_update.py b/pym/portage_update.py index 510ef4ce3..000514bf4 100644 --- a/pym/portage_update.py +++ b/pym/portage_update.py @@ -6,6 +6,7 @@ import errno, os, re from portage_util import write_atomic from portage_exception import DirectoryNotFound +from portage_dep import isvalidatom, isjustname ignored_dbentries = ("CONTENTS", "environment.bz2") @@ -83,3 +84,38 @@ def grab_updates(updpath, prev_mtimes=None): f.close() update_data.append((file_path, mystat, content)) return update_data + +def parse_updates(mycontent): + """Valid updates are returned as a list of split update commands.""" + myupd = [] + errors = [] + mylines = mycontent.splitlines() + for myline in mylines: + mysplit = myline.split() + if len(mysplit) == 0: + continue + if mysplit[0] not in ("move", "slotmove"): + errors.append("ERROR: Update type not recognized '%s'" % myline) + continue + if mysplit[0] == "move": + 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)): + errors.append( + "ERROR: Malformed update entry '%s'" % myline) + continue + 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): + 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 -- cgit v1.2.3-1-g7c22