Normalize try/except indentation for compatibility with 2to3. (trunk
authorZac Medico <zmedico@gentoo.org>
Mon, 23 Mar 2009 02:18:55 +0000 (02:18 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 23 Mar 2009 02:18:55 +0000 (02:18 -0000)
r13136:13139)

svn path=/main/branches/2.1.6/; revision=13156

pym/_emerge/__init__.py
pym/portage/cache/flat_list.py
pym/portage/cache/sql_template.py
pym/portage/cache/util.py
pym/portage/versions.py

index 2dfafd211f372a8ae431d14ced99b7223240c1d8..6b26f594e5fcca6108f4fefbe05ee544bb1a03c0 100644 (file)
@@ -13040,8 +13040,10 @@ def action_metadata(settings, portdb, myopts):
                        self.call_update_mine = 0
 
                def update(self, *arg):
-                       try:                            self.pstr = int(self.pstr) + 1
-                       except ValueError:      self.pstr = 1
+                       try:
+                               self.pstr = int(self.pstr) + 1
+                       except ValueError:
+                               self.pstr = 1
                        sys.stdout.write("%s%i%%" % \
                                ("\b" * (len(str(self.pstr))+1), self.pstr))
                        sys.stdout.flush()
index 413d4d33d164ad4193f50214be871173af470e5f..8734e79b05fc93111aeb118ebde324e1c37d809f 100644 (file)
@@ -47,7 +47,8 @@ class database(fs_template.FsBased):
        def _setitem(self, cpv, values):
                s = cpv.rfind("/")
                fp=os.path.join(self._base,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:]))
-               try:    myf=open(fp, "w")
+               try:
+                       myf = open(fp, "w")
                except (OSError, IOError), e:
                        if errno.ENOENT == e.errno:
                                try:
@@ -66,7 +67,8 @@ class database(fs_template.FsBased):
                self._ensure_access(fp, mtime=values["_mtime_"])
                #update written.  now we move it.
                new_fp = os.path.join(self._base,cpv)
-               try:    os.rename(fp, new_fp)
+               try:
+                       os.rename(fp, new_fp)
                except (OSError, IOError), e:
                        os.remove(fp)
                        raise cache_errors.CacheCorruption(cpv, e)
index 47bef9124957dec236756fbe3d28fa62af200259..a002d6c06ecf75f5dbb0fe124ee31dcc852e0693 100644 (file)
@@ -72,7 +72,8 @@ class SQLDatabase(template.database):
                        if self.readonly:
                                raise cache_errors.ReadOnlyRestriction("table %s doesn't exist" % \
                                        self.SCHEMA_PACKAGE_NAME)
-                       try:    self.con.execute(self.SCHEMA_PACKAGE_CREATE)
+                       try:
+                               self.con.execute(self.SCHEMA_PACKAGE_CREATE)
                        except  self._BaseError, e:
                                raise cache_errors.InitializationError(self.__class__, e)
 
@@ -80,7 +81,8 @@ class SQLDatabase(template.database):
                        if self.readonly:
                                raise cache_errors.ReadOnlyRestriction("table %s doesn't exist" % \
                                        self.SCHEMA_VALUES_NAME)
-                       try:    self.con.execute(self.SCHEMA_VALUES_CREATE)
+                       try:
+                               self.con.execute(self.SCHEMA_VALUES_CREATE)
                        except  self._BaseError, e:
                                raise cache_errors.InitializationError(self.__class__, e)
 
@@ -97,7 +99,8 @@ class SQLDatabase(template.database):
 
 
        def _getitem(self, cpv):
