From 5d24ea892f7c91771b0b703b14338baf8f3957fb Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 3 Sep 2008 14:47:31 +0000 Subject: bitbake utils.py: Add explode_dep_versions, an improved version of explode_deps git-svn-id: https://svn.o-hand.com/repos/poky/trunk@5128 311d38ba-8fff-0310-9ca6-ca027cbcb966 --- bitbake/lib/bb/utils.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'bitbake') diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index ec46021b5..211ac8129 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py @@ -96,7 +96,34 @@ def explode_deps(s): #r[-1] += ' ' + ' '.join(j) return r +def explode_dep_versions(s): + """ + Take an RDEPENDS style string of format: + "DEPEND1 (optional version) DEPEND2 (optional version) ..." + and return a dictonary of dependencies and versions. + """ + r = {} + l = s.split() + lastdep = None + lastver = "" + inversion = False + for i in l: + if i[0] == '(': + inversion = True + lastver = i[1:] or "" + #j = [] + elif inversion and i.endswith(')'): + inversion = False + lastver = lastver + " " + (i[:-1] or "") + r[lastdep] = lastver + elif not inversion: + r[i] = None + lastdep = i + lastver = "" + elif inversion: + lastver = lastver + " " + i + return r def _print_trace(body, line): """ -- cgit v1.2.3