[Piuparts-commits] [piuparts] 02/02: Use "autopep8 -a --max-line-length=160" to re-format all .py files.

Holger Levsen holger at moszumanska.debian.org
Sun Apr 19 10:00:25 UTC 2015


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch develop
in repository piuparts.

commit 90969750956e9b5016cf3b1e84474d26e06e63d8
Author: Holger Levsen <holger at layer-acht.org>
Date:   Sun Apr 19 09:59:53 2015 +0000

    Use "autopep8 -a --max-line-length=160" to re-format all .py files.
---
 debian/changelog          |  3 ++-
 piuparts-report.py        |  8 ++++----
 piuparts-slave.py         |  2 +-
 piuparts.py               | 44 +++++++++++++++++++++-----------------------
 piupartslib/conf.py       |  1 +
 piupartslib/dwke.py       |  2 +-
 piupartslib/packagesdb.py |  4 ++--
 piupartslib/pkgsummary.py |  4 ++--
 8 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index fad33a1..5468eda 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -61,7 +61,8 @@ piuparts (0.63) UNRELEASED; urgency=medium
     - Switch links to lintian.debian.org to https.
   * crontab-slave.in: try to start slave every hour to make sure it's always
     running.
-  * Use "autopep8 --max-line-length=160" to re-format all .py files.
+  * Use "autopep8 --max-line-length=160" to re-format all .py files, then also
+    use "-a" on a 2nd run.
 
  -- Andreas Beckmann <anbe at debian.org>  Wed, 03 Dec 2014 20:36:30 +0100
 
diff --git a/piuparts-report.py b/piuparts-report.py
index b7876fa..1375f8b 100644
--- a/piuparts-report.py
+++ b/piuparts-report.py
@@ -622,7 +622,8 @@ def update_file(source, target):
     except OSError:
         try:
             shutil.copyfile(source, target)
-        except IOError as (errno, strerror):
+        except IOError as xxx_todo_changeme:
+            (errno, strerror) = xxx_todo_changeme.args
             logging.error("failed to copy %s to %s: I/O error(%d): %s"
                            % (source, target, errno, strerror))
 
@@ -820,8 +821,7 @@ class Section:
         for pathname, package, version in logs:
             packages[package] = packages.get(package, []) + [(pathname, version)]
 
-        names = packages.keys()
-        names.sort()
+        names = sorted(packages.keys())
         lines = []
         version_count = 0
         for package in names:
@@ -1062,7 +1062,7 @@ class Section:
                         "maintainer": html_protect(maintainer + " in " + self._config.section),
                         "distrolinks": distrolinks,
                         "rows": rows + "".join([package_rows[state] for state in states]),
-                    })
+            })
 
     def create_source_summary(self, source, logs_by_dir):
         source_version = self._source_db.get_control_header(source, "Version")
diff --git a/piuparts-slave.py b/piuparts-slave.py
index 0bb7faf..ab26c8c 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -319,7 +319,7 @@ class Slave:
             raise MasterNotOK()
 
     def _reserved_filename(self, name, version):
-        return os.path.join("reserved",  "%s_%s.log" % (name, version))
+        return os.path.join("reserved", "%s_%s.log" % (name, version))
 
     def remember_reservation(self, name, version):
         create_file(self._reserved_filename(name, version), "")
diff --git a/piuparts.py b/piuparts.py
index cf678aa..1391480 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -489,7 +489,7 @@ def run(command, ignore_errors=False, timeout=0):
             p.kill()
         p.wait()
 
-    assert type(command) == type([])
+    assert isinstance(command, type([]))
     logging.debug("Starting command: %s" % command)
     env = os.environ.copy()
     env["LC_ALL"] = "C"
@@ -554,7 +554,7 @@ def create_file(name, contents):
         f = file(name, "w")
         f.write(contents)
         f.close()
-    except IOError, detail:
+    except IOError as detail:
         logging.error("Couldn't create file %s: %s" % (name, detail))
         panic()
 
@@ -565,7 +565,7 @@ def remove_files(filenames):
         logging.debug("Removing %s" % filename)
         try:
             os.remove(filename)
-        except OSError, detail:
+        except OSError as detail:
             logging.error("Couldn't remove %s: %s" % (filename, detail))
             panic()
 
@@ -582,7 +582,7 @@ def make_metapackage(name, depends, conflicts):
     panic_handler_id = do_on_panic(lambda: shutil.rmtree(tmpdir))
     create_file(os.path.join(tmpdir, ".piuparts.tmpdir"), "metapackage creation")
     old_umask = os.umask(0)
