From 1abb6eedb8e4394564169528cfc3f583c01554b6 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 21 Jul 2006 05:06:43 +0000 Subject: [PATCH] Move dep_getcpv, get_operator, and isvalidatom from the core portage module to portage_dep. svn path=/main/trunk/; revision=3974 --- pym/portage.py | 58 +--------------------------------------------- pym/portage_dep.py | 57 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 57 deletions(-) diff --git a/pym/portage.py b/pym/portage.py index 3659839b3..f4f01c3e8 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -54,6 +54,7 @@ try: import xpak import getbinpkg import portage_dep + from portage_dep import dep_getcpv, get_operator, isvalidatom # XXX: This needs to get cleaned up. import output @@ -3180,28 +3181,6 @@ def unmerge(cat, pkg, myroot, mysettings, mytrimworld=1, vartree=None, ldpath_mt return 0 return 1 -def isvalidatom(atom): - mycpv_cps = catpkgsplit(dep_getcpv(atom)) - operator = get_operator(atom) - if operator: - if operator[0] in "<>" and atom[-1] == "*": - return 0 - if mycpv_cps and mycpv_cps[0] != "null": - # >=cat/pkg-1.0 - return 1 - else: - # >=cat/pkg or >=pkg-1.0 (no category) - return 0 - if mycpv_cps: - # cat/pkg-1.0 - return 0 - - if (len(string.split(atom, '/'))==2): - # cat/pkg - return 1 - else: - return 0 - def isjustname(mypkg): myparts=string.split(mypkg,'-') for x in myparts: @@ -3384,19 +3363,6 @@ def dep_getkey(mydep): else: return mydep -def dep_getcpv(mydep): - if mydep and mydep[0]=="*": - mydep=mydep[1:] - if mydep and mydep[-1]=="*": - mydep=mydep[:-1] - if mydep and mydep[0]=="!": - mydep=mydep[1:] - if mydep[:2] in [ ">=", "<=" ]: - mydep=mydep[2:] - elif mydep[:1] in "=<>~": - mydep=mydep[1:] - return mydep - def dep_transform(mydep,oldkey,newkey): origdep=mydep if not len(mydep): @@ -3848,28 +3814,6 @@ def best_match_to_list(mypkg,mylist): bestm = x return bestm -def get_operator(mydep): - """ - returns '~', '=', '>', '<', '=*', '>=', or '<=' - """ - if mydep[0] == "~": - operator = "~" - elif mydep[0] == "=": - if mydep[-1] == "*": - operator = "=*" - else: - operator = "=" - elif mydep[0] in "><": - if len(mydep) > 1 and mydep[1] == "=": - operator = mydep[0:2] - else: - operator = mydep[0] - else: - operator = None - - return operator - - def match_from_list(mydep,candidate_list): if mydep[0] == "!": mydep = mydep[1:] diff --git a/pym/portage_dep.py b/pym/portage_dep.py index ece3c72dc..32aacc666 100644 --- a/pym/portage_dep.py +++ b/pym/portage_dep.py @@ -20,6 +20,7 @@ import os,string,types,sys,copy import portage_exception +from portage_versions import catpkgsplit def strip_empty(myarr): for x in range(len(myarr)-1, -1, -1): @@ -161,3 +162,59 @@ def dep_opconvert(deplist): retlist.append(deplist[x]) x += 1 return retlist + +def get_operator(mydep): + """ + returns '~', '=', '>', '<', '=*', '>=', or '<=' + """ + if mydep[0] == "~": + operator = "~" + elif mydep[0] == "=": + if mydep[-1] == "*": + operator = "=*" + else: + operator = "=" + elif mydep[0] in "><": + if len(mydep) > 1 and mydep[1] == "=": + operator = mydep[0:2] + else: + operator = mydep[0] + else: + operator = None + + return operator + +def dep_getcpv(mydep): + if mydep and mydep[0] == "*": + mydep = mydep[1:] + if mydep and mydep[-1] == "*": + mydep = mydep[:-1] + if mydep and mydep[0] == "!": + mydep = mydep[1:] + if mydep[:2] in [">=", "<="]: + mydep = mydep[2:] + elif mydep[:1] in "=<>~": + mydep = mydep[1:] + return mydep + +def isvalidatom(atom): + mycpv_cps = catpkgsplit(dep_getcpv(atom)) + operator = get_operator(atom) + if operator: + if operator[0] in "<>" and atom[-1] == "*": + return 0 + if mycpv_cps and mycpv_cps[0] != "null": + # >=cat/pkg-1.0 + return 1 + else: + # >=cat/pkg or >=pkg-1.0 (no category) + return 0 + if mycpv_cps: + # cat/pkg-1.0 + return 0 + + if (len(atom.split('/')) == 2): + # cat/pkg + return 1 + else: + return 0 -- 2.26.2