lib/generators: mkKeyValueLine -> mkKeyValueLine (#20920)
Rename, since the previous name was potentially confusing.
This commit is contained in:
parent
80f2e535b3
commit
271c0f5451
|
@ -21,10 +21,10 @@ rec {
|
||||||
* character sep. If sep appears in k, it is escaped.
|
* character sep. If sep appears in k, it is escaped.
|
||||||
* Helper for synaxes with different separators.
|
* Helper for synaxes with different separators.
|
||||||
*
|
*
|
||||||
* mkKeyValueLine ":" "f:oo" "bar"
|
* mkKeyValueDefault ":" "f:oo" "bar"
|
||||||
* > "f\:oo:bar"
|
* > "f\:oo:bar"
|
||||||
*/
|
*/
|
||||||
mkKeyValueLine = sep: k: v:
|
mkKeyValueDefault = sep: k: v:
|
||||||
"${libStr.escape [sep] k}${sep}${toString v}";
|
"${libStr.escape [sep] k}${sep}${toString v}";
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ rec {
|
||||||
* mkKeyValue is the same as in toINI.
|
* mkKeyValue is the same as in toINI.
|
||||||
*/
|
*/
|
||||||
toKeyValue = {
|
toKeyValue = {
|
||||||
mkKeyValue ? mkKeyValueLine "="
|
mkKeyValue ? mkKeyValueDefault "="
|
||||||
}: attrs:
|
}: attrs:
|
||||||
let mkLine = k: v: mkKeyValue k v + "\n";
|
let mkLine = k: v: mkKeyValue k v + "\n";
|
||||||
in libStr.concatStrings (libAttr.mapAttrsToList mkLine attrs);
|
in libStr.concatStrings (libAttr.mapAttrsToList mkLine attrs);
|
||||||
|
@ -63,7 +63,7 @@ rec {
|
||||||
# apply transformations (e.g. escapes) to section names
|
# apply transformations (e.g. escapes) to section names
|
||||||
mkSectionName ? (name: libStr.escape [ "[" "]" ] name),
|
mkSectionName ? (name: libStr.escape [ "[" "]" ] name),
|
||||||
# format a setting line from key and value
|
# format a setting line from key and value
|
||||||
mkKeyValue ? mkKeyValueLine "="
|
mkKeyValue ? mkKeyValueDefault "="
|
||||||
}: attrsOfAttrs:
|
}: attrsOfAttrs:
|
||||||
let
|
let
|
||||||
# map function to string for each key val
|
# map function to string for each key val
|
||||||
|
|
|
@ -135,8 +135,8 @@ runTests {
|
||||||
# these tests assume attributes are converted to lists
|
# these tests assume attributes are converted to lists
|
||||||
# in alphabetical order
|
# in alphabetical order
|
||||||
|
|
||||||
testMkKeyValueLine = {
|
testMkKeyValueDefault = {
|
||||||
expr = generators.mkKeyValueLine ":" "f:oo" "bar";
|
expr = generators.mkKeyValueDefault ":" "f:oo" "bar";
|
||||||
expected = ''f\:oo:bar'';
|
expected = ''f\:oo:bar'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue