[elbe-devel] [PATCH 29/75] filesystem: Fix Pylint

Olivier Dion dion at linutronix.de
Mon May 25 17:42:22 CEST 2020


15:0:   W0402: (deprecated-module)
54:0:   R0205: (useless-object-inheritance)
148:12: R1720: (no-else-raise)
228:33: E0602: (undefined-variable)

Signed-off-by: Olivier Dion <dion at linutronix.de>
---
 elbepack/filesystem.py | 18 ++++++++++--------
 elbepack/pkgutils.py   |  4 ++--
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/elbepack/filesystem.py b/elbepack/filesystem.py
index 99c5a013..b3cba99c 100644
--- a/elbepack/filesystem.py
+++ b/elbepack/filesystem.py
@@ -12,6 +12,7 @@ import errno
 
 from glob import glob
 from tempfile import mkdtemp
+# pylint: disable=deprecated-module
 from string import digits
 import gzip
 
@@ -51,6 +52,8 @@ def size_to_int(size):
 
     return int(s) * unit
 
+# TODO:py3 Remove object inheritance
+# pylint: disable=useless-object-inheritance
 class Filesystem(object):
 
     # pylint: disable=too-many-public-methods
@@ -105,7 +108,7 @@ class Filesystem(object):
             candidate = path.pop()
 
             # Don't care
-            if candidate == '' or candidate == os.curdir:
+            if candidate in ('', os.curdir):
                 continue
 
             # Can't go out of RFS
@@ -145,9 +148,7 @@ class Filesystem(object):
         try:
             os.symlink(src, self.fname(path))
         except OSError as e:
-            if e.errno != errno.EEXIST:
-                raise
-            elif not allow_exists:
+            if e.errno != errno.EEXIST or not allow_exists:
                 raise
 
     def stat(self, path):
@@ -208,7 +209,8 @@ class Filesystem(object):
 
         return flist
 
-    def _write_file(self, path, f, cont, mode):
+    @staticmethod
+    def _write_file(path, f, cont, mode):
         f.write(cont)
         f.close()
         if mode is not None:
@@ -222,10 +224,10 @@ class Filesystem(object):
         path = self.realpath(path)
         self._write_file(path, open(path, "a"), cont, mode)
 
-    def read_file(self, path, gzip=False):
+    def read_file(self, path, gzip_p=False):
         path = self.realpath(path)
-        if gzip:
-            fp = gzip.open(path, mode)
+        if gzip_p:
+            fp = gzip.open(path, "r")
         else:
             fp = open(path, "r")
 
diff --git a/elbepack/pkgutils.py b/elbepack/pkgutils.py
index a651012d..7a536a15 100644
--- a/elbepack/pkgutils.py
+++ b/elbepack/pkgutils.py
@@ -113,12 +113,12 @@ def extract_pkg_changelog(fname, extra_pkg=None):
     ret = ""
 
     if fs.exists(dch_bin):
-        ret += fs.read_file(dch_bin, gzip=True)
+        ret += fs.read_file(dch_bin, gzip_p=True)
     else:
         print("no bin")
 
     if fs.exists(dch_src):
-        ret += fs.read_file(dch_src, gzip=True)
+        ret += fs.read_file(dch_src, gzip_p=True)
     else:
         print("no source")
 
-- 
2.26.2




More information about the elbe-devel mailing list