-               try:    self.con.execute("SELECT key, value FROM %s NATURAL JOIN %s "
+               try:
+                       self.con.execute("SELECT key, value FROM %s NATURAL JOIN %s "
                        "WHERE label=%s AND cpv=%s" % (self.SCHEMA_PACKAGE_NAME, self.SCHEMA_VALUES_NAME,
                        self.label, self._sfilter(cpv)))
                except self._BaseError, e:
@@ -143,7 +146,8 @@ class SQLDatabase(template.database):
 
                try:
                        # insert.
-                       try:    pkgid = self._insert_cpv(cpv)
+                       try:
+                               pkgid = self._insert_cpv(cpv)
                        except self._BaseError, e:
                                raise cache_errors.CacheCorruption(cpv, e)
 
@@ -155,7 +159,8 @@ class SQLDatabase(template.database):
                                        db_values.append({"key":key, "value":values[key]})
 
                        if len(db_values) > 0:
-                               try:    self.con.executemany("INSERT INTO %s (pkgid, key, value) VALUES(\"%s\", %%(key)s, %%(value)s)" % \
+                               try:
+                                       self.con.executemany("INSERT INTO %s (pkgid, key, value) VALUES(\"%s\", %%(key)s, %%(value)s)" % \
                                        (self.SCHEMA_VALUES_NAME, str(pkgid)), db_values)
                                except self._BaseError, e:
                                        raise cache_errors.CacheCorruption(cpv, e)
@@ -164,8 +169,10 @@ class SQLDatabase(template.database):
 
                except Exception:
                        if not self.autocommits:
-                               try:    self.db.rollback()
-                               except self._BaseError: pass
+                               try:
+                                       self.db.rollback()
+                               except self._BaseError:
+                                       pass
                        raise
 
 
@@ -180,8 +187,10 @@ class SQLDatabase(template.database):
                        query_str = self.SCHEMA_INSERT_CPV_INTO_PACKAGE.replace("INSERT","REPLACE",1)
                else:
                        # just delete it.
-                       try:    del self[cpv]
-                       except  (cache_errors.CacheCorruption, KeyError):       pass
+                       try:
+                               del self[cpv]
+                       except (cache_errors.CacheCorruption, KeyError):
+                               pass
                        query_str = self.SCHEMA_INSERT_CPV_INTO_PACKAGE
                try:
                        self.con.execute(query_str % (self.label, cpv))
@@ -199,11 +208,13 @@ class SQLDatabase(template.database):
 
        def __contains__(self, cpv):
                if not self.autocommits:
-                       try:    self.commit()
+                       try:
+                               self.commit()
                        except self._BaseError, e:
                                raise cache_errors.GeneralCacheCorruption(e)
 
-               try:    self.con.execute("SELECT cpv FROM %s WHERE label=%s AND cpv=%s" % \
+               try:
+                       self.con.execute("SELECT cpv FROM %s WHERE label=%s AND cpv=%s" % \
                                (self.SCHEMA_PACKAGE_NAME, self.label, self._sfilter(cpv)))
                except self._BaseError, e:
                        raise cache_errors.GeneralCacheCorruption(e)
@@ -212,11 +223,13 @@ class SQLDatabase(template.database):
 
        def __iter__(self):
                if not self.autocommits:
-                       try:    self.commit()
+                       try:
+                               self.commit()
                        except self._BaseError, e:
                                raise cache_errors.GeneralCacheCorruption(e)
 
-               try:    self.con.execute("SELECT cpv FROM %s WHERE label=%s" % 
+               try:
+                       self.con.execute("SELECT cpv FROM %s WHERE label=%s" % 
                                (self.SCHEMA_PACKAGE_NAME, self.label))
                except self._BaseError, e:
                        raise cache_errors.GeneralCacheCorruption(e)
@@ -225,7 +238,8 @@ class SQLDatabase(template.database):
                        yield x[0]
 
        def iteritems(self):
-               try:    self.con.execute("SELECT cpv, key, value FROM %s NATURAL JOIN %s "
+               try:
+                       self.con.execute("SELECT cpv, key, value FROM %s NATURAL JOIN %s "
                        "WHERE label=%s" % (self.SCHEMA_PACKAGE_NAME, self.SCHEMA_VALUES_NAME,
                        self.label))
                except self._BaseError, e:
@@ -271,7 +285,8 @@ class SQLDatabase(template.database):
                        query = ''
 
                print "query = SELECT cpv from package_cache natural join values_cache WHERE label=%s %s" % (self.label, query)
-               try:    self.con.execute("SELECT cpv from package_cache natural join values_cache WHERE label=%s %s" % \
+               try:
+                       self.con.execute("SELECT cpv from package_cache natural join values_cache WHERE label=%s %s" % \
                                (self.label, query))
                except self._BaseError, e:
                        raise cache_errors.GeneralCacheCorruption(e)
index e152f50814e334c07644652722ee93eb85ae145c..9fcd4b49b1a7df8379438905c2fe4947a613e4e8 100644 (file)
@@ -29,7 +29,8 @@ def mirror_cache(valid_nodes_iterable, src_cache, trg_cache, eclass_cache=None,
 #              print "processing x=",x
                count+=1
                dead_nodes.discard(x)
-               try:    entry = src_cache[x]
+               try:
+                       entry = src_cache[x]
                except KeyError, e:
                        noise.missing_entry(x)
                        del e
@@ -111,7 +112,8 @@ def mirror_cache(valid_nodes_iterable, src_cache, trg_cache, eclass_cache=None,
 
                        # by this time, if it reaches here, the eclass has been validated, and the entry has 
                        # been updated/translated (if needs be, for metadata/cache mainly)
-                       try:    trg_cache[x] = entry
+                       try:
+                               trg_cache[x] = entry
                        except cache_errors.CacheError, ce:
                                noise.exception(x, ce)
                                del ce
index 261fa9deaf94c8560df5c2127fa9aed77be1d102..08e4a37445f360bbcb17b847844e6e471bceb605 100644 (file)
@@ -146,10 +146,14 @@ def vercmp(ver1, ver2, silent=1):
                if s1[1] != s2[1]:
                        # it's possible that the s(1|2)[1] == ''
                        # in such a case, fudge it.
-                       try:                    r1 = int(s1[1])
-                       except ValueError:      r1 = 0
-                       try:                    r2 = int(s2[1])
-                       except ValueError:      r2 = 0
+                       try:
+                               r1 = int(s1[1])
+                       except ValueError:
+                               r1 = 0
+                       try:
+                               r2 = int(s2[1])
+                       except ValueError:
+                               r2 = 0
                        if r1 - r2:
                                return r1 - r2