-    os.makedirs(os.path.join(tmpdir, name, 'DEBIAN'), mode=0755)
+    os.makedirs(os.path.join(tmpdir, name, 'DEBIAN'), mode=0o755)
     os.umask(old_umask)
     control = deb822.Deb822()
     control['Package'] = name
@@ -703,7 +703,7 @@ class Chroot:
         """Create a temporary directory for the chroot."""
         self.name = tempfile.mkdtemp(dir=settings.tmpdir)
         create_file(os.path.join(self.name, ".piuparts.tmpdir"), "chroot")
-        os.chmod(self.name, 0755)
+        os.chmod(self.name, 0o755)
         logging.debug("Created temporary directory %s" % self.name)
 
     def create(self, temp_tgz=None):
@@ -813,7 +813,7 @@ class Chroot:
 
         run(['tar', '-czf', tmpfile, '--one-file-system', '--exclude', 'tmp/scripts', '-C', self.name, './'])
 
-        os.chmod(tmpfile, 0644)
+        os.chmod(tmpfile, 0o644)
         os.rename(tmpfile, result)
         dont_do_on_panic(panic_handler_id)
 
@@ -967,7 +967,7 @@ class Chroot:
             policy += 'test "$1" = "firebird2.5-super" && exit 0\n'
         policy += "exit 101\n"
         create_file(full_name, policy)
-        os.chmod(full_name, 0755)
+        os.chmod(full_name, 0o755)
         logging.debug("Created policy-rc.d and chmodded it.")
 
     def create_resolv_conf(self):
@@ -1085,7 +1085,7 @@ class Chroot:
         for source_name in source_names:
             try:
                 shutil.copy(source_name, target_name)
-            except IOError, detail:
+            except IOError as detail:
                 logging.error("Error copying %s to %s: %s" %
                               (source_name, target_name, detail))
                 panic()
@@ -1657,8 +1657,7 @@ class Chroot:
         if not os.path.exists(basepath):
             logging.error("Scripts directory %s does not exist" % basepath)
             panic()
-        list_scripts = os.listdir(basepath)
-        list_scripts.sort()
+        list_scripts = sorted(os.listdir(basepath))
         for vfile in list_scripts:
             if vfile.startswith(step):
                 script = os.path.join("tmp/scripts", vfile)
@@ -1684,9 +1683,9 @@ class VirtServ(Chroot):
         return l[1:]
 
     def _vs_send(self, cmd):
-        if type(cmd) == type([]):
+        if isinstance(cmd, type([])):
             def maybe_quote(a):
-                if type(a) != type(()):
+                if not isinstance(a, type(())):
                     return a
                 (a,) = a
                 return urllib.quote(a)
@@ -1765,7 +1764,7 @@ class VirtServ(Chroot):
         self._open()
 
     def _execute(self, cmdl, tolerate_errors=False):
