mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-05 09:11:39 -05:00
pep508: Fix incorrect evaluation of groups
This commit is contained in:
parent
17cfb71c37
commit
d5a2bce5ec
1 changed files with 19 additions and 8 deletions
23
pep508.nix
23
pep508.nix
|
@ -43,7 +43,9 @@ let
|
||||||
exprPos = 0;
|
exprPos = 0;
|
||||||
startPos = 0;
|
startPos = 0;
|
||||||
} (lib.stringToCharacters expr);
|
} (lib.stringToCharacters expr);
|
||||||
in acc.exprs ++ [ (substr acc.exprPos acc.pos expr) ];
|
tailExpr = (substr acc.exprPos acc.pos expr);
|
||||||
|
tailExprs = if tailExpr != "" then [ tailExpr ] else [];
|
||||||
|
in acc.exprs ++ tailExprs;
|
||||||
|
|
||||||
parseExpressions = exprs: let
|
parseExpressions = exprs: let
|
||||||
splitCond = (s: builtins.map
|
splitCond = (s: builtins.map
|
||||||
|
@ -59,11 +61,14 @@ let
|
||||||
else {
|
else {
|
||||||
type = "expr";
|
type = "expr";
|
||||||
value = expr;
|
value = expr;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
parsed = builtins.filter (x: x != null) (builtins.map mapfn (splitCond exprs));
|
parse = expr: builtins.filter (x: x != null) (builtins.map mapfn (splitCond expr));
|
||||||
|
|
||||||
in if builtins.typeOf exprs == "string" then parsed else builtins.map parseExpressions exprs;
|
in builtins.foldl' (acc: v: acc ++ (
|
||||||
|
if builtins.typeOf v == "string" then parse v else [(parseExpressions v)]
|
||||||
|
)) [] exprs;
|
||||||
|
|
||||||
# Transform individual expressions to structured expressions
|
# Transform individual expressions to structured expressions
|
||||||
# This function also performs variable substitution, replacing environment markers with their explicit values
|
# This function also performs variable substitution, replacing environment markers with their explicit values
|
||||||
|
@ -155,7 +160,6 @@ let
|
||||||
"and" = x: y: x && y;
|
"and" = x: y: x && y;
|
||||||
"or" = x: y: x || y;
|
"or" = x: y: x || y;
|
||||||
};
|
};
|
||||||
|
|
||||||
reduceExpressionsFun = acc: v: (
|
reduceExpressionsFun = acc: v: (
|
||||||
if builtins.typeOf v == "set" then (
|
if builtins.typeOf v == "set" then (
|
||||||
if v.type == "value" then (
|
if v.type == "value" then (
|
||||||
|
@ -168,7 +172,14 @@ let
|
||||||
}
|
}
|
||||||
) else throw "Unsupported type"
|
) else throw "Unsupported type"
|
||||||
) else if builtins.typeOf v == "list" then (
|
) else if builtins.typeOf v == "list" then (
|
||||||
builtins.foldl' reduceExpressionsFun acc v
|
let
|
||||||
|
ret = builtins.foldl' reduceExpressionsFun {
|
||||||
|
value = true;
|
||||||
|
cond = "and";
|
||||||
|
} v;
|
||||||
|
in acc // {
|
||||||
|
value = cond."${acc.cond}" acc.value ret.value;
|
||||||
|
}
|
||||||
) else throw "Unsupported type"
|
) else throw "Unsupported type"
|
||||||
);
|
);
|
||||||
in (builtins.foldl' reduceExpressionsFun {
|
in (builtins.foldl' reduceExpressionsFun {
|
||||||
|
|
Loading…
Add table
Reference in a new issue