[elbe-devel] [PATCH v2 47/66] licencexml: Fix Pylint

Torben Hohn torben.hohn at linutronix.de
Wed Jun 10 13:52:49 CEST 2020


On Fri, Jun 05, 2020 at 01:07:11PM -0400, Olivier Dion wrote:
> 46:0:   R0205: (useless-object-inheritance)
> 101:15: W0703: (broad-except)
> 
> I put a warning level here because otherwise all Elbe build would fail
> if we use error level.  Basically because of missing paragraphs in the
> licenses.
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>

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

> ---
>  elbepack/licencexml.py | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/elbepack/licencexml.py b/elbepack/licencexml.py
> index f5f4ee5e..f9a748b5 100644
> --- a/elbepack/licencexml.py
> +++ b/elbepack/licencexml.py
> @@ -9,8 +9,9 @@ import io
>  import re
>  
>  import warnings
> +import logging
>  
> -from debian.copyright import Copyright, LicenseParagraph
> +from debian.copyright import Copyright, LicenseParagraph, NotMachineReadableError, MachineReadableFormatError
>  from elbepack.treeutils import etree
>  
>  warnings.simplefilter('error')
> @@ -42,7 +43,8 @@ def get_heuristics_license_list(c):
>  
>      return set(licenses)
>  
> -
> +# TODO:py3 Remove object inheritance
> +# pylint: disable=useless-object-inheritance
>  class copyright_xml (object):
>      def __init__(self):
>          self.outxml = etree(None)
> @@ -67,7 +69,13 @@ class copyright_xml (object):
>                                               .decode(encoding='utf-8',
>                                                       errors='replace'))
>          try:
> -            c = Copyright(bytesio)
> +            c = Copyright(bytesio, strict=True)
> +        except (NotMachineReadableError, MachineReadableFormatError) as E:
> +            logging.warning("Error in copyright of package '%s': %s", pkg_name, E)
> +        except Warning as W:
> +            logging.warning("Warning in copyrigh of package '%s' : %s", pkg_name, W)
> +        else:
> +
>              files = []
>  
>              for cc in c.all_files_paragraphs():
> @@ -98,9 +106,6 @@ class copyright_xml (object):
>  
>              return
>  
> -        except Exception:
> -            pass
> -
>          bytesio.seek(0)
>  
>          c = do_heuristics(bytesio)
> -- 
> 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