Third Party Packages eric7

Sat, 08 Jun 2024 15:57:58 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 08 Jun 2024 15:57:58 +0200
branch
eric7
changeset 10756
0702be694bc4
parent 10755
7d3687e3bec6
child 10757
7eed48700225

Third Party Packages
- Upgraded pip-licenses to version 4.4.0.

docs/ThirdParty.md file | annotate | diff | comparison | revisions
docs/changelog.md file | annotate | diff | comparison | revisions
src/eric7/PipInterface/piplicenses.py file | annotate | diff | comparison | revisions
--- a/docs/ThirdParty.md	Sat Jun 08 15:30:19 2024 +0200
+++ b/docs/ThirdParty.md	Sat Jun 08 15:57:58 2024 +0200
@@ -7,7 +7,7 @@
 |:------------:|:---------:|:----------------------------|
 | eradicate    |   2.3.0   | MIT License (Expat License) |
 | mccabe       |   0.7.0   | MIT License (Expat License) |
-| pip-licenses |   4.3.4   | MIT License (MIT)           |
+| pip-licenses |   4.4.0   | MIT License (MIT)           |
 | pycodestyle  |   2.11.1  | MIT License (Expat License) |
 | pyflakes     |   3.2.0   | MIT License (MIT)           |
 |              |           |                             |
--- a/docs/changelog.md	Sat Jun 08 15:30:19 2024 +0200
+++ b/docs/changelog.md	Sat Jun 08 15:57:58 2024 +0200
@@ -12,6 +12,8 @@
 - pip Interface
     - Added a configuration option to not include global environments in
       the selector list.
+- Third Party Packages
+    - Upgraded pip-licenses to version 4.4.0.
 
 ### Version 24.6
 - bug fixes
--- a/src/eric7/PipInterface/piplicenses.py	Sat Jun 08 15:30:19 2024 +0200
+++ b/src/eric7/PipInterface/piplicenses.py	Sat Jun 08 15:57:58 2024 +0200
@@ -66,7 +66,7 @@
 
 
 __pkgname__ = "pip-licenses"
-__version__ = "4.3.4"
+__version__ = "4.4.0"
 __author__ = "raimon"
 __license__ = "MIT"
 __summary__ = (
@@ -326,9 +326,15 @@
         )
 
         if fail_on_licenses:
-            failed_licenses = case_insensitive_set_intersect(
-                license_names, fail_on_licenses
-            )
+            failed_licenses = set()
+            if not args.partial_match:
+                failed_licenses = case_insensitive_set_intersect(
+                    license_names, fail_on_licenses
+                )
+            else:
+                failed_licenses = case_insensitive_partial_match_set_intersect(
+                    license_names, fail_on_licenses
+                )
             if failed_licenses:
                 sys.stderr.write(
                     "fail-on license {} was found for package "
@@ -341,9 +347,15 @@
                 sys.exit(1)
 
         if allow_only_licenses:
-            uncommon_licenses = case_insensitive_set_diff(
-                license_names, allow_only_licenses
-            )
+            uncommon_licenses = set()
+            if not args.partial_match:
+                uncommon_licenses = case_insensitive_set_diff(
+                    license_names, allow_only_licenses
+                )
+            else:
+                uncommon_licenses = case_insensitive_partial_match_set_diff(
+                    license_names, allow_only_licenses
+                )
             if len(uncommon_licenses) == len(license_names):
                 sys.stderr.write(
                     "license {} not in allow-only licenses was found"
@@ -423,6 +435,24 @@
     return common_items
 
 
+def case_insensitive_partial_match_set_intersect(set_a, set_b):
+    common_items = set()
+    for item_a in set_a:
+        for item_b in set_b:
+            if item_b.lower() in item_a.lower():
+                common_items.add(item_a)
+    return common_items
+
+
+def case_insensitive_partial_match_set_diff(set_a, set_b):
+    uncommon_items = set_a.copy()
+    for item_a in set_a:
+        for item_b in set_b:
+            if item_b.lower() in item_a.lower():
+                uncommon_items.remove(item_a)
+    return uncommon_items
+
+
 def case_insensitive_set_diff(set_a, set_b):
     """Same as set.difference() but case-insensitive"""
     uncommon_items = set()
@@ -574,6 +604,7 @@
     with_notice_file: bool
     filter_strings: bool
     filter_code_page: str
+    partial_match: bool
     fail_on: Optional[str]
     allow_only: Optional[str]
 
@@ -838,6 +869,12 @@
         help="fail (exit with code 1) on the first occurrence "
         "of the licenses not in the semicolon-separated list",
     )
+    verify_options.add_argument(
+        "--partial-match",
+        action="store_true",
+        default=False,
+        help="enables partial matching for --allow-only/--fail-on",
+    )
 
     return parser
 

eric ide

mercurial