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

Olivier Dion dion at linutronix.de
Fri Jun 5 19:07:11 CEST 2020


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




More information about the elbe-devel mailing list