From 5883ba88a08f0d8f802b7ca3a251f0165f902b1a Mon Sep 17 00:00:00 2001 From: Marius Mauch Date: Sun, 28 Sep 2008 17:02:51 +0000 Subject: Properly process set arguments inside set expressions svn path=/main/trunk/; revision=11583 --- pym/_emerge/__init__.py | 86 +++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 38 deletions(-) (limited to 'pym/_emerge') diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 39ab9f661..f533a0eb6 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -13362,25 +13362,8 @@ def expand_set_arguments(myfiles, myaction, root_config): retval = os.EX_OK setconfig = root_config.setconfig - # display errors that occured while loading the SetConfig instance - for e in setconfig.errors: - print colorize("BAD", "Error during set creation: %s" % e) - sets = setconfig.getSets() - # emerge relies on the existance of sets with names "world" and "system" - required_sets = ("world", "system") - - for s in required_sets: - if s not in sets: - msg = ["emerge: incomplete set configuration, " + \ - "no \"%s\" set defined" % s] - msg.append(" sets defined: %s" % ", ".join(sets)) - for line in msg: - sys.stderr.write(line + "\n") - retval = 1 - unmerge_actions = ("unmerge", "prune", "clean", "depclean") - # In order to know exactly which atoms/sets should be added to the # world file, the depgraph performs set expansion later. It will get # confused about where the atoms came from if it's not allowed to @@ -13399,34 +13382,61 @@ def expand_set_arguments(myfiles, myaction, root_config): # separators for set arguments ARG_START = "{" ARG_END = "}" + + # WARNING: all operators must be of equal length + IS_OPERATOR = "/@" + DIFF_OPERATOR = "-@" + UNION_OPERATOR = "+@" for i in range(0, len(myfiles)): if myfiles[i].startswith(SETPREFIX): + start = 0 + end = 0 x = myfiles[i][len(SETPREFIX):] - start = x.find(ARG_START) - end = x.find(ARG_END) - if start > 0 and start < end: - namepart = x[:start] - argpart = x[start+1:end] + newset = "" + while x: + start = x.find(ARG_START) + end = x.find(ARG_END) + if start > 0 and start < end: + namepart = x[:start] + argpart = x[start+1:end] + + # TODO: implement proper quoting + args = argpart.split(",") + options = {} + for a in args: + if "=" in a: + k, v = a.split("=", 1) + options[k] = v + else: + options[a] = "True" + setconfig.update(namepart, options) + newset += (x[:start-len(namepart)]+namepart) + x = x[end+len(ARG_END):] + else: + newset += x + x = "" + myfiles[i] = SETPREFIX+newset - # TODO: implement proper quoting - args = argpart.split(",") - options = {} - for a in args: - if "=" in a: - k, v = a.split("=", 1) - options[k] = v - else: - options[a] = "True" - setconfig.update(namepart, options) - myfiles[i] = SETPREFIX + namepart sets = setconfig.getSets() - # WARNING: all operators must be of equal length - IS_OPERATOR = "/@" - DIFF_OPERATOR = "-@" - UNION_OPERATOR = "+@" - + # display errors that occured while loading the SetConfig instance + for e in setconfig.errors: + print colorize("BAD", "Error during set creation: %s" % e) + + # emerge relies on the existance of sets with names "world" and "system" + required_sets = ("world", "system") + + for s in required_sets: + if s not in sets: + msg = ["emerge: incomplete set configuration, " + \ + "no \"%s\" set defined" % s] + msg.append(" sets defined: %s" % ", ".join(sets)) + for line in msg: + sys.stderr.write(line + "\n") + retval = 1 + unmerge_actions = ("unmerge", "prune", "clean", "depclean") + for a in myfiles: if a.startswith(SETPREFIX): # support simple set operations (intersection, difference and union) -- cgit v1.2.3-1-g7c22