[elbe-devel] [PATCH v2 23/66] filesystem: Fix Pylint
Olivier Dion
dion at linutronix.de
Fri Jun 5 19:06:47 CEST 2020
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 | 15 +++++++++------
elbepack/pkgutils.py | 4 ++--
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/elbepack/filesystem.py b/elbepack/filesystem.py
index 99c5a013..ffc5d100 100644
--- a/elbepack/filesystem.py
+++ b/elbepack/filesystem.py
@@ -51,6 +51,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 +107,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
@@ -147,7 +149,7 @@ class Filesystem(object):
except OSError as e:
if e.errno != errno.EEXIST:
raise
- elif not allow_exists:
+ if not allow_exists:
raise
def stat(self, path):
@@ -208,7 +210,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 +225,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, gz=False):
path = self.realpath(path)
- if gzip:
- fp = gzip.open(path, mode)
+ if gz:
+ fp = gzip.open(path, "r")
else:
fp = open(path, "r")
diff --git a/elbepack/pkgutils.py b/elbepack/pkgutils.py
index a651012d..be567b65 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, gz=True)
else:
print("no bin")
if fs.exists(dch_src):
- ret += fs.read_file(dch_src, gzip=True)
+ ret += fs.read_file(dch_src, gz=True)
else:
print("no source")
--
2.27.0
More information about the elbe-devel
mailing list