Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r13156 - in main/branches/2.1.6/pym: _emerge portage portage/cache
Date: Mon, 23 Mar 2009 02:18:59
Message-Id: E1LlZke-0003uK-BO@stork.gentoo.org
1 Author: zmedico
2 Date: 2009-03-23 02:18:55 +0000 (Mon, 23 Mar 2009)
3 New Revision: 13156
4
5 Modified:
6 main/branches/2.1.6/pym/_emerge/__init__.py
7 main/branches/2.1.6/pym/portage/cache/flat_list.py
8 main/branches/2.1.6/pym/portage/cache/sql_template.py
9 main/branches/2.1.6/pym/portage/cache/util.py
10 main/branches/2.1.6/pym/portage/versions.py
11 Log:
12 Normalize try/except indentation for compatibility with 2to3. (trunk
13 r13136:13139)
14
15
16 Modified: main/branches/2.1.6/pym/_emerge/__init__.py
17 ===================================================================
18 --- main/branches/2.1.6/pym/_emerge/__init__.py 2009-03-23 02:17:03 UTC (rev 13155)
19 +++ main/branches/2.1.6/pym/_emerge/__init__.py 2009-03-23 02:18:55 UTC (rev 13156)
20 @@ -13040,8 +13040,10 @@
21 self.call_update_mine = 0
22
23 def update(self, *arg):
24 - try: self.pstr = int(self.pstr) + 1
25 - except ValueError: self.pstr = 1
26 + try:
27 + self.pstr = int(self.pstr) + 1
28 + except ValueError:
29 + self.pstr = 1
30 sys.stdout.write("%s%i%%" % \
31 ("\b" * (len(str(self.pstr))+1), self.pstr))
32 sys.stdout.flush()
33
34 Modified: main/branches/2.1.6/pym/portage/cache/flat_list.py
35 ===================================================================
36 --- main/branches/2.1.6/pym/portage/cache/flat_list.py 2009-03-23 02:17:03 UTC (rev 13155)
37 +++ main/branches/2.1.6/pym/portage/cache/flat_list.py 2009-03-23 02:18:55 UTC (rev 13156)
38 @@ -47,7 +47,8 @@
39 def _setitem(self, cpv, values):
40 s = cpv.rfind("/")
41 fp=os.path.join(self._base,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:]))
42 - try: myf=open(fp, "w")
43 + try:
44 + myf = open(fp, "w")
45 except (OSError, IOError), e:
46 if errno.ENOENT == e.errno:
47 try:
48 @@ -66,7 +67,8 @@
49 self._ensure_access(fp, mtime=values["_mtime_"])
50 #update written. now we move it.
51 new_fp = os.path.join(self._base,cpv)
52 - try: os.rename(fp, new_fp)
53 + try:
54 + os.rename(fp, new_fp)
55 except (OSError, IOError), e:
56 os.remove(fp)
57 raise cache_errors.CacheCorruption(cpv, e)
58
59 Modified: main/branches/2.1.6/pym/portage/cache/sql_template.py
60 ===================================================================
61 --- main/branches/2.1.6/pym/portage/cache/sql_template.py 2009-03-23 02:17:03 UTC (rev 13155)
62 +++ main/branches/2.1.6/pym/portage/cache/sql_template.py 2009-03-23 02:18:55 UTC (rev 13156)
63 @@ -72,7 +72,8 @@
64 if self.readonly:
65 raise cache_errors.ReadOnlyRestriction("table %s doesn't exist" % \
66 self.SCHEMA_PACKAGE_NAME)
67 - try: self.con.execute(self.SCHEMA_PACKAGE_CREATE)
68 + try:
69 + self.con.execute(self.SCHEMA_PACKAGE_CREATE)
70 except self._BaseError, e:
71 raise cache_errors.InitializationError(self.__class__, e)
72
73 @@ -80,7 +81,8 @@
74 if self.readonly:
75 raise cache_errors.ReadOnlyRestriction("table %s doesn't exist" % \
76 self.SCHEMA_VALUES_NAME)
77 - try: self.con.execute(self.SCHEMA_VALUES_CREATE)
78 + try:
79 + self.con.execute(self.SCHEMA_VALUES_CREATE)
80 except self._BaseError, e:
81 raise cache_errors.InitializationError(self.__class__, e)
82
83 @@ -97,7 +99,8 @@
84
85
86 def _getitem(self, cpv):
87 - try: self.con.execute("SELECT key, value FROM %s NATURAL JOIN %s "
88 + try:
89 + self.con.execute("SELECT key, value FROM %s NATURAL JOIN %s "
90 "WHERE label=%s AND cpv=%s" % (self.SCHEMA_PACKAGE_NAME, self.SCHEMA_VALUES_NAME,
91 self.label, self._sfilter(cpv)))
92 except self._BaseError, e:
93 @@ -143,7 +146,8 @@
94
95 try:
96 # insert.
97 - try: pkgid = self._insert_cpv(cpv)
98 + try:
99 + pkgid = self._insert_cpv(cpv)
100 except self._BaseError, e:
101 raise cache_errors.CacheCorruption(cpv, e)
102
103 @@ -155,7 +159,8 @@
104 db_values.append({"key":key, "value":values[key]})
105
106 if len(db_values) > 0:
107 - try: self.con.executemany("INSERT INTO %s (pkgid, key, value) VALUES(\"%s\", %%(key)s, %%(value)s)" % \
108 + try:
109 + self.con.executemany("INSERT INTO %s (pkgid, key, value) VALUES(\"%s\", %%(key)s, %%(value)s)" % \
110 (self.SCHEMA_VALUES_NAME, str(pkgid)), db_values)
111 except self._BaseError, e:
112 raise cache_errors.CacheCorruption(cpv, e)
113 @@ -164,8 +169,10 @@
114
115 except Exception:
116 if not self.autocommits:
117 - try: self.db.rollback()
118 - except self._BaseError: pass
119 + try:
120 + self.db.rollback()
121 + except self._BaseError:
122 + pass
123 raise
124
125
126 @@ -180,8 +187,10 @@
127 query_str = self.SCHEMA_INSERT_CPV_INTO_PACKAGE.replace("INSERT","REPLACE",1)
128 else:
129 # just delete it.
130 - try: del self[cpv]
131 - except (cache_errors.CacheCorruption, KeyError): pass
132 + try:
133 + del self[cpv]
134 + except (cache_errors.CacheCorruption, KeyError):
135 + pass
136 query_str = self.SCHEMA_INSERT_CPV_INTO_PACKAGE
137 try:
138 self.con.execute(query_str % (self.label, cpv))
139 @@ -199,11 +208,13 @@
140
141 def __contains__(self, cpv):
142 if not self.autocommits:
143 - try: self.commit()
144 + try:
145 + self.commit()
146 except self._BaseError, e:
147 raise cache_errors.GeneralCacheCorruption(e)
148
149 - try: self.con.execute("SELECT cpv FROM %s WHERE label=%s AND cpv=%s" % \
150 + try:
151 + self.con.execute("SELECT cpv FROM %s WHERE label=%s AND cpv=%s" % \
152 (self.SCHEMA_PACKAGE_NAME, self.label, self._sfilter(cpv)))
153 except self._BaseError, e:
154 raise cache_errors.GeneralCacheCorruption(e)
155 @@ -212,11 +223,13 @@
156
157 def __iter__(self):
158 if not self.autocommits:
159 - try: self.commit()
160 + try:
161 + self.commit()
162 except self._BaseError, e:
163 raise cache_errors.GeneralCacheCorruption(e)
164
165 - try: self.con.execute("SELECT cpv FROM %s WHERE label=%s" %
166 + try:
167 + self.con.execute("SELECT cpv FROM %s WHERE label=%s" %
168 (self.SCHEMA_PACKAGE_NAME, self.label))
169 except self._BaseError, e:
170 raise cache_errors.GeneralCacheCorruption(e)
171 @@ -225,7 +238,8 @@
172 yield x[0]
173
174 def iteritems(self):
175 - try: self.con.execute("SELECT cpv, key, value FROM %s NATURAL JOIN %s "
176 + try:
177 + self.con.execute("SELECT cpv, key, value FROM %s NATURAL JOIN %s "
178 "WHERE label=%s" % (self.SCHEMA_PACKAGE_NAME, self.SCHEMA_VALUES_NAME,
179 self.label))
180 except self._BaseError, e:
181 @@ -271,7 +285,8 @@
182 query = ''
183
184 print "query = SELECT cpv from package_cache natural join values_cache WHERE label=%s %s" % (self.label, query)
185 - try: self.con.execute("SELECT cpv from package_cache natural join values_cache WHERE label=%s %s" % \
186 + try:
187 + self.con.execute("SELECT cpv from package_cache natural join values_cache WHERE label=%s %s" % \
188 (self.label, query))
189 except self._BaseError, e:
190 raise cache_errors.GeneralCacheCorruption(e)
191
192 Modified: main/branches/2.1.6/pym/portage/cache/util.py
193 ===================================================================
194 --- main/branches/2.1.6/pym/portage/cache/util.py 2009-03-23 02:17:03 UTC (rev 13155)
195 +++ main/branches/2.1.6/pym/portage/cache/util.py 2009-03-23 02:18:55 UTC (rev 13156)
196 @@ -29,7 +29,8 @@
197 # print "processing x=",x
198 count+=1
199 dead_nodes.discard(x)
200 - try: entry = src_cache[x]
201 + try:
202 + entry = src_cache[x]
203 except KeyError, e:
204 noise.missing_entry(x)
205 del e
206 @@ -111,7 +112,8 @@
207
208 # by this time, if it reaches here, the eclass has been validated, and the entry has
209 # been updated/translated (if needs be, for metadata/cache mainly)
210 - try: trg_cache[x] = entry
211 + try:
212 + trg_cache[x] = entry
213 except cache_errors.CacheError, ce:
214 noise.exception(x, ce)
215 del ce
216
217 Modified: main/branches/2.1.6/pym/portage/versions.py
218 ===================================================================
219 --- main/branches/2.1.6/pym/portage/versions.py 2009-03-23 02:17:03 UTC (rev 13155)
220 +++ main/branches/2.1.6/pym/portage/versions.py 2009-03-23 02:18:55 UTC (rev 13156)
221 @@ -146,10 +146,14 @@
222 if s1[1] != s2[1]:
223 # it's possible that the s(1|2)[1] == ''
224 # in such a case, fudge it.
225 - try: r1 = int(s1[1])
226 - except ValueError: r1 = 0
227 - try: r2 = int(s2[1])
228 - except ValueError: r2 = 0
229 + try:
230 + r1 = int(s1[1])
231 + except ValueError:
232 + r1 = 0
233 + try:
234 + r2 = int(s2[1])
235 + except ValueError:
236 + r2 = 0
237 if r1 - r2:
238 return r1 - r2