Gentoo Archives: gentoo-commits

From: "Fabian Groffen (grobian)" <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10881 - in main/branches/prefix: bin pym/_emerge pym/portage pym/portage/cache pym/portage/dbapi pym/portage/elog
Date: Tue, 01 Jul 2008 17:32:53
Message-Id: E1KDjig-0006fL-J3@stork.gentoo.org
1 Author: grobian
2 Date: 2008-07-01 17:32:45 +0000 (Tue, 01 Jul 2008)
3 New Revision: 10881
4
5 Modified:
6 main/branches/prefix/bin/dispatch-conf
7 main/branches/prefix/bin/dohtml
8 main/branches/prefix/bin/glsa-check
9 main/branches/prefix/bin/repoman
10 main/branches/prefix/pym/_emerge/__init__.py
11 main/branches/prefix/pym/portage/__init__.py
12 main/branches/prefix/pym/portage/cache/mappings.py
13 main/branches/prefix/pym/portage/cache/metadata_overlay.py
14 main/branches/prefix/pym/portage/cache/sql_template.py
15 main/branches/prefix/pym/portage/cache/template.py
16 main/branches/prefix/pym/portage/cvstree.py
17 main/branches/prefix/pym/portage/dbapi/__init__.py
18 main/branches/prefix/pym/portage/dbapi/bintree.py
19 main/branches/prefix/pym/portage/dbapi/vartree.py
20 main/branches/prefix/pym/portage/dbapi/virtual.py
21 main/branches/prefix/pym/portage/dispatch_conf.py
22 main/branches/prefix/pym/portage/elog/__init__.py
23 main/branches/prefix/pym/portage/elog/filtering.py
24 main/branches/prefix/pym/portage/elog/messages.py
25 main/branches/prefix/pym/portage/elog/mod_mail.py
26 main/branches/prefix/pym/portage/elog/mod_mail_summary.py
27 main/branches/prefix/pym/portage/getbinpkg.py
28 main/branches/prefix/pym/portage/glsa.py
29 main/branches/prefix/pym/portage/locks.py
30 main/branches/prefix/pym/portage/manifest.py
31 main/branches/prefix/pym/portage/util.py
32 Log:
33 Merged from trunk 10869:10875
34
35 | 10870 | Py3k compatibility patch #1 by Ali Polatel <hawking@g.o>. |
36 | zmedico | Replace dict.has_key() calls with "in" and "not in" |
37 | | operators.. |
38
39 | 10871 | Py3k compatibility patch #2 by Ali Polatel <hawking@g.o>. |
40 | zmedico | Replace dict.has_key() calls with "in" and "not in" |
41 | | operators. |
42
43 | 10872 | Py3k compatibility patch #3 by Ali Polatel <hawking@g.o>. |
44 | zmedico | Replace dict.has_key() calls with "in" and "not in" |
45 | | operators. |
46
47 | 10873 | Py3k compatibility patch #4 by Ali Polatel <hawking@g.o>. |
48 | zmedico | Replace dict.has_key() calls with "in" and "not in" |
49 | | operators. |
50
51 | 10874 | Py3k compatibility patch #5 by Ali Polatel <hawking@g.o>. |
52 | zmedico | Replace dict.has_key() calls with "in" and "not in" |
53 | | operators. |
54
55 | 10875 | Py3k compatibility patch #6 by Ali Polatel <hawking@g.o>. |
56 | zmedico | Replace dict.has_key() calls with "in" and "not in" |
57 | | operators. |
58
59
60 Modified: main/branches/prefix/bin/dispatch-conf
61 ===================================================================
62 --- main/branches/prefix/bin/dispatch-conf 2008-07-01 17:22:29 UTC (rev 10880)
63 +++ main/branches/prefix/bin/dispatch-conf 2008-07-01 17:32:45 UTC (rev 10881)
64 @@ -75,7 +75,7 @@
65
66 self.options = portage.dispatch_conf.read_config(MANDATORY_OPTS)
67
68 - if self.options.has_key("log-file"):
69 + if "log-file" in self.options:
70 if os.path.isfile(self.options["log-file"]):
71 shutil.copy(self.options["log-file"], self.options["log-file"] + '.old')
72 if os.path.isfile(self.options["log-file"]) \
73 @@ -273,7 +273,7 @@
74 show_new_diff = 1
75 continue
76 elif c == 'e':
77 - if not os.environ.has_key('EDITOR'):
78 + if 'EDITOR' not in os.environ:
79 os.environ['EDITOR']='nano'
80 os.system(os.environ['EDITOR'] + ' ' + newconf)
81 continue
82 @@ -337,7 +337,7 @@
83 conf = re.sub (r'\._cfg\d+_', '', nconf)
84 dir = re.match (r'^(.+)/', nconf).group (1)
85
86 - if h.has_key (conf):
87 + if conf in h:
88 mrgconf = re.sub(r'\._cfg', '._mrg', h[conf]['new'])
89 if os.path.exists(mrgconf):
90 os.unlink(mrgconf)
91
92 Modified: main/branches/prefix/bin/dohtml
93 ===================================================================
94 --- main/branches/prefix/bin/dohtml 2008-07-01 17:22:29 UTC (rev 10880)
95 +++ main/branches/prefix/bin/dohtml 2008-07-01 17:32:45 UTC (rev 10881)
96 @@ -86,11 +86,11 @@
97 self.ED = ""
98 self.DOCDESTTREE = ""
99
100 - if os.environ.has_key("PF"):
101 + if "PF" in os.environ:
102 self.PF = os.environ["PF"]
103 if os.environ.has_key("ED"):
104 self.ED = os.environ["ED"]
105 - if os.environ.has_key("_E_DOCDESTTREE_"):
106 + if "_E_DOCDESTTREE_" in os.environ:
107 self.DOCDESTTREE = os.environ["_E_DOCDESTTREE_"]
108
109 self.allowed_exts = [ 'htm', 'html', 'css', 'js',
110
111 Modified: main/branches/prefix/bin/glsa-check
112 ===================================================================
113 --- main/branches/prefix/bin/glsa-check 2008-07-01 17:22:29 UTC (rev 10880)
114 +++ main/branches/prefix/bin/glsa-check 2008-07-01 17:32:45 UTC (rev 10881)
115 @@ -295,12 +295,12 @@
116 # color doesn't make any sense for mail
117 nocolor()
118
119 - if portage.settings.has_key("PORTAGE_ELOG_MAILURI"):
120 + if "PORTAGE_ELOG_MAILURI" in portage.settings:
121 myrecipient = portage.settings["PORTAGE_ELOG_MAILURI"].split()[0]
122 else:
123 myrecipient = "root@localhost"
124
125 - if portage.settings.has_key("PORTAGE_ELOG_MAILFROM"):
126 + if "PORTAGE_ELOG_MAILFROM" in portage.settings:
127 myfrom = portage.settings["PORTAGE_ELOG_MAILFROM"]
128 else:
129 myfrom = "glsa-check"
130
131 Modified: main/branches/prefix/bin/repoman
132 ===================================================================
133 --- main/branches/prefix/bin/repoman 2008-07-01 17:22:29 UTC (rev 10880)
134 +++ main/branches/prefix/bin/repoman 2008-07-01 17:32:45 UTC (rev 10881)
135 @@ -660,7 +660,7 @@
136 if not os.path.isdir(portdir+"/profiles/"+arch[1]):
137 print "Invalid "+arch[2]+" profile ("+arch[1]+") for arch "+arch[0]
138 continue
139 - if profiles.has_key(arch[0]):
140 + if arch[0] in profiles:
141 profiles[arch[0]]+= [[arch[1], arch[2]]]
142 else:
143 profiles[arch[0]] = [[arch[1], arch[2]]]
144 @@ -668,7 +668,7 @@
145 for x in repoman_settings.archlist():
146 if x[0] == "~":
147 continue
148 - if not profiles.has_key(x):
149 + if x not in profiles:
150 print red("\""+x+"\" doesn't have a valid profile listed in profiles.desc.")
151 print red("You need to either \"cvs update\" your profiles dir or follow this")
152 print red("up with the "+x+" team.")
153 @@ -1333,7 +1333,7 @@
154
155 # uselist checks - local
156 mykey = portage.dep_getkey(catpkg)
157 - if luselist.has_key(mykey):
158 + if mykey in luselist:
159 for mypos in range(len(myuse)-1,-1,-1):
160 if myuse[mypos] and (myuse[mypos] in luselist[mykey]):
161 del myuse[mypos]
162 @@ -1378,7 +1378,7 @@
163 if myskey not in kwlist:
164 stats["KEYWORDS.invalid"] += 1
165 fails["KEYWORDS.invalid"].append(x+"/"+y+".ebuild: %s" % mykey)
166 - elif not profiles.has_key(myskey):
167 + elif myskey not in profiles:
168 stats["KEYWORDS.invalid"] += 1
169 fails["KEYWORDS.invalid"].append(x+"/"+y+".ebuild: %s (profile invalid)" % mykey)
170
171 @@ -1418,7 +1418,7 @@
172
173 for keyword,arch,groups in arches:
174
175 - if not profiles.has_key(arch):
176 + if arch not in profiles:
177 # A missing profile will create an error further down
178 # during the KEYWORDS verification.
179 continue
180 @@ -1831,7 +1831,7 @@
181 if "PORTAGE_GPG_KEY" not in repoman_settings:
182 raise portage.exception.MissingParameter("PORTAGE_GPG_KEY is unset!")
183 if "PORTAGE_GPG_DIR" not in repoman_settings:
184 - if os.environ.has_key("HOME"):
185 + if "HOME" in os.environ:
186 repoman_settings["PORTAGE_GPG_DIR"] = os.path.join(os.environ["HOME"], ".gnupg")
187 logging.info("Automatically setting PORTAGE_GPG_DIR to %s" % repoman_settings["PORTAGE_GPG_DIR"])
188 else:
189 @@ -1846,7 +1846,7 @@
190 repoman_settings["PORTAGE_GPG_DIR"])
191 gpgcmd = "gpg --sign --clearsign --yes "
192 gpgcmd+= "--default-key "+repoman_settings["PORTAGE_GPG_KEY"]
193 - if repoman_settings.has_key("PORTAGE_GPG_DIR"):
194 + if "PORTAGE_GPG_DIR" in repoman_settings:
195 gpgcmd += " --homedir "+repoman_settings["PORTAGE_GPG_DIR"]
196 if options.pretend:
197 print "("+gpgcmd+" "+filename+")"
198
199 Modified: main/branches/prefix/pym/_emerge/__init__.py
200 ===================================================================
201 --- main/branches/prefix/pym/_emerge/__init__.py 2008-07-01 17:22:29 UTC (rev 10880)
202 +++ main/branches/prefix/pym/_emerge/__init__.py 2008-07-01 17:32:45 UTC (rev 10881)
203 @@ -7340,7 +7340,7 @@
204 emergelog(xterm_titles, " *** Finished. Cleaning up...")
205
206 # We're out of the loop... We're done. Delete the resume data.
207 - if mtimedb.has_key("resume"):
208 + if "resume" in mtimedb:
209 del mtimedb["resume"]
210 mtimedb.commit()
211
212 @@ -7578,7 +7578,7 @@
213 # since we're pruning, we don't care about slots
214 # and put all the pkgs in together
215 myslot = 0
216 - if not slotmap.has_key(myslot):
217 + if myslot not in slotmap:
218 slotmap[myslot] = {}
219 slotmap[myslot][localtree.dbapi.cpv_counter(mypkg)] = mypkg
220
221 @@ -8283,7 +8283,7 @@
222 rsync_initial_timeout = 15
223
224 try:
225 - if settings.has_key("RSYNC_RETRIES"):
226 + if "RSYNC_RETRIES" in settings:
227 print yellow("WARNING:")+" usage of RSYNC_RETRIES is deprecated, use PORTAGE_RSYNC_RETRIES instead"
228 maxretries=int(settings["RSYNC_RETRIES"])
229 else:
230
231 Modified: main/branches/prefix/pym/portage/__init__.py
232 ===================================================================
233 --- main/branches/prefix/pym/portage/__init__.py 2008-07-01 17:22:29 UTC (rev 10880)
234 +++ main/branches/prefix/pym/portage/__init__.py 2008-07-01 17:32:45 UTC (rev 10881)
235 @@ -30,6 +30,7 @@
236 import UserDict
237 from itertools import chain, izip
238 import platform
239 + import warnings
240 except ImportError, e:
241 sys.stderr.write("\n\n")
242 sys.stderr.write("!!! Failed to complete python imports. These are internal modules for\n")
243 @@ -161,7 +162,7 @@
244
245 def best_from_dict(key, top_dict, key_order, EmptyOnError=1, FullCopy=1, AllowEmpty=1):
246 for x in key_order:
247 - if top_dict.has_key(x) and top_dict[x].has_key(key):
248 + if x in top_dict and key in top_dict[x]:
249 if FullCopy:
250 return copy.deepcopy(top_dict[x][key])
251 else:
252 @@ -195,7 +196,7 @@
253 def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, followSymlinks=True):
254 global cacheHit,cacheMiss,cacheStale
255 mypath = normalize_path(my_original_path)
256 - if dircache.has_key(mypath):
257 + if mypath in dircache:
258 cacheHit += 1
259 cached_mtime, list, ftype = dircache[mypath]
260 else:
261 @@ -220,7 +221,7 @@
262 return None, None
263 # Python retuns mtime in seconds, so if it was changed in the last few seconds, it could be invalid
264 if mtime != cached_mtime or time.time() - mtime < 4:
265 - if dircache.has_key(mypath):
266 + if mypath in dircache:
267 cacheStale += 1
268 try:
269 list = os.listdir(mypath)
270 @@ -852,7 +853,7 @@
271
272 # Check the .config for a CONFIG_LOCALVERSION and append that too, also stripping whitespace
273 kernelconfig = getconfig(base_dir+"/.config")
274 - if kernelconfig and kernelconfig.has_key("CONFIG_LOCALVERSION"):
275 + if kernelconfig and "CONFIG_LOCALVERSION" in kernelconfig:
276 version += "".join(kernelconfig["CONFIG_LOCALVERSION"].split())
277
278 return (version,None)
279 @@ -1225,7 +1226,7 @@
280 self.prevmaskdict={}
281 for x in self.packages:
282 mycatpkg=dep_getkey(x)
283 - if not self.prevmaskdict.has_key(mycatpkg):
284 + if mycatpkg not in self.prevmaskdict:
285 self.prevmaskdict[mycatpkg]=[x]
286 else:
287 self.prevmaskdict[mycatpkg].append(x)
288 @@ -1452,7 +1453,7 @@
289 os.path.join(abs_user_config, "package.use"), recursive=1)
290 for key in pusedict.keys():
291 cp = dep_getkey(key)
292 - if not self.pusedict.has_key(cp):
293 + if cp not in self.pusedict:
294 self.pusedict[cp] = {}
295 self.pusedict[cp][key] = pusedict[key]
296
297 @@ -1464,7 +1465,8 @@
298 # default to ~arch if no specific keyword is given
299 if not pkgdict[key]:
300 mykeywordlist = []
301 - if self.configdict["defaults"] and self.configdict["defaults"].has_key("ACCEPT_KEYWORDS"):
302 + if self.configdict["defaults"] and \
303 + "ACCEPT_KEYWORDS" in self.configdict["defaults"]:
304 groups = self.configdict["defaults"]["ACCEPT_KEYWORDS"].split()
305 else:
306 groups = []
307 @@ -1473,7 +1475,7 @@
308 mykeywordlist.append("~"+keyword)
309 pkgdict[key] = mykeywordlist
310 cp = dep_getkey(key)
311 - if not self.pkeywordsdict.has_key(cp):
312 + if cp not in self.pkeywordsdict:
313 self.pkeywordsdict[cp] = {}
314 self.pkeywordsdict[cp][key] = pkgdict[key]
315
316 @@ -1494,7 +1496,7 @@
317 recursive=1)
318 for x in pkgunmasklines:
319 mycatpkg=dep_getkey(x)
320 - if self.punmaskdict.has_key(mycatpkg):
321 + if mycatpkg in self.punmaskdict:
322 self.punmaskdict[mycatpkg].append(x)
323 else:
324 self.punmaskdict[mycatpkg]=[x]
325 @@ -1518,7 +1520,7 @@
326 self.pmaskdict = {}
327 for x in pkgmasklines:
328 mycatpkg=dep_getkey(x)
329 - if self.pmaskdict.has_key(mycatpkg):
330 + if mycatpkg in self.pmaskdict:
331 self.pmaskdict[mycatpkg].append(x)
332 else:
333 self.pmaskdict[mycatpkg]=[x]
334 @@ -1556,7 +1558,7 @@
335 if not x:
336 continue
337 mycatpkg=dep_getkey(x)
338 - if self.pprovideddict.has_key(mycatpkg):
339 + if mycatpkg in self.pprovideddict:
340 self.pprovideddict[mycatpkg].append(x)
341 else:
342 self.pprovideddict[mycatpkg]=[x]
343 @@ -1822,7 +1824,7 @@
344
345 def backup_changes(self,key=None):
346 self.modifying()
347 - if key and self.configdict["env"].has_key(key):
348 + if key and key in self.configdict["env"]:
349 self.backupenv[key] = copy.deepcopy(self.configdict["env"][key])
350 else:
351 raise KeyError, "No such key defined in environment: %s" % key
352 @@ -2666,7 +2668,7 @@
353 if virts:
354 for x in virts:
355 vkeysplit = x.split("/")
356 - if not self.virts_p.has_key(vkeysplit[1]):
357 + if vkeysplit[1] not in self.virts_p:
358 self.virts_p[vkeysplit[1]] = virts[x]
359 return self.virts_p
360
361 @@ -2778,6 +2780,9 @@
362 return v
363
364 def has_key(self,mykey):
365 + warnings.warn("portage.config.has_key() is deprecated, "
366 + "use the in operator instead",
367 + DeprecationWarning)
368 return mykey in self
369
370 def __contains__(self, mykey):
371 @@ -2839,7 +2844,7 @@
372 # remain unset.
373 continue
374 mydict[x] = myvalue
375 - if not mydict.has_key("HOME") and mydict.has_key("BUILD_PREFIX"):
376 + if "HOME" not in mydict and "BUILD_PREFIX" in mydict:
377 writemsg("*** HOME not set. Setting to "+mydict["BUILD_PREFIX"]+"\n")
378 mydict["HOME"]=mydict["BUILD_PREFIX"][:]
379
380 @@ -3321,7 +3326,7 @@
381 # use_locks = 0
382
383 # local mirrors are always added
384 - if custommirrors.has_key("local"):
385 + if "local" in custommirrors:
386 mymirrors += custommirrors["local"]
387
388 if "nomirror" in restrict or \
389 @@ -3368,7 +3373,7 @@
390 primaryuri_dict = {}
391 for myuri in myuris:
392 myfile=os.path.basename(myuri)
393 - if not filedict.has_key(myfile):
394 + if myfile not in filedict:
395 filedict[myfile]=[]
396 for y in range(0,len(locations)):
397 filedict[myfile].append(locations[y]+"/distfiles/"+myfile)
398 @@ -3378,14 +3383,14 @@
399 mirrorname = myuri[9:eidx]
400
401 # Try user-defined mirrors first
402 - if custommirrors.has_key(mirrorname):
403 + if mirrorname in custommirrors:
404 for cmirr in custommirrors[mirrorname]:
405 filedict[myfile].append(cmirr+"/"+myuri[eidx+1:])
406 # remove the mirrors we tried from the list of official mirrors
407 if cmirr.strip() in thirdpartymirrors[mirrorname]:
408 thirdpartymirrors[mirrorname].remove(cmirr)
409 # now try the official mirrors
410 - if thirdpartymirrors.has_key(mirrorname):
411 + if mirrorname in thirdpartymirrors:
412 shuffle(thirdpartymirrors[mirrorname])
413
414 for locmirr in thirdpartymirrors[mirrorname]:
415 @@ -3402,7 +3407,7 @@
416 continue
417 if "primaryuri" in restrict:
418 # Use the source site first.
419 - if primaryuri_indexes.has_key(myfile):
420 + if myfile in primaryuri_indexes:
421 primaryuri_indexes[myfile] += 1
422 else:
423 primaryuri_indexes[myfile] = 0
424 @@ -3713,11 +3718,11 @@
425 continue
426 # allow different fetchcommands per protocol
427 protocol = loc[0:loc.find("://")]
428 - if mysettings.has_key("FETCHCOMMAND_"+protocol.upper()):
429 + if "FETCHCOMMAND_" + protocol.upper() in mysettings:
430 fetchcommand=mysettings["FETCHCOMMAND_"+protocol.upper()]
431 else:
432 fetchcommand=mysettings["FETCHCOMMAND"]
433 - if mysettings.has_key("RESUMECOMMAND_"+protocol.upper()):
434 + if "RESUMECOMMAND_" + protocol.upper() in mysettings:
435 resumecommand=mysettings["RESUMECOMMAND_"+protocol.upper()]
436 else:
437 resumecommand=mysettings["RESUMECOMMAND"]
438 @@ -3834,7 +3839,7 @@
439 except EnvironmentError:
440 pass
441
442 - if mydigests!=None and mydigests.has_key(myfile):
443 + if mydigests is not None and myfile in mydigests:
444 try:
445 mystat = os.stat(myfile_path)
446 except OSError, e:
447 @@ -4428,7 +4433,7 @@
448 ebuild_path = os.path.abspath(myebuild)
449 pkg_dir = os.path.dirname(ebuild_path)
450
451 - if mysettings.configdict["pkg"].has_key("CATEGORY"):
452 + if "CATEGORY" in mysettings.configdict["pkg"]:
453 cat = mysettings.configdict["pkg"]["CATEGORY"]
454 else:
455 cat = os.path.basename(normalize_path(os.path.join(pkg_dir, "..")))
456 @@ -4531,7 +4536,7 @@
457 else:
458 mysettings["PVR"]=mysplit[1]+"-"+mysplit[2]
459
460 - if mysettings.has_key("PATH"):
461 + if "PATH" in mysettings:
462 mysplit=mysettings["PATH"].split(":")
463 else:
464 mysplit=[]
465 @@ -6240,7 +6245,7 @@
466 pass
467 else:
468 mykey = dep_getkey(deplist[mypos])
469 - if mysettings and mysettings.pprovideddict.has_key(mykey) and \
470 + if mysettings and mykey in mysettings.pprovideddict and \
471 match_from_list(deplist[mypos], mysettings.pprovideddict[mykey]):
472 deplist[mypos]=True
473 elif mydbapi is None:
474 @@ -6291,12 +6296,13 @@
475 for x in mydb.categories:
476 if mydb.cp_list(x+"/"+mykey,use_cache=use_cache):
477 return x+"/"+mykey
478 - if virts_p.has_key(mykey):
479 + if mykey in virts_p:
480 return(virts_p[mykey][0])
481 return "null/"+mykey
482 elif mydb:
483 if hasattr(mydb, "cp_list"):
484 - if (not mydb.cp_list(mykey,use_cache=use_cache)) and virts and virts.has_key(mykey):
485 + if not mydb.cp_list(mykey, use_cache=use_cache) and \
486 + virts and mykey in virts:
487 return virts[mykey][0]
488 return mykey
489
490 @@ -6370,7 +6376,7 @@
491 mykey=matches[0]
492
493 if not mykey and not isinstance(mydb, list):
494 - if virts_p.has_key(myp):
495 + if myp in virts_p:
496 mykey=virts_p[myp][0]
497 #again, we only perform virtual expansion if we have a dbapi (not a list)
498 if not mykey:
499 @@ -6418,7 +6424,7 @@
500 locations.reverse()
501 pmasklists = [(x, grablines(os.path.join(x, "package.mask"), recursive=1)) for x in locations]
502
503 - if settings.pmaskdict.has_key(mycp):
504 + if mycp in settings.pmaskdict:
505 for x in settings.pmaskdict[mycp]:
506 if match_from_list(x, cpv_slot_list):
507 comment = ""
508 @@ -6836,7 +6842,7 @@
509
510 def portageexit():
511 global uid,portage_gid,portdb,db
512 - if secpass and not os.environ.has_key("SANDBOX_ACTIVE"):
513 + if secpass and os.environ.get("SANDBOX_ON") != "1":
514 close_portdbapi_caches()
515 commit_mtimedb()
516
517
518 Modified: main/branches/prefix/pym/portage/cache/mappings.py
519 ===================================================================
520 --- main/branches/prefix/pym/portage/cache/mappings.py 2008-07-01 17:22:29 UTC (rev 10880)
521 +++ main/branches/prefix/pym/portage/cache/mappings.py 2008-07-01 17:32:45 UTC (rev 10881)
522 @@ -4,6 +4,7 @@
523 # $Id$
524
525 import UserDict
526 +import warnings
527 import weakref
528
529 class ProtectedDict(UserDict.DictMixin):
530 @@ -55,9 +56,14 @@
531 return list(self.__iter__())
532
533
534 - def has_key(self, key):
535 + def __contains__(self, key):
536 return key in self.new or (key not in self.blacklist and key in self.orig)
537
538 + def has_key(self, key):
539 + warnings.warn("portage.cache.mapping.ProtectedDict.has_key() is"
540 + " deprecated, use the in operator instead",
541 + DeprecationWarning)
542 + return key in self
543
544 class LazyLoad(UserDict.DictMixin):
545 """
546 @@ -91,6 +97,9 @@
547
548
549 def has_key(self, key):
550 + warnings.warn("portage.cache.mappings.LazyLoad.has_key() is "
551 + "deprecated, use the in operator instead",
552 + DeprecationWarning)
553 return key in self
554
555
556
557 Modified: main/branches/prefix/pym/portage/cache/metadata_overlay.py
558 ===================================================================
559 --- main/branches/prefix/pym/portage/cache/metadata_overlay.py 2008-07-01 17:22:29 UTC (rev 10880)
560 +++ main/branches/prefix/pym/portage/cache/metadata_overlay.py 2008-07-01 17:32:45 UTC (rev 10881)
561 @@ -61,7 +61,7 @@
562
563 def _delitem(self, cpv):
564 value = self[cpv] # validates whiteout and/or raises a KeyError when necessary
565 - if self.db_ro.has_key(cpv):
566 + if cpv in self.db_ro:
567 self.db_rw[cpv] = self._create_whiteout(value)
568 else:
569 del self.db_rw[cpv]
570
571 Modified: main/branches/prefix/pym/portage/cache/sql_template.py
572 ===================================================================
573 --- main/branches/prefix/pym/portage/cache/sql_template.py 2008-07-01 17:22:29 UTC (rev 10880)
574 +++ main/branches/prefix/pym/portage/cache/sql_template.py 2008-07-01 17:32:45 UTC (rev 10881)
575 @@ -150,7 +150,7 @@
576 # so we store only what's handed to us and is a known key
577 db_values = []
578 for key in self._known_keys:
579 - if values.has_key(key) and values[key] != '':
580 + if key in values and values[key]:
581 db_values.append({"key":key, "value":values[key]})
582
583 if len(db_values) > 0:
584
585 Modified: main/branches/prefix/pym/portage/cache/template.py
586 ===================================================================
587 --- main/branches/prefix/pym/portage/cache/template.py 2008-07-01 17:22:29 UTC (rev 10880)
588 +++ main/branches/prefix/pym/portage/cache/template.py 2008-07-01 17:32:45 UTC (rev 10881)
589 @@ -6,6 +6,7 @@
590 from portage.cache import cache_errors
591 from portage.cache.cache_errors import InvalidRestriction
592 from portage.cache.mappings import ProtectedDict
593 +import warnings
594
595 class database(object):
596 # this is for metadata/cache transfer.
597 @@ -121,6 +122,9 @@
598 if self.has_key is database.has_key:
599 # prevent a possible recursive loop
600 raise NotImplementedError
601 + warnings.warn("portage.cache.template.database.has_key() is "
602 + "deprecated, override __contains__ instead",
603 + DeprecationWarning)
604 return self.has_key(cpv)
605
606 def __iter__(self):
607
608 Modified: main/branches/prefix/pym/portage/cvstree.py
609 ===================================================================
610 --- main/branches/prefix/pym/portage/cvstree.py 2008-07-01 17:22:29 UTC (rev 10880)
611 +++ main/branches/prefix/pym/portage/cvstree.py 2008-07-01 17:32:45 UTC (rev 10881)
612 @@ -17,13 +17,13 @@
613 mytarget=mysplit[-1]
614 mysplit=mysplit[:-1]
615 for mys in mysplit:
616 - if myentries["dirs"].has_key(mys):
617 + if mys in myentries["dirs"]:
618 myentries=myentries["dirs"][mys]
619 else:
620 return None
621 - if myentries["dirs"].has_key(mytarget):
622 + if mytarget in myentries["dirs"]:
623 return myentries["dirs"][mytarget]
624 - elif myentries["files"].has_key(mytarget):
625 + elif mytarget in myentries["files"]:
626 return myentries["files"][mytarget]
627 else:
628 return None
629 @@ -242,9 +242,9 @@
630 if file=="digest-framerd-2.4.3":
631 print mydir,file
632 if os.path.isdir(mydir+"/"+file):
633 - if not entries["dirs"].has_key(file):
634 + if file not in entries["dirs"]:
635 entries["dirs"][file]={"dirs":{},"files":{}}
636 - if entries["dirs"][file].has_key("status"):
637 + if "status" in entries["dirs"][file]:
638 if "exists" not in entries["dirs"][file]["status"]:
639 entries["dirs"][file]["status"]+=["exists"]
640 else:
641 @@ -252,9 +252,9 @@
642 elif os.path.isfile(mydir+"/"+file):
643 if file=="digest-framerd-2.4.3":
644 print "isfile"
645 - if not entries["files"].has_key(file):
646 + if file not in entries["files"]:
647 entries["files"][file]={"revision":"","date":"","flags":"","tags":""}
648 - if entries["files"][file].has_key("status"):
649 + if "status" in entries["files"][file]:
650 if file=="digest-framerd-2.4.3":
651 print "has status"
652 if "exists" not in entries["files"][file]["status"]:
653 @@ -270,7 +270,7 @@
654 print "stat'ing"
655 mystat=os.stat(mydir+"/"+file)
656 mytime=time.asctime(time.gmtime(mystat[ST_MTIME]))
657 - if not entries["files"][file].has_key("status"):
658 + if "status" not in entries["files"][file]:
659 if file=="digest-framerd-2.4.3":
660 print "status not set"
661 entries["files"][file]["status"]=[]
662
663 Modified: main/branches/prefix/pym/portage/dbapi/__init__.py
664 ===================================================================
665 --- main/branches/prefix/pym/portage/dbapi/__init__.py 2008-07-01 17:22:29 UTC (rev 10880)
666 +++ main/branches/prefix/pym/portage/dbapi/__init__.py 2008-07-01 17:32:45 UTC (rev 10881)
667 @@ -173,7 +173,7 @@
668
669 def invalidentry(self, mypath):
670 if mypath.endswith('portage_lockfile'):
671 - if not os.environ.has_key("PORTAGE_MASTER_PID"):
672 + if "PORTAGE_MASTER_PID" not in os.environ:
673 writemsg("Lockfile removed: %s\n" % mypath, 1)
674 unlockfile((mypath, None, None))
675 else:
676
677 Modified: main/branches/prefix/pym/portage/dbapi/bintree.py
678 ===================================================================
679 --- main/branches/prefix/pym/portage/dbapi/bintree.py 2008-07-01 17:22:29 UTC (rev 10880)
680 +++ main/branches/prefix/pym/portage/dbapi/bintree.py 2008-07-01 17:32:45 UTC (rev 10881)
681 @@ -706,7 +706,7 @@
682 #writemsg(green(" -- DONE!\n\n"))
683
684 for mypkg in self.remotepkgs.keys():
685 - if not self.remotepkgs[mypkg].has_key("CATEGORY"):
686 + if "CATEGORY" not in self.remotepkgs[mypkg]:
687 #old-style or corrupt package
688 writemsg("!!! Invalid remote binary package: "+mypkg+"\n",
689 noiselevel=-1)
690
691 Modified: main/branches/prefix/pym/portage/dbapi/vartree.py
692 ===================================================================
693 --- main/branches/prefix/pym/portage/dbapi/vartree.py 2008-07-01 17:22:29 UTC (rev 10880)
694 +++ main/branches/prefix/pym/portage/dbapi/vartree.py 2008-07-01 17:32:45 UTC (rev 10881)
695 @@ -89,7 +89,7 @@
696 """
697 cp = "/".join(catpkgsplit(cpv)[:2])
698 cps = cp+":"+slot
699 - if len(paths) == 0 and self._data.has_key(cps) \
700 + if len(paths) == 0 and cps in self._data \
701 and self._data[cps][0] == cpv and int(self._data[cps][1]) == int(counter):
702 del self._data[cps]
703 elif len(paths) > 0:
704 @@ -603,7 +603,7 @@
705 mystat = os.stat(self.getpath(mysplit[0]))[stat.ST_MTIME]
706 except OSError:
707 mystat = 0
708 - if use_cache and self.cpcache.has_key(mycp):
709 + if use_cache and mycp in self.cpcache:
710 cpc = self.cpcache[mycp]
711 if cpc[0] == mystat:
712 return cpc[1][:]
713 @@ -631,7 +631,7 @@
714 self._cpv_sort_ascending(returnme)
715 if use_cache:
716 self.cpcache[mycp] = [mystat, returnme[:]]
717 - elif self.cpcache.has_key(mycp):
718 + elif mycp in self.cpcache:
719 del self.cpcache[mycp]
720 return returnme
721
722 @@ -727,7 +727,7 @@
723 mykey = dep_getkey(mydep)
724 mycat = catsplit(mykey)[0]
725 if not use_cache:
726 - if self.matchcache.has_key(mycat):
727 + if mycat in self.matchcache:
728 del self.mtdircache[mycat]
729 del self.matchcache[mycat]
730 return list(self._iter_match(mydep,
731 @@ -737,11 +737,12 @@
732 except (IOError, OSError):
733 curmtime=0
734
735 - if not self.matchcache.has_key(mycat) or not self.mtdircache[mycat]==curmtime:
736 + if mycat not in self.matchcache or \
737 + self.mtdircache[mycat] != curmtime:
738 # clear cache entry
739 self.mtdircache[mycat] = curmtime
740 self.matchcache[mycat] = {}
741 - if not self.matchcache[mycat].has_key(mydep):
742 + if mydep not in self.matchcache[mycat]:
743 mymatch = list(self._iter_match(mydep,
744 self.cp_list(mydep.cp, use_cache=use_cache)))
745 self.matchcache[mycat][mydep] = mymatch
746 @@ -1302,7 +1303,7 @@
747 myprovides = {}
748 for node in self.getallcpv():
749 for mykey in self.get_provide(node):
750 - if myprovides.has_key(mykey):
751 + if mykey in myprovides:
752 myprovides[mykey] += [node]
753 else:
754 myprovides[mykey] = [node]
755 @@ -2736,7 +2737,7 @@
756 #if we have a file containing previously-merged config file md5sums, grab it.
757 conf_mem_file = os.path.join(destroot, CONFIG_MEMORY_FILE)
758 cfgfiledict = grabdict(conf_mem_file)
759 - if self.settings.has_key("NOCONFMEM"):
760 + if "NOCONFMEM" in self.settings:
761 cfgfiledict["IGNORE"]=1
762 else:
763 cfgfiledict["IGNORE"]=0
764
765 Modified: main/branches/prefix/pym/portage/dbapi/virtual.py
766 ===================================================================
767 --- main/branches/prefix/pym/portage/dbapi/virtual.py 2008-07-01 17:22:29 UTC (rev 10880)
768 +++ main/branches/prefix/pym/portage/dbapi/virtual.py 2008-07-01 17:32:45 UTC (rev 10881)
769 @@ -40,7 +40,7 @@
770 return result[:]
771
772 def cpv_exists(self, mycpv):
773 - return self.cpvdict.has_key(mycpv)
774 + return mycpv in self.cpvdict
775
776 def cp_list(self, mycp, use_cache=1):
777 cachelist = self._match_cache.get(mycp)
778 @@ -94,9 +94,9 @@
779 """Removes a cpv from the list of available packages."""
780 self._clear_cache()
781 mycp = cpv_getkey(mycpv)
782 - if self.cpvdict.has_key(mycpv):
783 + if mycpv in self.cpvdict:
784 del self.cpvdict[mycpv]
785 - if not self.cpdict.has_key(mycp):
786 + if mycp not in self.cpdict:
787 return
788 while mycpv in self.cpdict[mycp]:
789 del self.cpdict[mycp][self.cpdict[mycp].index(mycpv)]
790 @@ -129,4 +129,4 @@
791 fake_api = dir(dbapi)
792 for call in fake_api:
793 if not hasattr(self, call):
794 - setattr(self, call, f)
795 \ No newline at end of file
796 + setattr(self, call, f)
797
798 Modified: main/branches/prefix/pym/portage/dispatch_conf.py
799 ===================================================================
800 --- main/branches/prefix/pym/portage/dispatch_conf.py 2008-07-01 17:22:29 UTC (rev 10880)
801 +++ main/branches/prefix/pym/portage/dispatch_conf.py 2008-07-01 17:32:45 UTC (rev 10881)
802 @@ -31,7 +31,7 @@
803 sys.exit(1)
804
805 for key in mandatory_opts:
806 - if not opts.has_key(key):
807 + if key not in opts:
808 if key == "merge":
809 opts["merge"] = "sdiff --suppress-common-lines --output='%s' '%s' '%s'"
810 else:
811
812 Modified: main/branches/prefix/pym/portage/elog/__init__.py
813 ===================================================================
814 --- main/branches/prefix/pym/portage/elog/__init__.py 2008-07-01 17:22:29 UTC (rev 10880)
815 +++ main/branches/prefix/pym/portage/elog/__init__.py 2008-07-01 17:32:45 UTC (rev 10881)
816 @@ -73,13 +73,13 @@
817
818 ebuild_logentries = collect_ebuild_messages(os.path.join(mysettings["T"], "logging"))
819 all_logentries = collect_messages()
820 - if all_logentries.has_key(cpv):
821 + if cpv in all_logentries:
822 all_logentries[cpv] = _merge_logentries(ebuild_logentries, all_logentries[cpv])
823 else:
824 all_logentries[cpv] = ebuild_logentries
825
826 for key in _preserve_logentries.keys():
827 - if all_logentries.has_key(key):
828 + if key in all_logentries:
829 all_logentries[key] = _merge_logentries(_preserve_logentries[key], all_logentries[key])
830 else:
831 all_logentries[key] = _preserve_logentries[key]
832
833 Modified: main/branches/prefix/pym/portage/elog/filtering.py
834 ===================================================================
835 --- main/branches/prefix/pym/portage/elog/filtering.py 2008-07-01 17:22:29 UTC (rev 10880)
836 +++ main/branches/prefix/pym/portage/elog/filtering.py 2008-07-01 17:32:45 UTC (rev 10881)
837 @@ -12,7 +12,7 @@
838 for phase in logentries:
839 for msgtype, msgcontent in logentries[phase]:
840 if msgtype.upper() in loglevels or "*" in loglevels:
841 - if not rValue.has_key(phase):
842 + if phase not in rValue:
843 rValue[phase] = []
844 rValue[phase].append((msgtype, msgcontent))
845 return rValue
846
847 Modified: main/branches/prefix/pym/portage/elog/messages.py
848 ===================================================================
849 --- main/branches/prefix/pym/portage/elog/messages.py 2008-07-01 17:22:29 UTC (rev 10880)
850 +++ main/branches/prefix/pym/portage/elog/messages.py 2008-07-01 17:32:45 UTC (rev 10881)
851 @@ -76,9 +76,9 @@
852 if color == None:
853 color = "GOOD"
854 print colorize(color, " * ")+msg
855 - if not _msgbuffer.has_key(key):
856 + if key not in _msgbuffer:
857 _msgbuffer[key] = {}
858 - if not _msgbuffer[key].has_key(phase):
859 + if phase not in _msgbuffer[key]:
860 _msgbuffer[key][phase] = []
861 _msgbuffer[key][phase].append((level, msg))
862
863
864 Modified: main/branches/prefix/pym/portage/elog/mod_mail.py
865 ===================================================================
866 --- main/branches/prefix/pym/portage/elog/mod_mail.py 2008-07-01 17:22:29 UTC (rev 10880)
867 +++ main/branches/prefix/pym/portage/elog/mod_mail.py 2008-07-01 17:32:45 UTC (rev 10881)
868 @@ -8,7 +8,7 @@
869 from portage.util import writemsg
870
871 def process(mysettings, key, logentries, fulltext):
872 - if mysettings.has_key("PORTAGE_ELOG_MAILURI"):
873 + if "PORTAGE_ELOG_MAILURI" in mysettings:
874 myrecipient = mysettings["PORTAGE_ELOG_MAILURI"].split()[0]
875 else:
876 myrecipient = "root@localhost"
877
878 Modified: main/branches/prefix/pym/portage/elog/mod_mail_summary.py
879 ===================================================================
880 --- main/branches/prefix/pym/portage/elog/mod_mail_summary.py 2008-07-01 17:22:29 UTC (rev 10880)
881 +++ main/branches/prefix/pym/portage/elog/mod_mail_summary.py 2008-07-01 17:32:45 UTC (rev 10881)
882 @@ -33,7 +33,7 @@
883 count = "one package"
884 else:
885 count = "multiple packages"
886 - if mysettings.has_key("PORTAGE_ELOG_MAILURI"):
887 + if "PORTAGE_ELOG_MAILURI" in mysettings:
888 myrecipient = mysettings["PORTAGE_ELOG_MAILURI"].split()[0]
889 else:
890 myrecipient = "root@localhost"
891
892 Modified: main/branches/prefix/pym/portage/getbinpkg.py
893 ===================================================================
894 --- main/branches/prefix/pym/portage/getbinpkg.py 2008-07-01 17:22:29 UTC (rev 10880)
895 +++ main/branches/prefix/pym/portage/getbinpkg.py 2008-07-01 17:32:45 UTC (rev 10881)
896 @@ -479,15 +479,15 @@
897 metadatafile.close()
898 except (cPickle.UnpicklingError, OSError, IOError, EOFError):
899 metadata = {}
900 - if not metadata.has_key(baseurl):
901 + if baseurl not in metadata:
902 metadata[baseurl]={}
903 - if not metadata[baseurl].has_key("indexname"):
904 + if "indexname" not in metadata[baseurl]:
905 metadata[baseurl]["indexname"]=""
906 - if not metadata[baseurl].has_key("timestamp"):
907 + if "timestamp" not in metadata[baseurl]:
908 metadata[baseurl]["timestamp"]=0
909 - if not metadata[baseurl].has_key("unmodified"):
910 + if "unmodified" not in metadata[baseurl]:
911 metadata[baseurl]["unmodified"]=0
912 - if not metadata[baseurl].has_key("data"):
913 + if "data" not in metadata[baseurl]:
914 metadata[baseurl]["data"]={}
915
916 if not os.access(cache_path, os.W_OK):
917 @@ -649,7 +649,7 @@
918 out.flush()
919
920 try:
921 - if metadata[baseurl].has_key("modified") and metadata[baseurl]["modified"]:
922 + if "modified" in metadata[baseurl] and metadata[baseurl]["modified"]:
923 metadata[baseurl]["timestamp"] = int(time.time())
924 metadatafile = open(CACHE_PATH+"/remote_metadata.pickle", "w+")
925 cPickle.dump(metadata,metadatafile)
926
927 Modified: main/branches/prefix/pym/portage/glsa.py
928 ===================================================================
929 --- main/branches/prefix/pym/portage/glsa.py 2008-07-01 17:22:29 UTC (rev 10880)
930 +++ main/branches/prefix/pym/portage/glsa.py 2008-07-01 17:32:45 UTC (rev 10881)
931 @@ -92,7 +92,7 @@
932 """
933 rValue = []
934
935 - if myconfig.has_key("GLSA_DIR"):
936 + if "GLSA_DIR" in myconfig:
937 repository = myconfig["GLSA_DIR"]
938 else:
939 repository = os.path.join(myconfig["PORTDIR"], "metadata", "glsa")
940 @@ -407,7 +407,7 @@
941 @rtype: None
942 @return: None
943 """
944 - if self.config.has_key("GLSA_DIR"):
945 + if "GLSA_DIR" in self.config:
946 repository = "file://" + self.config["GLSA_DIR"]+"/"
947 else:
948 repository = "file://" + self.config["PORTDIR"] + "/metadata/glsa/"
949 @@ -470,7 +470,7 @@
950 self.packages = {}
951 for p in self.affected.getElementsByTagName("package"):
952 name = p.getAttribute("name")
953 - if not self.packages.has_key(name):
954 + if name not in self.packages:
955 self.packages[name] = []
956 tmp = {}
957 tmp["arch"] = p.getAttribute("arch")
958
959 Modified: main/branches/prefix/pym/portage/locks.py
960 ===================================================================
961 --- main/branches/prefix/pym/portage/locks.py 2008-07-01 17:22:29 UTC (rev 10880)
962 +++ main/branches/prefix/pym/portage/locks.py 2008-07-01 17:32:45 UTC (rev 10881)
963 @@ -290,9 +290,9 @@
964 host = "-".join(hostpid[:-1])
965 pid = hostpid[-1]
966
967 - if not mylist.has_key(filename):
968 + if filename not in mylist:
969 mylist[filename] = {}
970 - if not mylist[filename].has_key(host):
971 + if host not in mylist[filename]:
972 mylist[filename][host] = []
973 mylist[filename][host].append(pid)
974
975 @@ -302,7 +302,7 @@
976 results.append("Found %(count)s locks" % {"count":mycount})
977
978 for x in mylist:
979 - if mylist[x].has_key(myhost) or remove_all_locks:
980 + if myhost in mylist[x] or remove_all_locks:
981 mylockname = hardlock_name(path+"/"+x)
982 if hardlink_is_mine(mylockname, path+"/"+x) or \
983 not os.path.exists(path+"/"+x) or \
984
985 Modified: main/branches/prefix/pym/portage/manifest.py
986 ===================================================================
987 --- main/branches/prefix/pym/portage/manifest.py 2008-07-01 17:22:29 UTC (rev 10880)
988 +++ main/branches/prefix/pym/portage/manifest.py 2008-07-01 17:32:45 UTC (rev 10881)
989 @@ -419,9 +419,9 @@
990 """ Regenerate hashes for the given file """
991 if checkExisting:
992 self.checkFileHashes(ftype, fname, ignoreMissing=ignoreMissing)
993 - if not ignoreMissing and not self.fhashdict[ftype].has_key(fname):
994 + if not ignoreMissing and fname not in self.fhashdict[ftype]:
995 raise FileNotInManifestException(fname)
996 - if not self.fhashdict[ftype].has_key(fname):
997 + if fname not in self.fhashdict[ftype]:
998 self.fhashdict[ftype][fname] = {}
999 myhashkeys = list(self.hashes)
1000 if reuseExisting:
1001
1002 Modified: main/branches/prefix/pym/portage/util.py
1003 ===================================================================
1004 --- main/branches/prefix/pym/portage/util.py 2008-07-01 17:22:29 UTC (rev 10880)
1005 +++ main/branches/prefix/pym/portage/util.py 2008-07-01 17:32:45 UTC (rev 10881)
1006 @@ -175,7 +175,7 @@
1007 final_dict = {}
1008 for y in mydict.keys():
1009 if True:
1010 - if final_dict.has_key(y) and (incremental or (y in incrementals)):
1011 + if y in final_dict and (incremental or (y in incrementals)):
1012 final_dict[y] += " "+mydict[y][:]
1013 else:
1014 final_dict[y] = mydict[y][:]
1015 @@ -494,7 +494,7 @@
1016 cexpand[mystring]=""
1017 return ""
1018 numvars=numvars+1
1019 - if mydict.has_key(myvarname):
1020 + if myvarname in mydict:
1021 newstring=newstring+mydict[myvarname]
1022 else:
1023 newstring=newstring+mystring[pos]
1024
1025 --
1026 gentoo-commits@l.g.o mailing list