From 2a9036d2d11bc77f59d0fcf56bdc33dc201738d0 Mon Sep 17 00:00:00 2001 From: Bogdan Sikora Date: Tue, 21 Jan 2020 13:37:58 +0100 Subject: [PATCH 1/3] fix: correct has_issues --- license_sh/commands/run_license_sh.py | 3 +-- license_sh/helpers.py | 15 ++++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/license_sh/commands/run_license_sh.py b/license_sh/commands/run_license_sh.py index bbd5f35..7c4c2c1 100644 --- a/license_sh/commands/run_license_sh.py +++ b/license_sh/commands/run_license_sh.py @@ -68,7 +68,7 @@ def run_license_sh(arguments): dep_tree, license_map = runner.check() ignored_packages = ignored_packages_map[ProjectType.YARN.value] - filtered_dep_tree, licenses_not_found = get_dependency_tree_with_licenses( + filtered_dep_tree, licenses_not_found, has_issues = get_dependency_tree_with_licenses( dep_tree, whitelist, ignored_packages=ignored_packages, get_full_tree=tree ) @@ -98,5 +98,4 @@ def run_license_sh(arguments): get_full_tree=tree, ) - has_issues: bool = filtered_dep_tree.height > 0 exit(1 if has_issues else 0) diff --git a/license_sh/helpers.py b/license_sh/helpers.py index 686f980..15ce0bd 100644 --- a/license_sh/helpers.py +++ b/license_sh/helpers.py @@ -1,6 +1,8 @@ from typing import Tuple, Set, List from anytree import PreOrderIter, LevelOrderIter, AnyNode +from anytree.exporter import DictExporter +from anytree.importer import DictImporter from license_expression import Licensing try: @@ -180,13 +182,14 @@ def filter_dep_tree(tree: AnyNode) -> AnyNode: Returns: AnyNode -- Filtered tree """ - for node in LevelOrderIter(tree): + treeCopy = DictImporter().import_(DictExporter().export(tree)) + for node in LevelOrderIter(treeCopy): node.children = filter( lambda subnode: subnode.subtree_problem or subnode.license_problem, node.children, ) - return tree + return treeCopy def get_dependency_tree_with_licenses( @@ -206,7 +209,9 @@ def get_dependency_tree_with_licenses( annotated_dep_tree, unknown_licenses = annotate_dep_tree( dep_tree, whitelist=whitelist, ignored_packages=ignored_packages ) - filtered_dependency_tree = ( - annotated_dep_tree if get_full_tree else filter_dep_tree(annotated_dep_tree) + filtered_dependency_tree = filter_dep_tree(annotated_dep_tree) + has_issues = filtered_dependency_tree.height > 0 + dependency_tree = ( + annotated_dep_tree if get_full_tree else filtered_dependency_tree ) - return filtered_dependency_tree, unknown_licenses + return dependency_tree, unknown_licenses, has_issues From a6402236ca6cff6db896ea7f1e2078cb18d3ae02 Mon Sep 17 00:00:00 2001 From: Bogdan Sikora Date: Tue, 21 Jan 2020 13:38:30 +0100 Subject: [PATCH 2/3] fix: style update --- license_sh/commands/run_license_sh.py | 6 +++++- license_sh/helpers.py | 6 ++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/license_sh/commands/run_license_sh.py b/license_sh/commands/run_license_sh.py index 7c4c2c1..8d75480 100644 --- a/license_sh/commands/run_license_sh.py +++ b/license_sh/commands/run_license_sh.py @@ -68,7 +68,11 @@ def run_license_sh(arguments): dep_tree, license_map = runner.check() ignored_packages = ignored_packages_map[ProjectType.YARN.value] - filtered_dep_tree, licenses_not_found, has_issues = get_dependency_tree_with_licenses( + ( + filtered_dep_tree, + licenses_not_found, + has_issues, + ) = get_dependency_tree_with_licenses( dep_tree, whitelist, ignored_packages=ignored_packages, get_full_tree=tree ) diff --git a/license_sh/helpers.py b/license_sh/helpers.py index 15ce0bd..56b2849 100644 --- a/license_sh/helpers.py +++ b/license_sh/helpers.py @@ -211,7 +211,5 @@ def get_dependency_tree_with_licenses( ) filtered_dependency_tree = filter_dep_tree(annotated_dep_tree) has_issues = filtered_dependency_tree.height > 0 - dependency_tree = ( - annotated_dep_tree if get_full_tree else filtered_dependency_tree - ) - return dependency_tree, unknown_licenses, has_issues + dependency_tree = annotated_dep_tree if get_full_tree else filtered_dependency_tree + return dependency_tree, unknown_licenses, has_issues From 25abde79f37f8150ef86673593f95ce8818e074f Mon Sep 17 00:00:00 2001 From: Bogdan Sikora Date: Tue, 21 Jan 2020 13:41:31 +0100 Subject: [PATCH 3/3] feat: 1.0.15 version --- license_sh/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/license_sh/version.py b/license_sh/version.py index b19b12e..f871089 100644 --- a/license_sh/version.py +++ b/license_sh/version.py @@ -1 +1 @@ -__version__ = "1.0.14" +__version__ = "1.0.15"