Gentoo Archives: gentoo-commits

From: "Marius Mauch (genone)" <genone@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r11581 - in main/trunk/pym: _emerge portage/sets
Date: Sun, 28 Sep 2008 16:08:55
Message-Id: E1KjypI-0008A9-UQ@stork.gentoo.org
1 Author: genone
2 Date: 2008-09-28 16:08:50 +0000 (Sun, 28 Sep 2008)
3 New Revision: 11581
4
5 Modified:
6 main/trunk/pym/_emerge/__init__.py
7 main/trunk/pym/portage/sets/__init__.py
8 Log:
9 implement set arguments to reconfigure and create package sets on the commandline
10
11 Modified: main/trunk/pym/_emerge/__init__.py
12 ===================================================================
13 --- main/trunk/pym/_emerge/__init__.py 2008-09-28 14:53:35 UTC (rev 11580)
14 +++ main/trunk/pym/_emerge/__init__.py 2008-09-28 16:08:50 UTC (rev 11581)
15 @@ -13395,12 +13395,38 @@
16 myfiles = newargs
17 del newargs
18 newargs = []
19 +
20 + # separators for set arguments
21 + ARG_START = "{"
22 + ARG_END = "}"
23
24 + for i in range(0, len(myfiles)):
25 + if myfiles[i].startswith(SETPREFIX):
26 + x = myfiles[i][len(SETPREFIX):]
27 + start = x.find(ARG_START)
28 + end = x.find(ARG_END)
29 + if start > 0 and start < end:
30 + namepart = x[:start]
31 + argpart = x[start+1:end]
32 +
33 + # TODO: implement proper quoting
34 + args = argpart.split(",")
35 + options = {}
36 + for a in args:
37 + if "=" in a:
38 + k, v = a.split("=", 1)
39 + options[k] = v
40 + else:
41 + options[a] = "True"
42 + setconfig.update(namepart, options)
43 + myfiles[i] = SETPREFIX + namepart
44 + sets = setconfig.getSets()
45 +
46 # WARNING: all operators must be of equal length
47 IS_OPERATOR = "/@"
48 DIFF_OPERATOR = "-@"
49 UNION_OPERATOR = "+@"
50 -
51 +
52 for a in myfiles:
53 if a.startswith(SETPREFIX):
54 # support simple set operations (intersection, difference and union)
55
56 Modified: main/trunk/pym/portage/sets/__init__.py
57 ===================================================================
58 --- main/trunk/pym/portage/sets/__init__.py 2008-09-28 14:53:35 UTC (rev 11580)
59 +++ main/trunk/pym/portage/sets/__init__.py 2008-09-28 16:08:50 UTC (rev 11581)
60 @@ -33,6 +33,29 @@
61 self._parsed = False
62 self.active = []
63
64 + def update(self, setname, options):
65 + self.errors = []
66 + if not setname in self.psets:
67 + options["name"] = setname
68 +
69 + # for the unlikely case that there is already a section with the requested setname
70 + import random
71 + while setname in self.sections():
72 + setname = "%08d" % random.randint(0, 10**10)
73 +
74 + self.add_section(setname)
75 + for k, v in options.items():
76 + self.set(setname, k, v)
77 + else:
78 + section = self.psets[setname].creator
79 + if self.has_option(section, "multiset") and self.getboolean(section, "multiset"):
80 + self.errors.append("Invalid request to reconfigure set '%s' generated by multiset section '%s'" % (setname, section))
81 + return
82 + for k, v in options.items():
83 + self.set(section, k, v)
84 + self._parsed = False
85 + self._parse()
86 +
87 def _parse(self):
88 if self._parsed:
89 return