diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-08-25 13:18:28 +0200 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-09-28 12:54:54 +0200 |
commit | c1f6a379b3a85303f487e1b366e96d9db90cd4e3 (patch) | |
tree | 363707a5d1809b2d3640eb3e934a0239a699f64f /src | |
parent | ad76c83354b2741b10fc2f9b12fea30dbd450e33 (diff) | |
download | haketilo-hydrilla-c1f6a379b3a85303f487e1b366e96d9db90cd4e3.tar.gz haketilo-hydrilla-c1f6a379b3a85303f487e1b366e96d9db90cd4e3.zip |
include offending mapping identifiers in exception when unable to resolve dependencies
Diffstat (limited to 'src')
-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) |