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