@@ -125,7 +125,7 @@ limitations under the License.
125
125
local aux(idx, ret, val) =
126
126
if idx >= strLen then
127
127
ret + [val]
128
- else if str[idx : idx + cLen : 1 ] == c &&
128
+ else if str[idx: idx + cLen: 1 ] == c &&
129
129
(maxsplits == -1 || std.length (ret) < maxsplits) then
130
130
aux(idx + cLen, ret + [val], '' )
131
131
else
@@ -891,7 +891,7 @@ limitations under the License.
891
891
local
892
892
escapeStringToml = std.escapeStringJson ,
893
893
escapeKeyToml(key) =
894
- local bare_allowed = std.set (std.stringChars (" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-" ));
894
+ local bare_allowed = std.set (std.stringChars (' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-' ));
895
895
if std.setUnion (std.set (std.stringChars (key)), bare_allowed) == bare_allowed then key else escapeStringToml(key),
896
896
isTableArray(v) = std.isArray (v) && std.length (v) > 0 && std.all(std.map (std.isObject , v)),
897
897
isSection(v) = std.isObject (v) || isTableArray(v),
@@ -917,19 +917,19 @@ limitations under the License.
917
917
local separator = if inline then ' ' else '\n ' ;
918
918
local lines = ['[' + separator]
919
919
+ std.join ([',' + separator],
920
- [
921
- [new_indent + renderValue(v[i], indexedPath + [i], true , '' )]
922
- for i in range
923
- ])
920
+ [
921
+ [new_indent + renderValue(v[i], indexedPath + [i], true , '' )]
922
+ for i in range
923
+ ])
924
924
+ [separator + (if inline then '' else cindent) + ']' ];
925
925
std.join ('' , lines)
926
926
else if std.isObject (v) then
927
927
local lines = ['{ ' ]
928
928
+ std.join ([', ' ],
929
- [
930
- [escapeKeyToml(k) + ' = ' + renderValue(v[k], indexedPath + [k], true , '' )]
931
- for k in std.objectFields (v)
932
- ])
929
+ [
930
+ [escapeKeyToml(k) + ' = ' + renderValue(v[k], indexedPath + [k], true , '' )]
931
+ for k in std.objectFields (v)
932
+ ])
933
933
+ [' }' ];
934
934
std.join ('' , lines),
935
935
renderTableInternal(v, path, indexedPath, cindent) =
@@ -939,10 +939,11 @@ limitations under the License.
939
939
if !isSection(v[k])
940
940
]);
941
941
local sections = [std.join ('\n ' , kvp)] + [
942
- (if std.isObject (v[k]) then
943
- renderTable(v[k], path + [k], indexedPath + [k], cindent)
944
- else
945
- renderTableArray(v[k], path + [k], indexedPath + [k], cindent)
942
+ (
943
+ if std.isObject (v[k]) then
944
+ renderTable(v[k], path + [k], indexedPath + [k], cindent)
945
+ else
946
+ renderTableArray(v[k], path + [k], indexedPath + [k], cindent)
946
947
)
947
948
for k in std.objectFields (v)
948
949
if isSection(v[k])
@@ -956,8 +957,8 @@ limitations under the License.
956
957
local range = std.range (0 , std.length (v) - 1 );
957
958
local sections = [
958
959
(cindent + '[[' + std.join ('.' , std.map (escapeKeyToml, path)) + ']]'
959
- + (if v[i] == {} then '' else '\n ' )
960
- + renderTableInternal(v[i], path, indexedPath + [i], cindent + indent))
960
+ + (if v[i] == {} then '' else '\n ' )
961
+ + renderTableInternal(v[i], path, indexedPath + [i], cindent + indent))
961
962
for i in range
962
963
];
963
964
std.join ('\n\n ' , sections);
@@ -1076,11 +1077,24 @@ limitations under the License.
1076
1077
// the risk of missing a permutation.
1077
1078
local reserved = [
1078
1079
// Boolean types taken from https://yaml.org/type/bool.html
1079
- 'true' , 'false' , 'yes' , 'no' , 'on' , 'off' , 'y' , 'n' ,
1080
+ 'true' ,
1081
+ 'false' ,
1082
+ 'yes' ,
1083
+ 'no' ,
1084
+ 'on' ,
1085
+ 'off' ,
1086
+ 'y' ,
1087
+ 'n' ,
1080
1088
// Numerical words taken from https://yaml.org/type/float.html
1081
- '.nan' , '-.inf' , '+.inf' , '.inf' , 'null' ,
1089
+ '.nan' ,
1090
+ '-.inf' ,
1091
+ '+.inf' ,
1092
+ '.inf' ,
1093
+ 'null' ,
1082
1094
// Invalid keys that contain no invalid characters
1083
- '-' , '---' , '' ,
1095
+ '-' ,
1096
+ '---' ,
1097
+ '' ,
1084
1098
];
1085
1099
local bad = [word for word in reserved if word == std.asciiLower (key)];
1086
1100
if std.length (bad) > 0 then
@@ -1120,7 +1134,7 @@ limitations under the License.
1120
1134
local keySet = std.set (keyChars);
1121
1135
local keySetLc = std.set (std.stringChars (keyLc));
1122
1136
// Check for unsafe characters
1123
- if ! onlyChars(safeChars, keySet) then
1137
+ if !onlyChars(safeChars, keySet) then
1124
1138
false
1125
1139
// Check for reserved words
1126
1140
else if isReserved(key) then
@@ -1132,16 +1146,16 @@ limitations under the License.
1132
1146
- has exactly 2 dashes
1133
1147
are considered dates.
1134
1148
*/
1135
- else if onlyChars(dateChars, keySet)
1136
- && std.length (std.findSubstr ('-' , key)) == 2 then
1149
+ else if onlyChars(dateChars, keySet)
1150
+ && std.length (std.findSubstr ('-' , key)) == 2 then
1137
1151
false
1138
1152
/* Check for integers. Keys that meet all of the following:
1139
1153
- all characters match [0-9_\-]
1140
1154
- has at most 1 dash
1141
1155
are considered integers.
1142
1156
*/
1143
1157
else if onlyChars(intChars, keySetLc)
1144
- && std.length (std.findSubstr ('-' , key)) < 2 then
1158
+ && std.length (std.findSubstr ('-' , key)) < 2 then
1145
1159
false
1146
1160
/* Check for binary integers. Keys that meet all of the following:
1147
1161
- all characters match [0-9b_\-]
@@ -1150,8 +1164,8 @@ limitations under the License.
1150
1164
are considered binary integers.
1151
1165
*/
1152
1166
else if onlyChars(binChars, keySetLc)
1153
- && std.length (key) > 2
1154
- && typeMatch(key, '0b' ) then
1167
+ && std.length (key) > 2
1168
+ && typeMatch(key, '0b' ) then
1155
1169
false
1156
1170
/* Check for floats. Keys that meet all of the following:
1157
1171
- all characters match [0-9e._\-]
@@ -1161,9 +1175,9 @@ limitations under the License.
1161
1175
are considered floats.
1162
1176
*/
1163
1177
else if onlyChars(floatChars, keySetLc)
1164
- && std.length (std.findSubstr ('.' , key)) == 1
1165
- && std.length (std.findSubstr ('-' , key)) < 3
1166
- && std.length (std.findSubstr ('e' , keyLc)) < 2 then
1178
+ && std.length (std.findSubstr ('.' , key)) == 1
1179
+ && std.length (std.findSubstr ('-' , key)) < 3
1180
+ && std.length (std.findSubstr ('e' , keyLc)) < 2 then
1167
1181
false
1168
1182
/* Check for hexadecimals. Keys that meet all of the following:
1169
1183
- all characters match [0-9a-fx_\-]
@@ -1172,10 +1186,10 @@ limitations under the License.
1172
1186
- starts with (-)0x
1173
1187
are considered hexadecimals.
1174
1188
*/
1175
- else if onlyChars(hexChars, keySetLc)
1176
- && std.length (std.findSubstr ('-' , key)) < 2
1177
- && std.length (keyChars) > 2
1178
- && typeMatch(key, '0x' ) then
1189
+ else if onlyChars(hexChars, keySetLc)
1190
+ && std.length (std.findSubstr ('-' , key)) < 2
1191
+ && std.length (keyChars) > 2
1192
+ && typeMatch(key, '0x' ) then
1179
1193
false
1180
1194
// All checks pass. Key is safe for emission without quotes.
1181
1195
else true ;
@@ -1518,7 +1532,7 @@ limitations under the License.
1518
1532
else
1519
1533
patch,
1520
1534
1521
- get(o, f, default = null, inc_hidden = true)::
1535
+ get(o, f, default= null, inc_hidden= true)::
1522
1536
if std.objectHasEx(o, f, inc_hidden) then o[f] else default,
1523
1537
1524
1538
objectFields(o)::
@@ -1687,11 +1701,11 @@ limitations under the License.
1687
1701
__array_less_or_equal(arr1, arr2):: std.__compare_array(arr1, arr2) <= 0 ,
1688
1702
__array_greater_or_equal(arr1, arr2):: std.__compare_array(arr1, arr2) >= 0 ,
1689
1703
1690
- sum(arr):: std.foldl (function (a,b)a+b, arr,0 ),
1704
+ sum(arr):: std.foldl (function (a, b) a + b, arr, 0 ),
1691
1705
1692
- xor(x, y):: x!= y,
1706
+ xor(x, y):: x != y,
1693
1707
1694
- xnor(x, y):: x== y,
1708
+ xnor(x, y):: x == y,
1695
1709
1696
1710
isEmpty(str):: std.length (str) == 0 ,
1697
1711
}
0 commit comments