[elbe-devel] [PATCH v2 33/66] updated_monitors: Fix Pylint

Torben Hohn torben.hohn at linutronix.de
Wed Jun 10 13:34:42 CEST 2020


On Fri, Jun 05, 2020 at 01:06:57PM -0400, Olivier Dion wrote:
> 20:0:  R0205: (useless-object-inheritance)
> 36:20: E0602: (undefined-variable)
> 94:24: E0602: (undefined-variable)
> 93:8:  R0201: (no-self-use)
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>

> ---
>  elbepack/updated_monitors.py | 41 +++++++++++++++++++-----------------
>  1 file changed, 22 insertions(+), 19 deletions(-)
> 
> diff --git a/elbepack/updated_monitors.py b/elbepack/updated_monitors.py
> index 9d4ecfb6..16b4994f 100644
> --- a/elbepack/updated_monitors.py
> +++ b/elbepack/updated_monitors.py
> @@ -16,7 +16,8 @@ except ImportError:
>  
>  from elbepack.updated import is_update_file, handle_update_file
>  
> -
> +# TODO:py3 Remove object inheritance
> +# pylint: disable=useless-object-inheritance
>  class UpdateMonitor(object):
>      def __init__(self, status):
>          self.status = status
> @@ -33,14 +34,15 @@ class UpdateMonitor(object):
>  
>  if udev_available:
>      def get_mountpoint_for_device(dev):
> -        for line in file("/proc/mounts"):
> -            fields = line.split()
> -            try:
> -                if fields[0] == dev:
> -                    return fields[1]
> -            except BaseException:
> -                pass
> -        return None
> +        with open("/proc/mounts") as f:
> +            for line in f:
> +                fields = line.split()
> +                try:
> +                    if fields[0] == dev:
> +                        return fields[1]
> +                except BaseException:
> +                    pass
> +            return None
>  
>      class USBMonitor (UpdateMonitor):
>          def __init__(self, status, recursive=False):
> @@ -90,16 +92,17 @@ if udev_available:
>          def join(self):
>              self.observer.join()
>  
> -        def get_mountpoint_for_device(self, dev):
> -            for line in file("/proc/mounts"):
> -                fields = line.split()
> -                try:
> -                    if fields[0] == dev:
> -                        return fields[1]
> -                except BaseException:
> -                    pass
> -            return None
> -
> +        @staticmethod
> +        def get_mountpoint_for_device(dev):
> +            with open("/proc/mounts") as f:
> +                for line in f:
> +                    fields = line.split()
> +                    try:
> +                        if fields[0] == dev:
> +                            return fields[1]
> +                    except BaseException:
> +                        pass
> +                return None
>  
>  class FileMonitor (UpdateMonitor):
>  
> -- 
> 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