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

Torben Hohn torben.hohn at linutronix.de
Fri May 29 12:05:46 CEST 2020


On Mon, May 25, 2020 at 11:42:22AM -0400, Olivier Dion wrote:
> 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

this was a bug in pylint, its fixed now.
But it seems like string is still mentioned in .pylintrc
Please remove it from the deprecated modules in .pylintrc

>  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

this is confusing...

how about just changing the elif to if ?

>  
>      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):

gzip_p is ugly. use "gz" please.

>          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
> 
> 
> _______________________________________________
> 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