Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10870 - in main/trunk/pym: _emerge portage
Date: Tue, 01 Jul 2008 12:38:56
Message-Id: E1KDf8E-0004GY-FS@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-07-01 12:38:49 +0000 (Tue, 01 Jul 2008)
3 New Revision: 10870
4
5 Modified:
6 main/trunk/pym/_emerge/__init__.py
7 main/trunk/pym/portage/__init__.py
8 main/trunk/pym/portage/cvstree.py
9 main/trunk/pym/portage/dispatch_conf.py
10 main/trunk/pym/portage/getbinpkg.py
11 main/trunk/pym/portage/glsa.py
12 main/trunk/pym/portage/locks.py
13 main/trunk/pym/portage/manifest.py
14 main/trunk/pym/portage/util.py
15 Log:
16 Py3k compatibility patch #1 by Ali Polatel <hawking@g.o>.
17 Replace dict.has_key() calls with "in" and "not in" operators..
18
19
20 Modified: main/trunk/pym/_emerge/__init__.py
21 ===================================================================
22 --- main/trunk/pym/_emerge/__init__.py 2008-07-01 10:11:10 UTC (rev 10869)
23 +++ main/trunk/pym/_emerge/__init__.py 2008-07-01 12:38:49 UTC (rev 10870)
24 @@ -7299,7 +7299,7 @@
25 emergelog(xterm_titles, " *** Finished. Cleaning up...")
26
27 # We're out of the loop... We're done. Delete the resume data.
28 - if mtimedb.has_key("resume"):
29 + if "resume" in mtimedb:
30 del mtimedb["resume"]
31 mtimedb.commit()
32
33 @@ -7537,7 +7537,7 @@
34 # since we're pruning, we don't care about slots
35 # and put all the pkgs in together
36 myslot = 0
37 - if not slotmap.has_key(myslot):
38 + if myslot not in slotmap:
39 slotmap[myslot] = {}
40 slotmap[myslot][localtree.dbapi.cpv_counter(mypkg)] = mypkg
41
42 @@ -8241,7 +8241,7 @@
43 rsync_initial_timeout = 15
44
45 try:
46 - if settings.has_key("RSYNC_RETRIES"):
47 + if "RSYNC_RETRIES" in settings:
48 print yellow("WARNING:")+" usage of RSYNC_RETRIES is deprecated, use PORTAGE_RSYNC_RETRIES instead"
49 maxretries=int(settings["RSYNC_RETRIES"])
50 else:
51
52 Modified: main/trunk/pym/portage/__init__.py
53 ===================================================================
54 --- main/trunk/pym/portage/__init__.py 2008-07-01 10:11:10 UTC (rev 10869)
55 +++ main/trunk/pym/portage/__init__.py 2008-07-01 12:38:49 UTC (rev 10870)
56 @@ -160,7 +160,7 @@
57
58 def best_from_dict(key, top_dict, key_order, EmptyOnError=1, FullCopy=1, AllowEmpty=1):
59 for x in key_order:
60 - if top_dict.has_key(x) and top_dict[x].has_key(key):
61 + if x in top_dict and key in top_dict[x]:
62 if FullCopy:
63 return copy.deepcopy(top_dict[x][key])
64 else:
65 @@ -194,7 +194,7 @@
66 def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, followSymlinks=True):
67 global cacheHit,cacheMiss,cacheStale
68 mypath = normalize_path(my_original_path)
69 - if dircache.has_key(mypath):
70 + if mypath in dircache:
71 cacheHit += 1
72 cached_mtime, list, ftype = dircache[mypath]
73 else:
74 @@ -219,7 +219,7 @@
75 return None, None
76 # Python retuns mtime in seconds, so if it was changed in the last few seconds, it could be invalid
77 if mtime != cached_mtime or time.time() - mtime < 4:
78 - if dircache.has_key(mypath):
79 + if mypath in dircache:
80 cacheStale += 1
81 try:
82 list = os.listdir(mypath)
83 @@ -851,7 +851,7 @@
84
85 # Check the .config for a CONFIG_LOCALVERSION and append that too, also stripping whitespace
86 kernelconfig = getconfig(base_dir+"/.config")
87 - if kernelconfig and kernelconfig.has_key("CONFIG_LOCALVERSION"):
88 + if kernelconfig and "CONFIG_LOCALVERSION" in kernelconfig:
89 version += "".join(kernelconfig["CONFIG_LOCALVERSION"].split())
90
91 return (version,None)
92 @@ -1218,7 +1218,7 @@
93 self.prevmaskdict={}
94 for x in self.packages:
95 mycatpkg=dep_getkey(x)
96 - if not self.prevmaskdict.has_key(mycatpkg):
97 + if mycatpkg not in self.prevmaskdict:
98 self.prevmaskdict[mycatpkg]=[x]
99 else:
100 self.prevmaskdict[mycatpkg].append(x)
101 @@ -1440,7 +1440,7 @@
102 os.path.join(abs_user_config, "package.use"), recursive=1)
103 for key in pusedict.keys():
104 cp = dep_getkey(key)
105 - if not self.pusedict.has_key(cp):
106 + if cp not in self.pusedict:
107 self.pusedict[cp] = {}
108 self.pusedict[cp][key] = pusedict[key]
109
110 @@ -1452,7 +1452,8 @@
111 # default to ~arch if no specific keyword is given
112 if not pkgdict[key]:
113 mykeywordlist = []
114 - if self.configdict["defaults"] and self.configdict["defaults"].has_key("ACCEPT_KEYWORDS"):
115 + if self.configdict["defaults"] and \
116 + "ACCEPT_KEYWORDS" in self.configdict["defaults"]:
117 groups = self.configdict["defaults"]["ACCEPT_KEYWORDS"].split()
118 else:
119 groups = []
120 @@ -1461,7 +1462,7 @@
121 mykeywordlist.append("~"+keyword)
122 pkgdict[key] = mykeywordlist
123 cp = dep_getkey(key)
124 - if not self.pkeywordsdict.has_key(cp):
125 + if cp not in self.pkeywordsdict:
126 self.pkeywordsdict[cp] = {}
127 self.pkeywordsdict[cp][key] = pkgdict[key]
128
129 @@ -1482,7 +1483,7 @@
130 recursive=1)
131 for x in pkgunmasklines:
132 mycatpkg=dep_getkey(x)
133 - if self.punmaskdict.has_key(mycatpkg):
134 + if mycatpkg in self.punmaskdict:
135 self.punmaskdict[mycatpkg].append(x)
136 else:
137 self.punmaskdict[mycatpkg]=[x]
138 @@ -1506,7 +1507,7 @@
139 self.pmaskdict = {}
140 for x in pkgmasklines:
141 mycatpkg=dep_getkey(x)
142 - if self.pmaskdict.has_key(mycatpkg):
143 + if mycatpkg in self.pmaskdict:
144 self.pmaskdict[mycatpkg].append(x)
145 else:
146 self.pmaskdict[mycatpkg]=[x]
147 @@ -1544,7 +1545,7 @@
148 if not x:
149 continue
150 mycatpkg=dep_getkey(x)
151 - if self.pprovideddict.has_key(mycatpkg):
152 + if mycatpkg in self.pprovideddict:
153 self.pprovideddict[mycatpkg].append(x)
154 else:
155 self.pprovideddict[mycatpkg]=[x]
156 @@ -1806,7 +1807,7 @@
157
158 def backup_changes(self,key=None):
159 self.modifying()
160 - if key and self.configdict["env"].has_key(key):
161 + if key and key in self.configdict["env"]:
162 self.backupenv[key] = copy.deepcopy(self.configdict["env"][key])
163 else:
164 raise KeyError, "No such key defined in environment: %s" % key
165 @@ -2646,7 +2647,7 @@
166 if virts:
167 for x in virts:
168 vkeysplit = x.split("/")
169 - if not self.virts_p.has_key(vkeysplit[1]):
170 + if vkeysplit[1] not in self.virts_p:
171 self.virts_p[vkeysplit[1]] = virts[x]
172 return self.virts_p
173
174 @@ -2819,7 +2820,7 @@
175 # remain unset.
176 continue
177 mydict[x] = myvalue
178 - if not mydict.has_key("HOME") and mydict.has_key("BUILD_PREFIX"):
179 + if "HOME" not in mydict and "BUILD_PREFIX" in mydict:
180 writemsg("*** HOME not set. Setting to "+mydict["BUILD_PREFIX"]+"\n")
181 mydict["HOME"]=mydict["BUILD_PREFIX"][:]
182
183 @@ -3301,7 +3302,7 @@
184 # use_locks = 0
185
186 # local mirrors are always added
187 - if custommirrors.has_key("local"):
188 + if "local" in custommirrors:
189 mymirrors += custommirrors["local"]
190
191 if "nomirror" in restrict or \
192 @@ -3348,7 +3349,7 @@
193 primaryuri_dict = {}
194 for myuri in myuris:
195 myfile=os.path.basename(myuri)
196 - if not filedict.has_key(myfile):
197 + if myfile not in filedict:
198 filedict[myfile]=[]
199 for y in range(0,len(locations)):
200 filedict[myfile].append(locations[y]+"/distfiles/"+myfile)
201 @@ -3358,14 +3359,14 @@
202 mirrorname = myuri[9:eidx]
203
204 # Try user-defined mirrors first
205 - if custommirrors.has_key(mirrorname):
206 + if mirrorname in custommirrors:
207 for cmirr in custommirrors[mirrorname]:
208 filedict[myfile].append(cmirr+"/"+myuri[eidx+1:])
209 # remove the mirrors we tried from the list of official mirrors
210 if cmirr.strip() in thirdpartymirrors[mirrorname]:
211 thirdpartymirrors[mirrorname].remove(cmirr)
212 # now try the official mirrors
213 - if thirdpartymirrors.has_key(mirrorname):
214 + if mirrorname in thirdpartymirrors:
215 shuffle(thirdpartymirrors[mirrorname])
216
217 for locmirr in thirdpartymirrors[mirrorname]:
218 @@ -3382,7 +3383,7 @@
219 continue
220 if "primaryuri" in restrict:
221 # Use the source site first.
222 - if primaryuri_indexes.has_key(myfile):
223 + if myfile in primaryuri_indexes:
224 primaryuri_indexes[myfile] += 1
225 else:
226 primaryuri_indexes[myfile] = 0
227 @@ -3693,11 +3694,11 @@
228 continue
229 # allow different fetchcommands per protocol
230 protocol = loc[0:loc.find("://")]
231 - if mysettings.has_key("FETCHCOMMAND_"+protocol.upper()):
232 + if "FETCHCOMMAND_" + protocol.upper() in mysettings:
233 fetchcommand=mysettings["FETCHCOMMAND_"+protocol.upper()]
234 else:
235 fetchcommand=mysettings["FETCHCOMMAND"]
236 - if mysettings.has_key("RESUMECOMMAND_"+protocol.upper()):
237 + if "RESUMECOMMAND_" + protocol.upper() in mysettings:
238 resumecommand=mysettings["RESUMECOMMAND_"+protocol.upper()]
239 else:
240 resumecommand=mysettings["RESUMECOMMAND"]
241 @@ -3814,7 +3815,7 @@
242 except EnvironmentError:
243 pass
244
245 - if mydigests!=None and mydigests.has_key(myfile):
246 + if mydigests is not None and myfile in mydigests:
247 try:
248 mystat = os.stat(myfile_path)
249 except OSError, e:
250 @@ -4382,7 +4383,7 @@
251 ebuild_path = os.path.abspath(myebuild)
252 pkg_dir = os.path.dirname(ebuild_path)
253
254 - if mysettings.configdict["pkg"].has_key("CATEGORY"):
255 + if "CATEGORY" in mysettings.configdict["pkg"]:
256 cat = mysettings.configdict["pkg"]["CATEGORY"]
257 else:
258 cat = os.path.basename(normalize_path(os.path.join(pkg_dir, "..")))
259 @@ -4483,7 +4484,7 @@
260 else:
261 mysettings["PVR"]=mysplit[1]+"-"+mysplit[2]
262
263 - if mysettings.has_key("PATH"):
264 + if "PATH" in mysettings:
265 mysplit=mysettings["PATH"].split(":")
266 else:
267 mysplit=[]
268 @@ -6191,7 +6192,7 @@
269 pass
270 else:
271 mykey = dep_getkey(deplist[mypos])
272 - if mysettings and mysettings.pprovideddict.has_key(mykey) and \
273 + if mysettings and mykey in mysettings.pprovideddict and \
274 match_from_list(deplist[mypos], mysettings.pprovideddict[mykey]):
275 deplist[mypos]=True
276 elif mydbapi is None:
277 @@ -6242,12 +6243,13 @@
278 for x in mydb.categories:
279 if mydb.cp_list(x+"/"+mykey,use_cache=use_cache):
280 return x+"/"+mykey
281 - if virts_p.has_key(mykey):
282 + if mykey in virts_p:
283 return(virts_p[mykey][0])
284 return "null/"+mykey
285 elif mydb:
286 if hasattr(mydb, "cp_list"):
287 - if (not mydb.cp_list(mykey,use_cache=use_cache)) and virts and virts.has_key(mykey):
288 + if not mydb.cp_list(mykey, use_cache=use_cache) and \
289 + virts and mykey in virts:
290 return virts[mykey][0]
291 return mykey
292
293 @@ -6321,7 +6323,7 @@
294 mykey=matches[0]
295
296 if not mykey and not isinstance(mydb, list):
297 - if virts_p.has_key(myp):
298 + if myp in virts_p:
299 mykey=virts_p[myp][0]
300 #again, we only perform virtual expansion if we have a dbapi (not a list)
301 if not mykey:
302 @@ -6369,7 +6371,7 @@
303 locations.reverse()
304 pmasklists = [(x, grablines(os.path.join(x, "package.mask"), recursive=1)) for x in locations]
305
306 - if settings.pmaskdict.has_key(mycp):
307 + if mycp in settings.pmaskdict:
308 for x in settings.pmaskdict[mycp]:
309 if match_from_list(x, cpv_slot_list):
310 comment = ""
311 @@ -6750,7 +6752,7 @@
312
313 def portageexit():
314 global uid,portage_gid,portdb,db
315 - if secpass and not os.environ.has_key("SANDBOX_ACTIVE"):
316 + if secpass and os.environ.get("SANDBOX_ON") != "1":
317 close_portdbapi_caches()
318 commit_mtimedb()
319
320
321 Modified: main/trunk/pym/portage/cvstree.py
322 ===================================================================
323 --- main/trunk/pym/portage/cvstree.py 2008-07-01 10:11:10 UTC (rev 10869)
324 +++ main/trunk/pym/portage/cvstree.py 2008-07-01 12:38:49 UTC (rev 10870)
325 @@ -17,13 +17,13 @@
326 mytarget=mysplit[-1]
327 mysplit=mysplit[:-1]
328 for mys in mysplit:
329 - if myentries["dirs"].has_key(mys):
330 + if mys in myentries["dirs"]:
331 myentries=myentries["dirs"][mys]
332 else:
333 return None
334 - if myentries["dirs"].has_key(mytarget):
335 + if mytarget in myentries["dirs"]:
336 return myentries["dirs"][mytarget]
337 - elif myentries["files"].has_key(mytarget):
338 + elif mytarget in myentries["files"]:
339 return myentries["files"][mytarget]
340 else:
341 return None
342 @@ -242,9 +242,9 @@
343 if file=="digest-framerd-2.4.3":
344 print mydir,file
345 if os.path.isdir(mydir+"/"+file):
346 - if not entries["dirs"].has_key(file):
347 + if file not in entries["dirs"]:
348 entries["dirs"][file]={"dirs":{},"files":{}}
349 - if entries["dirs"][file].has_key("status"):
350 + if "status" in entries["dirs"][file]:
351 if "exists" not in entries["dirs"][file]["status"]:
352 entries["dirs"][file]["status"]+=["exists"]
353 else:
354 @@ -252,9 +252,9 @@
355 elif os.path.isfile(mydir+"/"+file):
356 if file=="digest-framerd-2.4.3":
357 print "isfile"
358 - if not entries["files"].has_key(file):
359 + if file not in entries["files"]:
360 entries["files"][file]={"revision":"","date":"","flags":"","tags":""}
361 - if entries["files"][file].has_key("status"):
362 + if "status" in entries["files"][file]:
363 if file=="digest-framerd-2.4.3":
364 print "has status"
365 if "exists" not in entries["files"][file]["status"]:
366 @@ -270,7 +270,7 @@
367 print "stat'ing"
368 mystat=os.stat(mydir+"/"+file)
369 mytime=time.asctime(time.gmtime(mystat[ST_MTIME]))
370 - if not entries["files"][file].has_key("status"):
371 + if "status" not in entries["files"][file]:
372 if file=="digest-framerd-2.4.3":
373 print "status not set"
374 entries["files"][file]["status"]=[]
375
376 Modified: main/trunk/pym/portage/dispatch_conf.py
377 ===================================================================
378 --- main/trunk/pym/portage/dispatch_conf.py 2008-07-01 10:11:10 UTC (rev 10869)
379 +++ main/trunk/pym/portage/dispatch_conf.py 2008-07-01 12:38:49 UTC (rev 10870)
380 @@ -31,7 +31,7 @@
381 sys.exit(1)
382
383 for key in mandatory_opts:
384 - if not opts.has_key(key):
385 + if key not in opts:
386 if key == "merge":
387 opts["merge"] = "sdiff --suppress-common-lines --output='%s' '%s' '%s'"
388 else:
389
390 Modified: main/trunk/pym/portage/getbinpkg.py
391 ===================================================================
392 --- main/trunk/pym/portage/getbinpkg.py 2008-07-01 10:11:10 UTC (rev 10869)
393 +++ main/trunk/pym/portage/getbinpkg.py 2008-07-01 12:38:49 UTC (rev 10870)
394 @@ -478,15 +478,15 @@
395 metadatafile.close()
396 except (cPickle.UnpicklingError, OSError, IOError, EOFError):
397 metadata = {}
398 - if not metadata.has_key(baseurl):
399 + if baseurl not in metadata:
400 metadata[baseurl]={}
401 - if not metadata[baseurl].has_key("indexname"):
402 + if "indexname" not in metadata[baseurl]:
403 metadata[baseurl]["indexname"]=""
404 - if not metadata[baseurl].has_key("timestamp"):
405 + if "timestamp" not in metadata[baseurl]:
406 metadata[baseurl]["timestamp"]=0
407 - if not metadata[baseurl].has_key("unmodified"):
408 + if "unmodified" not in metadata[baseurl]:
409 metadata[baseurl]["unmodified"]=0
410 - if not metadata[baseurl].has_key("data"):
411 + if "data" not in metadata[baseurl]:
412 metadata[baseurl]["data"]={}
413
414 if not os.access(cache_path, os.W_OK):
415 @@ -648,7 +648,7 @@
416 out.flush()
417
418 try:
419 - if metadata[baseurl].has_key("modified") and metadata[baseurl]["modified"]:
420 + if "modified" in metadata[baseurl] and metadata[baseurl]["modified"]:
421 metadata[baseurl]["timestamp"] = int(time.time())
422 metadatafile = open("/var/cache/edb/remote_metadata.pickle", "w+")
423 cPickle.dump(metadata,metadatafile)
424
425 Modified: main/trunk/pym/portage/glsa.py
426 ===================================================================
427 --- main/trunk/pym/portage/glsa.py 2008-07-01 10:11:10 UTC (rev 10869)
428 +++ main/trunk/pym/portage/glsa.py 2008-07-01 12:38:49 UTC (rev 10870)
429 @@ -92,7 +92,7 @@
430 """
431 rValue = []
432
433 - if myconfig.has_key("GLSA_DIR"):
434 + if "GLSA_DIR" in myconfig:
435 repository = myconfig["GLSA_DIR"]
436 else:
437 repository = os.path.join(myconfig["PORTDIR"], "metadata", "glsa")
438 @@ -407,7 +407,7 @@
439 @rtype: None
440 @return: None
441 """
442 - if self.config.has_key("GLSA_DIR"):
443 + if "GLSA_DIR" in self.config:
444 repository = "file://" + self.config["GLSA_DIR"]+"/"
445 else:
446 repository = "file://" + self.config["PORTDIR"] + "/metadata/glsa/"
447 @@ -470,7 +470,7 @@
448 self.packages = {}
449 for p in self.affected.getElementsByTagName("package"):
450 name = p.getAttribute("name")
451 - if not self.packages.has_key(name):
452 + if name not in self.packages:
453 self.packages[name] = []
454 tmp = {}
455 tmp["arch"] = p.getAttribute("arch")
456
457 Modified: main/trunk/pym/portage/locks.py
458 ===================================================================
459 --- main/trunk/pym/portage/locks.py 2008-07-01 10:11:10 UTC (rev 10869)
460 +++ main/trunk/pym/portage/locks.py 2008-07-01 12:38:49 UTC (rev 10870)
461 @@ -289,9 +289,9 @@
462 host = "-".join(hostpid[:-1])
463 pid = hostpid[-1]
464
465 - if not mylist.has_key(filename):
466 + if filename not in mylist:
467 mylist[filename] = {}
468 - if not mylist[filename].has_key(host):
469 + if host not in mylist[filename]:
470 mylist[filename][host] = []
471 mylist[filename][host].append(pid)
472
473 @@ -301,7 +301,7 @@
474 results.append("Found %(count)s locks" % {"count":mycount})
475
476 for x in mylist:
477 - if mylist[x].has_key(myhost) or remove_all_locks:
478 + if myhost in mylist[x] or remove_all_locks:
479 mylockname = hardlock_name(path+"/"+x)
480 if hardlink_is_mine(mylockname, path+"/"+x) or \
481 not os.path.exists(path+"/"+x) or \
482
483 Modified: main/trunk/pym/portage/manifest.py
484 ===================================================================
485 --- main/trunk/pym/portage/manifest.py 2008-07-01 10:11:10 UTC (rev 10869)
486 +++ main/trunk/pym/portage/manifest.py 2008-07-01 12:38:49 UTC (rev 10870)
487 @@ -419,9 +419,9 @@
488 """ Regenerate hashes for the given file """
489 if checkExisting:
490 self.checkFileHashes(ftype, fname, ignoreMissing=ignoreMissing)
491 - if not ignoreMissing and not self.fhashdict[ftype].has_key(fname):
492 + if not ignoreMissing and fname not in self.fhashdict[ftype]:
493 raise FileNotInManifestException(fname)
494 - if not self.fhashdict[ftype].has_key(fname):
495 + if fname not in self.fhashdict[ftype]:
496 self.fhashdict[ftype][fname] = {}
497 myhashkeys = list(self.hashes)
498 if reuseExisting:
499
500 Modified: main/trunk/pym/portage/util.py
501 ===================================================================
502 --- main/trunk/pym/portage/util.py 2008-07-01 10:11:10 UTC (rev 10869)
503 +++ main/trunk/pym/portage/util.py 2008-07-01 12:38:49 UTC (rev 10870)
504 @@ -174,7 +174,7 @@
505 final_dict = {}
506 for y in mydict.keys():
507 if True:
508 - if final_dict.has_key(y) and (incremental or (y in incrementals)):
509 + if y in final_dict and (incremental or (y in incrementals)):
510 final_dict[y] += " "+mydict[y][:]
511 else:
512 final_dict[y] = mydict[y][:]
513 @@ -493,7 +493,7 @@
514 cexpand[mystring]=""
515 return ""
516 numvars=numvars+1
517 - if mydict.has_key(myvarname):
518 + if myvarname in mydict:
519 newstring=newstring+mydict[myvarname]
520 else:
521 newstring=newstring+mystring[pos]
522
523 --
524 gentoo-commits@l.g.o mailing list