-        assert type(cmdl) == type([])
+        assert isinstance(cmdl, type([]))
         prefix = ['sh', '-ec', '''
             LC_ALL=C
             unset LANGUAGES
@@ -1783,7 +1782,7 @@ class VirtServ(Chroot):
         if es and not tolerate_errors:
             stderr_data = self._getfilecontents(stderr)
             logging.error("Execution failed (status=%d): %s\n%s" %
-                          (es, `cmdl`, indent_string(stderr_data)))
+                          (es, repr(cmdl), indent_string(stderr_data)))
             panic()
         return (es, stdout, stderr)
 
@@ -1792,7 +1791,7 @@ class VirtServ(Chroot):
         stderr_data = self._getfilecontents(stderr)
         if es or stderr_data:
             logging.error('Internal command failed (status=%d): %s\n%s' %
-                          (es, `cmdl`, indent_string(stderr_data)))
+                          (es, repr(cmdl), indent_string(stderr_data)))
             panic()
         (_, tf) = create_temp_file()
         try:
@@ -1806,12 +1805,12 @@ class VirtServ(Chroot):
         cmdl = ['sh', '-ec', 'cd /\n' + ' '.join(command)]
         (es, stdout, stderr) = self._execute(cmdl, tolerate_errors=True)
         stdout_data = self._getfilecontents(stdout)
-        print >>sys.stderr, "VirtServ run", `command`, `cmdl`, '==>', `es`, `stdout`, `stderr`, '|', stdout_data
+        print >>sys.stderr, "VirtServ run", repr(command), repr(cmdl), '==>', repr(es), repr(stdout), repr(stderr), '|', stdout_data
         if es == 0 or ignore_errors:
             return (es, stdout_data)
         stderr_data = self._getfilecontents(stderr)
         logging.error('Command failed (status=%d): %s\n%s' %
-                      (es, `command`, indent_string(stdout_data + stderr_data)))
+                      (es, repr(command), indent_string(stdout_data + stderr_data)))
         panic()
 
     def setup_minimal_chroot(self):
@@ -1867,21 +1866,21 @@ class VirtServ(Chroot):
         try:
             f = file(tf)
 
-            while 1:
+            while True:
                 line = ''
-                while 1:
+                while True:
                     splut = line.split('\0')
                     if len(splut) == 8 and splut[7] == '\n':
                         break
                     if len(splut) >= 8:
                         self._fail('aaargh wrong output from find: %s' %
-                                   urllib.quote(line), `splut`)
+                                   urllib.quote(line), repr(splut))
                     l = f.readline()
                     if not l:
                         if not line:
                             break
                         self._fail('aargh missing final newline from find'
-                                   ': %s, %s' % (`l`[0:200], `splut`[0:200]))
+                                   ': %s, %s' % (repr(l)[0:200], repr(splut)[0:200]))
                     line += l
                 if not line:
                     break
@@ -2061,8 +2060,7 @@ def diff_meta_data(tree1, tree2):
 
 def file_list(meta_infos, file_owners):
     """Return list of indented filenames."""
-    meta_infos = meta_infos[:]
-    meta_infos.sort()
+    meta_infos = sorted(meta_infos[:])
     vlist = []
     for name, data in meta_infos:
         (st, target) = data
diff --git a/piupartslib/conf.py b/piupartslib/conf.py
index 161ac51..e06be68 100644
--- a/piupartslib/conf.py
+++ b/piupartslib/conf.py
@@ -30,6 +30,7 @@ import subprocess
 import collections
 import re
 import distro_info
+from functools import reduce
 
 
 class MissingSection(Exception):
diff --git a/piupartslib/dwke.py b/piupartslib/dwke.py
index 0e2624b..4894ac2 100644
--- a/piupartslib/dwke.py
+++ b/piupartslib/dwke.py
@@ -101,7 +101,7 @@ class Problem():
             if self.inc_re.search(logbody, re.MULTILINE):
                 for line in logbody.splitlines():
                     if self.inc_re.search(line):
-                        if self.exc_re == None \
+                        if self.exc_re is None \
                                 or not self.exc_re.search(line):
                             return True
 
diff --git a/piupartslib/packagesdb.py b/piupartslib/packagesdb.py
index 7731a2e..9fa5b25 100644
--- a/piupartslib/packagesdb.py
+++ b/piupartslib/packagesdb.py
@@ -44,7 +44,7 @@ apt_pkg.init_system()
 
 def rfc822_like_header_parse(input):
     headers = []
-    while 1:
+    while True:
         line = input.readline()
         if not line or line in ["\r\n", "\n"]:
             break
@@ -220,7 +220,7 @@ class LogDB:
         # Let's make it follow the umask.
         umask = os.umask(0)
         os.umask(umask)
-        os.chmod(temp_name, 0666 & ~umask)
+        os.chmod(temp_name, 0o666 & ~umask)
 
         full_name = os.path.join(subdir, self._log_name(package, version))
         try:
diff --git a/piupartslib/pkgsummary.py b/piupartslib/pkgsummary.py
index 688df9e..1c45fe9 100644
--- a/piupartslib/pkgsummary.py
+++ b/piupartslib/pkgsummary.py
@@ -96,7 +96,7 @@ DEFSEC = 'overall'
 FlagInfo = namedtuple('FlagInfo', ['word', 'priority', 'states'])
 
 flaginfo = {
-    'F': FlagInfo('Failed',  0, ["failed-testing"]),
+    'F': FlagInfo('Failed', 0, ["failed-testing"]),
             'X': FlagInfo('Blocked', 1, [
                           "cannot-be-tested",
                           "dependency-failed-testing",
@@ -107,7 +107,7 @@ flaginfo = {
                           "waiting-to-be-tested",
                           "waiting-for-dependency-to-be-tested",
                           ]),
-            'P': FlagInfo('Passed',  3, [
+            'P': FlagInfo('Passed', 3, [
                           "essential-required",
                           "successfully-tested",
                           ]),

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git



More information about the Piuparts-commits mailing list