diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-08-25 13:18:28 +0200 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-09-09 13:55:05 +0200 |
commit | b853acea1d8fec0964aede10b87cbc3086bba744 (patch) | |
tree | 19a383e318435a4953d550207e246ebe7895a43d /src/hydrilla/proxy/simple_dependency_satisfying.py | |
parent | 17617de07c892e671d65f839360f23cd45c57d41 (diff) | |
download | haketilo-hydrilla-b853acea1d8fec0964aede10b87cbc3086bba744.tar.gz haketilo-hydrilla-b853acea1d8fec0964aede10b87cbc3086bba744.zip |
include offending mapping identifiers in exception when unable to resolve dependencies
Diffstat (limited to 'src/hydrilla/proxy/simple_dependency_satisfying.py')
-rw-r--r-- | src/hydrilla/proxy/simple_dependency_satisfying.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/hydrilla/proxy/simple_dependency_satisfying.py b/src/hydrilla/proxy/simple_dependency_satisfying.py index f1371db..78a1197 100644 --- a/src/hydrilla/proxy/simple_dependency_satisfying.py +++ b/src/hydrilla/proxy/simple_dependency_satisfying.py @@ -25,7 +25,11 @@ # in a proprietary program, I am not going to enforce this in court. """ -..... +This module contains logic to construct the dependency graph of Haketilo +packages and to perform dependency resolution. + +The approach taken here is a very simplified one. Hopefully, this will at some +point be replaced by a solution based on some SAT solver. """ # Enable using with Python 3.7. @@ -39,8 +43,9 @@ from .. import item_infos from .. import url_patterns +@dc.dataclass(frozen=True) class ImpossibleSituation(HaketiloException): - pass + bad_mapping_identifiers: frozenset[str] @dc.dataclass(frozen=True) @@ -219,13 +224,16 @@ class _ComputationData: if self.mappings.get(depended_identifier) not in choices: _mark_mappings(depended_identifier, reverse_deps, bad_mappings) - if any(identifier in self.required for identifier in bad_mappings): - raise ImpossibleSituation() + bad_required_mappings: list[str] = [] - for identifier in bad_mappings: - if identifier in self.required: - raise ImpossibleSituation() + for identifier in self.required: + if identifier in bad_mappings or identifier not in choices: + bad_required_mappings.append(identifier) + + if len(bad_required_mappings) > 0: + raise ImpossibleSituation(frozenset(bad_required_mappings)) + for identifier in bad_mappings: if identifier in self.mappings: choices.pop(identifier, None) |