foamlib 0.8.3__py3-none-any.whl → 0.8.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- foamlib/__init__.py +1 -1
- foamlib/_files/_files.py +3 -3
- foamlib/_files/_parsing.py +21 -5
- foamlib/_files/_serialization.py +4 -1
- {foamlib-0.8.3.dist-info → foamlib-0.8.4.dist-info}/METADATA +1 -1
- {foamlib-0.8.3.dist-info → foamlib-0.8.4.dist-info}/RECORD +8 -8
- {foamlib-0.8.3.dist-info → foamlib-0.8.4.dist-info}/WHEEL +0 -0
- {foamlib-0.8.3.dist-info → foamlib-0.8.4.dist-info}/licenses/LICENSE.txt +0 -0
foamlib/__init__.py
CHANGED
foamlib/_files/_files.py
CHANGED
@@ -308,15 +308,15 @@ class FoamFile(
|
|
308
308
|
self[(*keywords, k)] = v
|
309
309
|
|
310
310
|
elif keywords:
|
311
|
+
val = dumps(data, kind=kind)
|
311
312
|
parsed.put(
|
312
313
|
keywords,
|
313
314
|
normalize(data, kind=kind),
|
314
315
|
before
|
315
316
|
+ indentation
|
316
317
|
+ dumps(keywords[-1])
|
317
|
-
+ b" "
|
318
|
-
+
|
319
|
-
+ b";"
|
318
|
+
+ ((b" " + val) if val else b"")
|
319
|
+
+ (b";" if not keywords[-1].startswith("#") else b"")
|
320
320
|
+ after,
|
321
321
|
)
|
322
322
|
|
foamlib/_files/_parsing.py
CHANGED
@@ -153,12 +153,19 @@ def _tensor_list(
|
|
153
153
|
|
154
154
|
|
155
155
|
def _dict_of(
|
156
|
-
keyword: ParserElement,
|
156
|
+
keyword: ParserElement,
|
157
|
+
data: ParserElement,
|
158
|
+
*,
|
159
|
+
directive: ParserElement | None = None,
|
160
|
+
located: bool = False,
|
157
161
|
) -> ParserElement:
|
158
162
|
dict_ = Forward()
|
159
163
|
|
160
164
|
keyword_entry = keyword + (dict_ | (data + Literal(";").suppress()))
|
161
165
|
|
166
|
+
if directive is not None:
|
167
|
+
keyword_entry |= directive + data + LineEnd().suppress() # type: ignore [no-untyped-call]
|
168
|
+
|
162
169
|
if located:
|
163
170
|
keyword_entry = Located(keyword_entry)
|
164
171
|
|
@@ -175,12 +182,17 @@ def _keyword_entry_of(
|
|
175
182
|
keyword: ParserElement,
|
176
183
|
data: ParserElement,
|
177
184
|
*,
|
185
|
+
directive: ParserElement | None = None,
|
178
186
|
located: bool = False,
|
179
187
|
) -> ParserElement:
|
180
188
|
keyword_entry = keyword + (
|
181
|
-
_dict_of(keyword, data, located=located)
|
189
|
+
_dict_of(keyword, data, directive=directive, located=located)
|
190
|
+
| (data + Literal(";").suppress())
|
182
191
|
)
|
183
192
|
|
193
|
+
if directive is not None:
|
194
|
+
keyword_entry |= directive + data + LineEnd().suppress() # type: ignore [no-untyped-call]
|
195
|
+
|
184
196
|
if located:
|
185
197
|
keyword_entry = Located(keyword_entry)
|
186
198
|
else:
|
@@ -240,7 +252,8 @@ _FIELD = (Keyword("uniform", _IDENTBODYCHARS).suppress() + _TENSOR) | (
|
|
240
252
|
| _tensor_list(TensorKind.TENSOR, ignore=_COMMENT)
|
241
253
|
)
|
242
254
|
)
|
243
|
-
|
255
|
+
_DIRECTIVE = Word("#", _IDENTBODYCHARS)
|
256
|
+
_TOKEN = dbl_quoted_string | _IDENTIFIER | _DIRECTIVE
|
244
257
|
_DATA = Forward()
|
245
258
|
_KEYWORD_ENTRY = _keyword_entry_of(_TOKEN | _list_of(_IDENTIFIER), _DATA)
|
246
259
|
_DICT = _dict_of(_TOKEN, _DATA)
|
@@ -259,18 +272,21 @@ _DATA <<= (
|
|
259
272
|
|
260
273
|
|
261
274
|
def parse_data(s: str) -> Data:
|
275
|
+
if not s.strip():
|
276
|
+
return ""
|
262
277
|
return cast(Data, _DATA.parse_string(s, parse_all=True)[0])
|
263
278
|
|
264
279
|
|
265
280
|
_LOCATED_DICTIONARY = Group(
|
266
|
-
_keyword_entry_of(
|
281
|
+
_keyword_entry_of(
|
282
|
+
_TOKEN, Opt(_DATA, default=""), directive=_DIRECTIVE, located=True
|
283
|
+
)
|
267
284
|
)[...]
|
268
285
|
_LOCATED_DATA = Group(Located(_DATA.copy().add_parse_action(lambda tks: ["", tks[0]])))
|
269
286
|
|
270
287
|
_FILE = (
|
271
288
|
Dict(_LOCATED_DICTIONARY + Opt(_LOCATED_DATA) + _LOCATED_DICTIONARY)
|
272
289
|
.ignore(_COMMENT)
|
273
|
-
.ignore(Literal("#include") + ... + LineEnd()) # type: ignore [no-untyped-call]
|
274
290
|
.parse_with_tabs()
|
275
291
|
)
|
276
292
|
|
foamlib/_files/_serialization.py
CHANGED
@@ -111,7 +111,10 @@ def dumps(
|
|
111
111
|
|
112
112
|
if isinstance(data, tuple) and kind == Kind.SINGLE_ENTRY and len(data) == 2:
|
113
113
|
k, v = data
|
114
|
-
ret = dumps(k)
|
114
|
+
ret = dumps(k)
|
115
|
+
val = dumps(v)
|
116
|
+
if val:
|
117
|
+
ret += b" " + val
|
115
118
|
if not isinstance(v, Mapping):
|
116
119
|
ret += b";"
|
117
120
|
return ret
|
@@ -1,4 +1,4 @@
|
|
1
|
-
foamlib/__init__.py,sha256=
|
1
|
+
foamlib/__init__.py,sha256=xYSLuRubvL_srTiNR5-bYmOHuvUEv_y3cMIOAXMcCt8,452
|
2
2
|
foamlib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
foamlib/_cases/__init__.py,sha256=_A1TTHuQfS9FH2_33lSEyLtOJZGFHZBco1tWJCVOHks,358
|
4
4
|
foamlib/_cases/_async.py,sha256=onECxRLQCF7Kd-GeuLqH_Xv3gbMMhKOSbFaUG5Ttgmk,7822
|
@@ -9,12 +9,12 @@ foamlib/_cases/_subprocess.py,sha256=6BlBRxknj2-BFcGkx7oVcuL63_utSaY1Axmsc1qV9j8
|
|
9
9
|
foamlib/_cases/_sync.py,sha256=2BJXB7Nzldb4OgPukqupgYqdceUGkI2mYhhtGPWEBrc,5901
|
10
10
|
foamlib/_cases/_util.py,sha256=tK4SM5WT3eEgGsFLnidIySbom1qowBAua9z13gipKJk,1518
|
11
11
|
foamlib/_files/__init__.py,sha256=q1vkjXnjnSZvo45jPAICpWeF2LZv5V6xfzAR6S8fS5A,96
|
12
|
-
foamlib/_files/_files.py,sha256=
|
12
|
+
foamlib/_files/_files.py,sha256=V740S36NVunULv8pnyEsJ7lIWbSjk_-LwbP7BBqFsO0,15404
|
13
13
|
foamlib/_files/_io.py,sha256=BGbbm6HKxL2ka0YMCmHqZQZ1R4PPQlkvWWb4FHMAS8k,2217
|
14
|
-
foamlib/_files/_parsing.py,sha256=
|
15
|
-
foamlib/_files/_serialization.py,sha256=
|
14
|
+
foamlib/_files/_parsing.py,sha256=_YCi1-ltrlQWyh5RvGDZgi47MzJ7FzFcsK6L_rAWksA,13489
|
15
|
+
foamlib/_files/_serialization.py,sha256=PvMzNyTja6OKT_GUfExTulx9nMLBjfu0-9yThCKbvxs,5227
|
16
16
|
foamlib/_files/_types.py,sha256=m-fFjJnS4sFSavDsijlXpAfEhnbh10RBumSHAT0GOgQ,3408
|
17
|
-
foamlib-0.8.
|
18
|
-
foamlib-0.8.
|
19
|
-
foamlib-0.8.
|
20
|
-
foamlib-0.8.
|
17
|
+
foamlib-0.8.4.dist-info/METADATA,sha256=YsjrAXLrG3ELANlB9PRyyHiciEJAU7rL0IP4AOsMV8A,7968
|
18
|
+
foamlib-0.8.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
19
|
+
foamlib-0.8.4.dist-info/licenses/LICENSE.txt,sha256=5Dte9TUnLZzPRs4NQzl-Jc2-Ljd-t_v0ZR5Ng5r0UsY,35131
|
20
|
+
foamlib-0.8.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|