[elbe-devel] [PATCH v2 23/66] filesystem: Fix Pylint

Torben Hohn torben.hohn at linutronix.de
Wed Jun 10 13:32:54 CEST 2020


On Fri, Jun 05, 2020 at 01:06:47PM -0400, Olivier Dion wrote:
> 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>

Reviewed-by: Torben Hohn <torben.hohn 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
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list