Skip to content

Commit

Permalink
Authorize qualifier dictionaries in Dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienBortolussiAda committed Sep 15, 2023
1 parent 83bfeaf commit f7c506d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/e3/anod/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(
host: str | None = None,
target: str | None = None,
build: str | None = None,
qualifier: str | None = None,
qualifier: str | None | dict[str, str | bool] = None,
local_name: str | None = None,
require: Literal["build_tree"]
| Literal["installation"]
Expand Down Expand Up @@ -79,8 +79,24 @@ def __init__(
self.host = host
self.target = target
self.build = build
self.qualifier = qualifier
self.local_name = local_name if local_name is not None else name

self.qualifier: str | None
if isinstance(qualifier, dict):
for q in set(qualifier.keys()):
v = qualifier[q]
if isinstance(v, bool):
# It's a tag qualifier
if v:
qualifier[q] = ""
else:
qualifier.pop(q)
self.qualifier = ",".join(
[f"{key}{'=' if val else ''}{val}" for key, val in qualifier.items()]
)
else:
self.qualifier = qualifier

if require not in (
"build_tree",
"download",
Expand Down
8 changes: 8 additions & 0 deletions tests/tests_e3/anod/deps/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,11 @@ class MockAnod:
d.env(parent_anod_instance, default_env=defaultenv).target.platform
== defaultenv.build.platform
)


def test_dependency4():
d = e3.anod.deps.Dependency(
"dep", qualifier={"q1": False, "q2": True, "q_str": "str"}
)

assert d.qualifier == "q2,q_str=str"

0 comments on commit f7c506d

Please sign in to comment.