Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10872 - main/trunk/pym/portage/dbapi
Date: Tue, 01 Jul 2008 12:49:03
Message-Id: E1KDfI2-0004KD-5r@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-07-01 12:48:57 +0000 (Tue, 01 Jul 2008)
3 New Revision: 10872
4
5 Modified:
6 main/trunk/pym/portage/dbapi/__init__.py
7 main/trunk/pym/portage/dbapi/bintree.py
8 main/trunk/pym/portage/dbapi/vartree.py
9 main/trunk/pym/portage/dbapi/virtual.py
10 Log:
11 Py3k compatibility patch #3 by Ali Polatel <hawking@g.o>.
12 Replace dict.has_key() calls with "in" and "not in" operators.
13
14
15 Modified: main/trunk/pym/portage/dbapi/__init__.py
16 ===================================================================
17 --- main/trunk/pym/portage/dbapi/__init__.py 2008-07-01 12:42:15 UTC (rev 10871)
18 +++ main/trunk/pym/portage/dbapi/__init__.py 2008-07-01 12:48:57 UTC (rev 10872)
19 @@ -173,7 +173,7 @@
20
21 def invalidentry(self, mypath):
22 if mypath.endswith('portage_lockfile'):
23 - if not os.environ.has_key("PORTAGE_MASTER_PID"):
24 + if "PORTAGE_MASTER_PID" not in os.environ:
25 writemsg("Lockfile removed: %s\n" % mypath, 1)
26 unlockfile((mypath, None, None))
27 else:
28
29 Modified: main/trunk/pym/portage/dbapi/bintree.py
30 ===================================================================
31 --- main/trunk/pym/portage/dbapi/bintree.py 2008-07-01 12:42:15 UTC (rev 10871)
32 +++ main/trunk/pym/portage/dbapi/bintree.py 2008-07-01 12:48:57 UTC (rev 10872)
33 @@ -696,7 +696,7 @@
34 #writemsg(green(" -- DONE!\n\n"))
35
36 for mypkg in self.remotepkgs.keys():
37 - if not self.remotepkgs[mypkg].has_key("CATEGORY"):
38 + if "CATEGORY" not in self.remotepkgs[mypkg]:
39 #old-style or corrupt package
40 writemsg("!!! Invalid remote binary package: "+mypkg+"\n",
41 noiselevel=-1)
42
43 Modified: main/trunk/pym/portage/dbapi/vartree.py
44 ===================================================================
45 --- main/trunk/pym/portage/dbapi/vartree.py 2008-07-01 12:42:15 UTC (rev 10871)
46 +++ main/trunk/pym/portage/dbapi/vartree.py 2008-07-01 12:48:57 UTC (rev 10872)
47 @@ -89,7 +89,7 @@
48 """
49 cp = "/".join(catpkgsplit(cpv)[:2])
50 cps = cp+":"+slot
51 - if len(paths) == 0 and self._data.has_key(cps) \
52 + if len(paths) == 0 and cps in self._data \
53 and self._data[cps][0] == cpv and int(self._data[cps][1]) == int(counter):
54 del self._data[cps]
55 elif len(paths) > 0:
56 @@ -463,7 +463,7 @@
57 mystat = os.stat(self.getpath(mysplit[0]))[stat.ST_MTIME]
58 except OSError:
59 mystat = 0
60 - if use_cache and self.cpcache.has_key(mycp):
61 + if use_cache and mycp in self.cpcache:
62 cpc = self.cpcache[mycp]
63 if cpc[0] == mystat:
64 return cpc[1][:]
65 @@ -491,7 +491,7 @@
66 self._cpv_sort_ascending(returnme)
67 if use_cache:
68 self.cpcache[mycp] = [mystat, returnme[:]]
69 - elif self.cpcache.has_key(mycp):
70 + elif mycp in self.cpcache:
71 del self.cpcache[mycp]
72 return returnme
73
74 @@ -587,7 +587,7 @@
75 mykey = dep_getkey(mydep)
76 mycat = catsplit(mykey)[0]
77 if not use_cache:
78 - if self.matchcache.has_key(mycat):
79 + if mycat in self.matchcache:
80 del self.mtdircache[mycat]
81 del self.matchcache[mycat]
82 return list(self._iter_match(mydep,
83 @@ -597,11 +597,12 @@
84 except (IOError, OSError):
85 curmtime=0
86
87 - if not self.matchcache.has_key(mycat) or not self.mtdircache[mycat]==curmtime:
88 + if mycat not in self.matchcache or \
89 + self.mtdircache[mycat] != curmtime:
90 # clear cache entry
91 self.mtdircache[mycat] = curmtime
92 self.matchcache[mycat] = {}
93 - if not self.matchcache[mycat].has_key(mydep):
94 + if mydep not in self.matchcache[mycat]:
95 mymatch = list(self._iter_match(mydep,
96 self.cp_list(mydep.cp, use_cache=use_cache)))
97 self.matchcache[mycat][mydep] = mymatch
98 @@ -1162,7 +1163,7 @@
99 myprovides = {}
100 for node in self.getallcpv():
101 for mykey in self.get_provide(node):
102 - if myprovides.has_key(mykey):
103 + if mykey in myprovides:
104 myprovides[mykey] += [node]
105 else:
106 myprovides[mykey] = [node]
107 @@ -2593,7 +2594,7 @@
108 #if we have a file containing previously-merged config file md5sums, grab it.
109 conf_mem_file = os.path.join(destroot, CONFIG_MEMORY_FILE)
110 cfgfiledict = grabdict(conf_mem_file)
111 - if self.settings.has_key("NOCONFMEM"):
112 + if "NOCONFMEM" in self.settings:
113 cfgfiledict["IGNORE"]=1
114 else:
115 cfgfiledict["IGNORE"]=0
116
117 Modified: main/trunk/pym/portage/dbapi/virtual.py
118 ===================================================================
119 --- main/trunk/pym/portage/dbapi/virtual.py 2008-07-01 12:42:15 UTC (rev 10871)
120 +++ main/trunk/pym/portage/dbapi/virtual.py 2008-07-01 12:48:57 UTC (rev 10872)
121 @@ -40,7 +40,7 @@
122 return result[:]
123
124 def cpv_exists(self, mycpv):
125 - return self.cpvdict.has_key(mycpv)
126 + return mycpv in self.cpvdict
127
128 def cp_list(self, mycp, use_cache=1):
129 cachelist = self._match_cache.get(mycp)
130 @@ -94,9 +94,9 @@
131 """Removes a cpv from the list of available packages."""
132 self._clear_cache()
133 mycp = cpv_getkey(mycpv)
134 - if self.cpvdict.has_key(mycpv):
135 + if mycpv in self.cpvdict:
136 del self.cpvdict[mycpv]
137 - if not self.cpdict.has_key(mycp):
138 + if mycp not in self.cpdict:
139 return
140 while mycpv in self.cpdict[mycp]:
141 del self.cpdict[mycp][self.cpdict[mycp].index(mycpv)]
142 @@ -129,4 +129,4 @@
143 fake_api = dir(dbapi)
144 for call in fake_api:
145 if not hasattr(self, call):
146 - setattr(self, call, f)
147 \ No newline at end of file
148 + setattr(self, call, f)
149
150 --
151 gentoo-commits@l.g.o mailing list