summaryrefslogtreecommitdiffstats
path: root/pym/portage_dep.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-07-21 05:06:43 +0000
committerZac Medico <zmedico@gentoo.org>2006-07-21 05:06:43 +0000
commit1abb6eedb8e4394564169528cfc3f583c01554b6 (patch)
tree478e2691d86739293b9716ded9e214dd56cda1bb /pym/portage_dep.py
parent4a031c34483f749c68ad9ab66dfe8f4ce89275f5 (diff)
downloadportage-1abb6eedb8e4394564169528cfc3f583c01554b6.tar.gz
portage-1abb6eedb8e4394564169528cfc3f583c01554b6.tar.bz2
portage-1abb6eedb8e4394564169528cfc3f583c01554b6.zip
Move dep_getcpv, get_operator, and isvalidatom from the core portage module to portage_dep.
svn path=/main/trunk/; revision=3974
Diffstat (limited to 'pym/portage_dep.py')
-rw-r--r--pym/portage_dep.py57
1 files changed, 57 insertions, 0 deletions
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