1 |
Author: grobian |
2 |
Date: 2010-02-22 12:58:01 +0000 (Mon, 22 Feb 2010) |
3 |
New Revision: 15431 |
4 |
|
5 |
Modified: |
6 |
main/branches/prefix/pym/_emerge/depgraph.py |
7 |
main/branches/prefix/pym/portage/__init__.py |
8 |
main/branches/prefix/pym/portage/dbapi/bintree.py |
9 |
main/branches/prefix/pym/portage/dbapi/porttree.py |
10 |
main/branches/prefix/pym/portage/dbapi/vartree.py |
11 |
main/branches/prefix/pym/portage/dep.py |
12 |
main/branches/prefix/pym/portage/sets/base.py |
13 |
main/branches/prefix/pym/portage/sets/files.py |
14 |
Log: |
15 |
Merged from trunk -r15397:15407 |
16 |
|
17 |
| 15398 | Use a valid atom in the dep_getkey docstring. | |
18 |
| zmedico | | |
19 |
|
20 |
| 15399 | Use Atom.cp instead of dep_getkey. | |
21 |
| zmedico | | |
22 |
|
23 |
| 15400 | Use Atom.cp instead of dep_getkey. | |
24 |
| zmedico | | |
25 |
|
26 |
| 15401 | Use Atom.cp instead of dep_getkey. | |
27 |
| zmedico | | |
28 |
|
29 |
| 15402 | Remove deprecated key_expand function and | |
30 |
| zmedico | config.load_infodir method. | |
31 |
|
32 |
| 15403 | Add DeprecationWarning to dep_virtual function. | |
33 |
| zmedico | | |
34 |
|
35 |
| 15404 | Remove deprecated methods that call removed key_expand | |
36 |
| zmedico | function. | |
37 |
|
38 |
| 15405 | Add stacklevel=2 to warnings.warn() calls. | |
39 |
| zmedico | | |
40 |
|
41 |
| 15406 | Add stacklevel=2 to warnings.warn calls. | |
42 |
| zmedico | | |
43 |
|
44 |
| 15407 | Use a frozenset for use inside binarytree._eval_use_flags(). | |
45 |
| zmedico | | |
46 |
|
47 |
|
48 |
Modified: main/branches/prefix/pym/_emerge/depgraph.py |
49 |
=================================================================== |
50 |
--- main/branches/prefix/pym/_emerge/depgraph.py 2010-02-22 12:56:52 UTC (rev 15430) |
51 |
+++ main/branches/prefix/pym/_emerge/depgraph.py 2010-02-22 12:58:01 UTC (rev 15431) |
52 |
@@ -1819,8 +1819,7 @@ |
53 |
pprovided_match = False |
54 |
for virt_choice in virtuals.get(atom.cp, []): |
55 |
expanded_atom = portage.dep.Atom( |
56 |
- atom.replace(atom.cp, |
57 |
- portage.dep_getkey(virt_choice), 1)) |
58 |
+ atom.replace(atom.cp, virt_choice.cp, 1)) |
59 |
pprovided = pprovideddict.get(expanded_atom.cp) |
60 |
if pprovided and \ |
61 |
portage.match_from_list(expanded_atom, pprovided): |
62 |
@@ -3004,10 +3003,8 @@ |
63 |
if provider_virtual: |
64 |
atoms = [] |
65 |
for provider_entry in virtuals[blocker.cp]: |
66 |
- provider_cp = \ |
67 |
- portage.dep_getkey(provider_entry) |
68 |
atoms.append(Atom(blocker.atom.replace( |
69 |
- blocker.cp, provider_cp))) |
70 |
+ blocker.cp, provider_entry.cp, 1))) |
71 |
else: |
72 |
atoms = [blocker.atom] |
73 |
|
74 |
@@ -5352,14 +5349,14 @@ |
75 |
if len(expanded_atoms) > 1: |
76 |
non_virtual_atoms = [] |
77 |
for x in expanded_atoms: |
78 |
- if not portage.dep_getkey(x).startswith("virtual/"): |
79 |
+ if not x.cp.startswith("virtual/"): |
80 |
non_virtual_atoms.append(x) |
81 |
if len(non_virtual_atoms) == 1: |
82 |
expanded_atoms = non_virtual_atoms |
83 |
if len(expanded_atoms) > 1: |
84 |
# compatible with portage.cpv_expand() |
85 |
raise portage.exception.AmbiguousPackageName( |
86 |
- [portage.dep_getkey(x) for x in expanded_atoms]) |
87 |
+ [x.cp for x in expanded_atoms]) |
88 |
if expanded_atoms: |
89 |
atom = expanded_atoms[0] |
90 |
else: |
91 |
|
92 |
Modified: main/branches/prefix/pym/portage/__init__.py |
93 |
=================================================================== |
94 |
--- main/branches/prefix/pym/portage/__init__.py 2010-02-22 12:56:52 UTC (rev 15430) |
95 |
+++ main/branches/prefix/pym/portage/__init__.py 2010-02-22 12:58:01 UTC (rev 15431) |
96 |
@@ -2463,11 +2463,6 @@ |
97 |
self.useforce_list, incremental=True)) |
98 |
self.regenerate(use_cache=use_cache) |
99 |
|
100 |
- def load_infodir(self,infodir): |
101 |
- warnings.warn("portage.config.load_infodir() is deprecated", |
102 |
- DeprecationWarning) |
103 |
- return 1 |
104 |
- |
105 |
class _lazy_vars(object): |
106 |
|
107 |
__slots__ = ('built_use', 'settings', 'values') |
108 |
@@ -3298,7 +3293,10 @@ |
109 |
modified = False |
110 |
cp = dep.Atom(cpv_getkey(mycpv)) |
111 |
for virt in virts: |
112 |
- virt = dep_getkey(virt) |
113 |
+ try: |
114 |
+ virt = dep.Atom(virt).cp |
115 |
+ except exception.InvalidAtom: |
116 |
+ continue |
117 |
providers = self.virtuals.get(virt) |
118 |
if providers and cp in providers: |
119 |
continue |
120 |
@@ -3704,7 +3702,7 @@ |
121 |
def has_key(self,mykey): |
122 |
warnings.warn("portage.config.has_key() is deprecated, " |
123 |
"use the in operator instead", |
124 |
- DeprecationWarning) |
125 |
+ DeprecationWarning, stacklevel=2) |
126 |
return mykey in self |
127 |
|
128 |
def __contains__(self, mykey): |
129 |
@@ -7793,6 +7791,8 @@ |
130 |
|
131 |
def dep_virtual(mysplit, mysettings): |
132 |
"Does virtual dependency conversion" |
133 |
+ warnings.warn("portage.dep_virtual() is deprecated", |
134 |
+ DeprecationWarning, stacklevel=2) |
135 |
newsplit=[] |
136 |
myvirtuals = mysettings.getvirtuals() |
137 |
for x in mysplit: |
138 |
@@ -8478,7 +8478,7 @@ |
139 |
return mysplit[0] + '/' + mysplit[1] |
140 |
|
141 |
warnings.warn("portage.cpv_getkey() called with invalid cpv: '%s'" \ |
142 |
- % (mycpv,), DeprecationWarning) |
143 |
+ % (mycpv,), DeprecationWarning, stacklevel=2) |
144 |
|
145 |
myslash = mycpv.split("/", 1) |
146 |
mysplit = versions._pkgsplit(myslash[-1]) |
147 |
@@ -8492,32 +8492,6 @@ |
148 |
|
149 |
getCPFromCPV = cpv_getkey |
150 |
|
151 |
-def key_expand(mykey, mydb=None, use_cache=1, settings=None): |
152 |
- """This is deprecated because it just returns the first match instead of |
153 |
- raising AmbiguousPackageName like cpv_expand does.""" |
154 |
- warnings.warn("portage.key_expand() is deprecated", DeprecationWarning) |
155 |
- mysplit=mykey.split("/") |
156 |
- if settings is None: |
157 |
- settings = globals()["settings"] |
158 |
- virts = settings.getvirtuals("/") |
159 |
- virts_p = settings.get_virts_p("/") |
160 |
- if len(mysplit)==1: |
161 |
- if hasattr(mydb, "cp_list"): |
162 |
- for x in mydb.categories: |
163 |
- if mydb.cp_list(x+"/"+mykey,use_cache=use_cache): |
164 |
- return dep.Atom(x + "/" + mykey) |
165 |
- if mykey in virts_p: |
166 |
- return(virts_p[mykey][0]) |
167 |
- return dep.Atom("null/" + mykey) |
168 |
- elif mydb: |
169 |
- if hasattr(mydb, "cp_list"): |
170 |
- if not mydb.cp_list(mykey, use_cache=use_cache) and \ |
171 |
- virts and mykey in virts: |
172 |
- return virts[mykey][0] |
173 |
- if not isinstance(mykey, dep.Atom): |
174 |
- mykey = dep.Atom(mykey) |
175 |
- return mykey |
176 |
- |
177 |
def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None): |
178 |
"""Given a string (packagename or virtual) expand it into a valid |
179 |
cat/package string. Virtuals use the mydb to determine which provided |
180 |
@@ -8549,7 +8523,7 @@ |
181 |
# it may be necessary to remove the operator and |
182 |
# version from the atom before it is passed into |
183 |
# dbapi.cp_list(). |
184 |
- if mydb.cp_list(dep_getkey(vkey), use_cache=use_cache): |
185 |
+ if mydb.cp_list(vkey.cp): |
186 |
mykey = str(vkey) |
187 |
writemsg(_("virts chosen: %s\n") % (mykey), 1) |
188 |
break |
189 |
|
190 |
Modified: main/branches/prefix/pym/portage/dbapi/bintree.py |
191 |
=================================================================== |
192 |
--- main/branches/prefix/pym/portage/dbapi/bintree.py 2010-02-22 12:56:52 UTC (rev 15430) |
193 |
+++ main/branches/prefix/pym/portage/dbapi/bintree.py 2010-02-22 12:58:01 UTC (rev 15431) |
194 |
@@ -460,7 +460,7 @@ |
195 |
warnings.warn( |
196 |
"portage.dbapi.bintree.binarytree.populate(): " + \ |
197 |
"getbinpkgsonly parameter is deprecated", |
198 |
- DeprecationWarning) |
199 |
+ DeprecationWarning, stacklevel=2) |
200 |
|
201 |
if self._populating: |
202 |
return |
203 |
@@ -1049,7 +1049,7 @@ |
204 |
return False |
205 |
|
206 |
def _eval_use_flags(self, cpv, metadata): |
207 |
- use = metadata["USE"].split() |
208 |
+ use = frozenset(metadata["USE"].split()) |
209 |
raw_use = use |
210 |
iuse = set(f.lstrip("-+") for f in metadata["IUSE"].split()) |
211 |
use = [f for f in use if f in iuse] |
212 |
|
213 |
Modified: main/branches/prefix/pym/portage/dbapi/porttree.py |
214 |
=================================================================== |
215 |
--- main/branches/prefix/pym/portage/dbapi/porttree.py 2010-02-22 12:56:52 UTC (rev 15430) |
216 |
+++ main/branches/prefix/pym/portage/dbapi/porttree.py 2010-02-22 12:58:01 UTC (rev 15431) |
217 |
@@ -25,7 +25,7 @@ |
218 |
from portage.manifest import Manifest |
219 |
|
220 |
from portage import eclass_cache, auxdbkeys, doebuild, flatten, \ |
221 |
- listdir, dep_expand, eapi_is_supported, key_expand, dep_check, \ |
222 |
+ listdir, dep_expand, eapi_is_supported, dep_check, \ |
223 |
_eapi_is_deprecated |
224 |
from portage import os |
225 |
from portage import _encodings |
226 |
@@ -171,7 +171,7 @@ |
227 |
"portage.dbapi.porttree.portdbapi" + \ |
228 |
" constructor is now unused. Use " + \ |
229 |
"mysettings['PORTDIR'] instead.", |
230 |
- DeprecationWarning) |
231 |
+ DeprecationWarning, stacklevel=2) |
232 |
|
233 |
# This is strictly for use in aux_get() doebuild calls when metadata |
234 |
# is generated by the depend phase. It's safest to use a clone for |
235 |
@@ -1227,20 +1227,6 @@ |
236 |
psplit = pkgsplit(mysplit[1]) |
237 |
return "/".join([self.portroot, mysplit[0], psplit[0], mysplit[1]])+".ebuild" |
238 |
|
239 |
- def resolve_specific(self, myspec): |
240 |
- warnings.warn( |
241 |
- "portage.dbapi.porttree.portagetree.resolve_specific() is deprecated", |
242 |
- DeprecationWarning) |
243 |
- cps = catpkgsplit(myspec) |
244 |
- if not cps: |
245 |
- return None |
246 |
- mykey = key_expand(cps[0]+"/"+cps[1], mydb=self.dbapi, |
247 |
- settings=self.settings) |
248 |
- mykey = mykey + "-" + cps[2] |
249 |
- if cps[3] != "r0": |
250 |
- mykey = mykey + "-" + cps[3] |
251 |
- return mykey |
252 |
- |
253 |
def depcheck(self, mycheck, use="yes", myusesplit=None): |
254 |
return dep_check(mycheck, self.dbapi, use=use, myuse=myusesplit) |
255 |
|
256 |
|
257 |
Modified: main/branches/prefix/pym/portage/dbapi/vartree.py |
258 |
=================================================================== |
259 |
--- main/branches/prefix/pym/portage/dbapi/vartree.py 2010-02-22 12:56:52 UTC (rev 15430) |
260 |
+++ main/branches/prefix/pym/portage/dbapi/vartree.py 2010-02-22 12:58:01 UTC (rev 15431) |
261 |
@@ -33,7 +33,7 @@ |
262 |
FileNotFound, PermissionDenied, UnsupportedAPIException |
263 |
from portage.localization import _ |
264 |
|
265 |
-from portage import listdir, dep_expand, digraph, flatten, key_expand, \ |
266 |
+from portage import listdir, dep_expand, digraph, flatten, \ |
267 |
doebuild_environment, doebuild, env_update, prepare_build_dirs, \ |
268 |
abssymlink, movefile, _movefile, bsd_chflags, cpv_getkey |
269 |
|
270 |
@@ -2689,7 +2689,7 @@ |
271 |
self.root = root[:] |
272 |
if settings is None: |
273 |
from portage import settings |
274 |
- self.settings = settings # for key_expand calls |
275 |
+ self.settings = settings |
276 |
if categories is None: |
277 |
categories = settings.categories |
278 |
self.dbapi = vardbapi(self.root, categories=categories, |
279 |
@@ -2774,50 +2774,10 @@ |
280 |
masked package for nodes in this nodes list.""" |
281 |
return self.dbapi.cp_all() |
282 |
|
283 |
- def exists_specific_cat(self, cpv, use_cache=1): |
284 |
- warnings.warn( |
285 |
- "portage.dbapi.vartree.vartree.exists_specific_cat() is deprecated", |
286 |
- DeprecationWarning) |
287 |
- cpv = key_expand(cpv, mydb=self.dbapi, use_cache=use_cache, |
288 |
- settings=self.settings) |
289 |
- a = catpkgsplit(cpv) |
290 |
- if not a: |
291 |
- return 0 |
292 |
- mylist = listdir(self.getpath(a[0]), EmptyOnError=1) |
293 |
- for x in mylist: |
294 |
- b = pkgsplit(x) |
295 |
- if not b: |
296 |
- self.dbapi.invalidentry(self.getpath(a[0], filename=x)) |
297 |
- continue |
298 |
- if a[1] == b[0]: |
299 |
- return 1 |
300 |
- return 0 |
301 |
- |
302 |
def getebuildpath(self, fullpackage): |
303 |
cat, package = catsplit(fullpackage) |
304 |
return self.getpath(fullpackage, filename=package+".ebuild") |
305 |
|
306 |
- def getnode(self, mykey, use_cache=1): |
307 |
- warnings.warn( |
308 |
- "portage.dbapi.vartree.vartree.getnode() is deprecated", |
309 |
- DeprecationWarning) |
310 |
- mykey = key_expand(mykey, mydb=self.dbapi, use_cache=use_cache, |
311 |
- settings=self.settings) |
312 |
- if not mykey: |
313 |
- return [] |
314 |
- mysplit = catsplit(mykey) |
315 |
- mydirlist = listdir(self.getpath(mysplit[0]),EmptyOnError=1) |
316 |
- returnme = [] |
317 |
- for x in mydirlist: |
318 |
- mypsplit = pkgsplit(x) |
319 |
- if not mypsplit: |
320 |
- self.dbapi.invalidentry(self.getpath(mysplit[0], filename=x)) |
321 |
- continue |
322 |
- if mypsplit[0] == mysplit[1]: |
323 |
- appendme = [mysplit[0]+"/"+x, [mysplit[0], mypsplit[0], mypsplit[1], mypsplit[2]]] |
324 |
- returnme.append(appendme) |
325 |
- return returnme |
326 |
- |
327 |
def getslot(self, mycatpkg): |
328 |
"Get a slot for a catpkg; assume it exists." |
329 |
try: |
330 |
@@ -2825,24 +2785,6 @@ |
331 |
except KeyError: |
332 |
return "" |
333 |
|
334 |
- def hasnode(self, mykey, use_cache): |
335 |
- """Does the particular node (cat/pkg key) exist?""" |
336 |
- warnings.warn( |
337 |
- "portage.dbapi.vartree.vartree.hadnode() is deprecated", |
338 |
- DeprecationWarning) |
339 |
- mykey = key_expand(mykey, mydb=self.dbapi, use_cache=use_cache, |
340 |
- settings=self.settings) |
341 |
- mysplit = catsplit(mykey) |
342 |
- mydirlist = listdir(self.getpath(mysplit[0]), EmptyOnError=1) |
343 |
- for x in mydirlist: |
344 |
- mypsplit = pkgsplit(x) |
345 |
- if not mypsplit: |
346 |
- self.dbapi.invalidentry(self.getpath(mysplit[0], filename=x)) |
347 |
- continue |
348 |
- if mypsplit[0] == mysplit[1]: |
349 |
- return 1 |
350 |
- return 0 |
351 |
- |
352 |
def populate(self): |
353 |
self.populated=1 |
354 |
|
355 |
|
356 |
Modified: main/branches/prefix/pym/portage/dep.py |
357 |
=================================================================== |
358 |
--- main/branches/prefix/pym/portage/dep.py 2010-02-22 12:56:52 UTC (rev 15430) |
359 |
+++ main/branches/prefix/pym/portage/dep.py 2010-02-22 12:58:01 UTC (rev 15431) |
360 |
@@ -923,7 +923,7 @@ |
361 |
Return the category/package-name of a depstring. |
362 |
|
363 |
Example usage: |
364 |
- >>> dep_getkey('media-libs/test-3.0') |
365 |
+ >>> dep_getkey('=media-libs/test-3.0') |
366 |
'media-libs/test' |
367 |
|
368 |
@param mydep: The depstring to retrieve the category/package-name of |
369 |
|
370 |
Modified: main/branches/prefix/pym/portage/sets/base.py |
371 |
=================================================================== |
372 |
--- main/branches/prefix/pym/portage/sets/base.py 2010-02-22 12:56:52 UTC (rev 15430) |
373 |
+++ main/branches/prefix/pym/portage/sets/base.py 2010-02-22 12:58:01 UTC (rev 15431) |
374 |
@@ -5,7 +5,7 @@ |
375 |
import sys |
376 |
from portage import cpv_getkey, flatten |
377 |
from portage.dep import Atom, isvalidatom, match_from_list, \ |
378 |
- best_match_to_list, dep_getkey, use_reduce, paren_reduce |
379 |
+ best_match_to_list, use_reduce, paren_reduce |
380 |
from portage.exception import InvalidAtom |
381 |
|
382 |
if sys.hexversion >= 0x3000000: |
383 |
@@ -153,7 +153,10 @@ |
384 |
return |
385 |
provides = provides.split() |
386 |
for provide in provides: |
387 |
- provided_cp = dep_getkey(provide) |
388 |
+ try: |
389 |
+ provided_cp = Atom(provide).cp |
390 |
+ except InvalidAtom: |
391 |
+ continue |
392 |
atoms = self._atommap.get(provided_cp) |
393 |
if atoms: |
394 |
for atom in atoms: |
395 |
@@ -201,7 +204,7 @@ |
396 |
def removePackageAtoms(self, cp): |
397 |
self._load() |
398 |
for a in list(self._atoms): |
399 |
- if dep_getkey(a) == cp: |
400 |
+ if a.cp == cp: |
401 |
self.remove(a) |
402 |
self.write() |
403 |
|
404 |
|
405 |
Modified: main/branches/prefix/pym/portage/sets/files.py |
406 |
=================================================================== |
407 |
--- main/branches/prefix/pym/portage/sets/files.py 2010-02-22 12:56:52 UTC (rev 15430) |
408 |
+++ main/branches/prefix/pym/portage/sets/files.py 2010-02-22 12:58:01 UTC (rev 15431) |
409 |
@@ -18,7 +18,7 @@ |
410 |
from portage.sets import SetConfigError, SETPREFIX, get_boolean |
411 |
from portage.env.loaders import ItemFileLoader, KeyListFileLoader |
412 |
from portage.env.validators import ValidAtomValidator |
413 |
-from portage import dep_getkey, cpv_getkey |
414 |
+from portage import cpv_getkey |
415 |
|
416 |
__all__ = ["StaticFileSet", "ConfigFileSet", "WorldSelectedSet"] |
417 |
|
418 |
@@ -304,7 +304,7 @@ |
419 |
mykey = cpv_getkey(cpv) |
420 |
newworldlist = [] |
421 |
for x in worldlist: |
422 |
- if dep_getkey(x) == mykey: |
423 |
+ if x.cp == mykey: |
424 |
matches = vardb.match(x, use_cache=0) |
425 |
if not matches: |
426 |
#zap our world entry |