Gentoo Archives: gentoo-commits

From: "André Erdmann" <dywi@×××××××.de>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/depres/simpledeprule/
Date: Wed, 03 Jul 2013 10:05:04
Message-Id: 1372845837.6cb202e96bfd7e9e34bdc0abe64688595ab8142b.dywi@gentoo
1 commit: 6cb202e96bfd7e9e34bdc0abe64688595ab8142b
2 Author: André Erdmann <dywi <AT> mailerd <DOT> de>
3 AuthorDate: Wed Jul 3 09:59:16 2013 +0000
4 Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
5 CommitDate: Wed Jul 3 10:03:57 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=6cb202e9
7
8 roverlay/depres: restrict calculated slot value
9
10 This commit changes the behavior when using slot restrictions.
11 A slot value is now accepted if the _calculated_ slot value (taken from the dep
12 strings version) is in the list of allowed values. This is only relevant for
13 rules that use "immediate" slot values.
14
15 ---
16 roverlay/depres/simpledeprule/rules.py | 26 ++++++++++------------
17 roverlay/depres/simpledeprule/util.py | 40 +++++++++++++++++++++++-----------
18 2 files changed, 39 insertions(+), 27 deletions(-)
19
20 diff --git a/roverlay/depres/simpledeprule/rules.py b/roverlay/depres/simpledeprule/rules.py
21 index 999a8b4..dea5f38 100644
22 --- a/roverlay/depres/simpledeprule/rules.py
23 +++ b/roverlay/depres/simpledeprule/rules.py
24 @@ -308,15 +308,6 @@ class SimpleFuzzySlotDependencyRule ( FuzzySimpleRule ):
25 # --- end of noexport (...) ---
26
27 def get_resolving_str ( self ):
28 - ## syntax
29 - ## ~<cat>/<pkg>[:[<slot option>]]*
30 - ## where slot option is any of
31 - ## * slot restrict (range, list)
32 - ## * "with version", "open" ("*" and "=" slot operators)
33 - ## * relevant version parts ("1.2.3.4" => "1" if 1, "1.2" if 2, ...)
34 - ## * relevant subslot version parts ("1.2.3.4" => <SLOT>/<SUBSLOT?>)
35 - ## * slot operator ("=")
36 -
37 def gen_opts():
38 if self.mode == 2:
39 yield "open"
40 @@ -360,20 +351,27 @@ class SimpleFuzzySlotDependencyRule ( FuzzySimpleRule ):
41 if self.mode == 2:
42 res = self._resolving_str
43 elif vmod & dep_env.VMOD_EQ:
44 - slot_str = None
45 - slot = self.slotparts.get_slot ( fuzzy )
46 + slot_str = None
47 + vslot_str = None
48 + slot = self.slotparts.get_slot ( fuzzy )
49
50 if slot is not None:
51 if self.subslotparts:
52 subslot = self.subslotparts.get_slot ( fuzzy )
53 if subslot is not None:
54 - slot_str = slot + '/' + subslot
55 + slot_str = slot + '/' + subslot
56 + vslot_str = (
57 + self.slotparts.calculate_slot ( fuzzy, slot )
58 + + '/'
59 + + self.subslotparts.calculate_slot ( fuzzy, subslot )
60 + )
61 else:
62 - slot_str = slot
63 + vslot_str = self.slotparts.calculate_slot ( fuzzy, slot )
64 + slot_str = slot
65
66 if slot_str and (
67 not self.slot_restrict
68 - or self.slot_restrict.accepts ( slot )
69 + or self.slot_restrict.accepts ( vslot_str )
70 ):
71 res = self._resolving_fmt.format (
72 slot=slot_str,
73
74 diff --git a/roverlay/depres/simpledeprule/util.py b/roverlay/depres/simpledeprule/util.py
75 index 0a8311c..0ce5aa4 100644
76 --- a/roverlay/depres/simpledeprule/util.py
77 +++ b/roverlay/depres/simpledeprule/util.py
78 @@ -68,6 +68,9 @@ class SlotSetRestrict ( SlotRestrict ):
79
80 class SlotValueCreatorBase ( object ):
81
82 + def calculate_slot ( self, fuzzy, slot_value ):
83 + return slot_value
84 +
85 def get_slot ( self, *args, **kwargs ):
86 raise NotImplementedError()
87 # --- end of get_slot (...) ---
88 @@ -77,19 +80,6 @@ class SlotValueCreatorBase ( object ):
89 # --- end of __str__ (...) ---
90
91
92 -class ImmediateSlotValueCreator ( SlotValueCreatorBase ):
93 - def __init__ ( self, v_str ):
94 - super ( ImmediateSlotValueCreator, self ).__init__()
95 - self._value = v_str
96 - # --- end of __init__ (...) ---
97 -
98 - def get_slot ( self, *args, **kwargs ):
99 - return self._value
100 - # --- end of get_slot (...) ---
101 -
102 - def __str__ ( self ):
103 - return "i" + self._value
104 -
105 class SingleIndexValueCreator ( SlotValueCreatorBase ):
106 def __init__ ( self, index ):
107 super ( SingleIndexValueCreator, self ).__init__()
108 @@ -129,6 +119,30 @@ class IndexRangeSlotValueCreator ( SlotValueCreatorBase ):
109 ( self._high - 1 ) if self._high > 0 else self._high
110 )
111
112 +class ImmediateSlotValueCreator ( SlotValueCreatorBase ):
113 + def __init__ ( self, v_str ):
114 + super ( ImmediateSlotValueCreator, self ).__init__()
115 + self._value = v_str
116 + numparts = len ( v_str.split ( "." ) )
117 + assert numparts > 0
118 +
119 + if numparts < 2:
120 + self._slot_calculator = SingleIndexValueCreator ( 0 )
121 + else:
122 + self._slot_calculator = IndexRangeSlotValueCreator ( 0, numparts-1 )
123 + # --- end of __init__ (...) ---
124 +
125 + def calculate_slot ( self, fuzzy, slot_value ):
126 + cval = self._slot_calculator.get_slot ( fuzzy )
127 + return slot_value if cval is None else cval
128 + # --- end of calculate_slot (...) ---
129 +
130 + def get_slot ( self, *args, **kwargs ):
131 + return self._value
132 + # --- end of get_slot (...) ---
133 +
134 + def __str__ ( self ):
135 + return "i" + self._value
136
137 def get_slot_parser ( vstr ):
138 if vstr [0] == 'i':