From f3d02a47d9e222ca751bd2b57aa855cc386a9e29 Mon Sep 17 00:00:00 2001 From: Jonas Singe Date: Sun, 16 Jan 2022 23:17:03 +0100 Subject: [PATCH 1/2] Compatibility fixes and workarounds * Prevent TypeError in path_common by converting path set into list * Fix networkx version to 2.0 to circumvent AttributeError: 'DiGraph' object has no attribute 'number_of_selfloops' * Fix pytest version to 3.6 * Import mock from unittest for compatiblity with python 3.3 and above --- cppdep/cppdep.py | 2 +- requirements-test.txt | 2 +- requirements.txt | 2 +- test/test_cppdep.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cppdep/cppdep.py b/cppdep/cppdep.py index 0a60c75..2aa232f 100644 --- a/cppdep/cppdep.py +++ b/cppdep/cppdep.py @@ -86,7 +86,7 @@ def path_common(paths): """Returns common prefix path for the argument absolute normalized paths.""" if not paths: return '' - path = os.path.commonprefix(paths) + path = os.path.commonprefix(list(paths)) assert os.path.isabs(path) if path[-1] == os.path.sep: return os.path.dirname(path) diff --git a/requirements-test.txt b/requirements-test.txt index 93253de..4d4b09a 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,2 +1,2 @@ mock -pytest +pytest=3.6 diff --git a/requirements.txt b/requirements.txt index 97ec535..6f724a2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -networkx +networkx=2.0 pydot pydotplus PyYAML diff --git a/test/test_cppdep.py b/test/test_cppdep.py index b8bfce1..5c9a42c 100644 --- a/test/test_cppdep.py +++ b/test/test_cppdep.py @@ -21,7 +21,7 @@ import platform import re -import mock +from unittest import mock import pytest from cppdep import cppdep From e2426e9f07745be5b97dab97ffc4f8fcf41e1881 Mon Sep 17 00:00:00 2001 From: Jonas Singe Date: Sun, 16 Jan 2022 23:20:47 +0100 Subject: [PATCH 2/2] Adapted error handling In case the script aborts because a package has no sources, print the package name. In case of duplicated source file declarations inside one package, show a warning instead of aborting. --- cppdep/cppdep.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cppdep/cppdep.py b/cppdep/cppdep.py index 2aa232f..ab23c95 100644 --- a/cppdep/cppdep.py +++ b/cppdep/cppdep.py @@ -372,6 +372,8 @@ def __init__(self, name, group, src_paths, include_paths, alias_paths, self.ignore_paths = set() self.alias_paths = set() self.include_patterns = include_patterns + if src_paths is None: + raise Exception("No src_paths for {}".format(name)) self.__init_paths(src_paths, include_paths, alias_paths, ignore_paths) self.root = path_common(self.src_paths) self.components = [] @@ -395,10 +397,10 @@ def _update(path_container, arg_paths, check_dir=True): '%s is not a directory in %s (group %s).' % (path, self.group.path, self.group.name)) if abs_path in path_container: - raise InvalidArgumentError( - '%s is duplicated in %s.%s' % + warn('%s is duplicated in %s.%s' % (abs_path, self.group.name, self.name)) - path_container.add(abs_path) + else: + path_container.add(abs_path) _update(self.src_paths, src_paths, check_dir=False) _update(self.ignore_paths, ignore_paths, check_dir=False) @@ -809,7 +811,7 @@ def _dep_filter(nodes): for group_name, package_group in self.internal_groups.items(): for pkg_name, package in package_group.packages.items(): if not package.components: - assert not package.src_paths + assert not package.src_paths, pkg_name continue printer('\n' + '#' * 80) printer('analyzing dependencies among components in '