foamlib 0.8.5__py3-none-any.whl → 0.8.6__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 +5 -5
- foamlib/_files/_parsing.py +27 -7
- {foamlib-0.8.5.dist-info → foamlib-0.8.6.dist-info}/METADATA +1 -1
- {foamlib-0.8.5.dist-info → foamlib-0.8.6.dist-info}/RECORD +7 -7
- {foamlib-0.8.5.dist-info → foamlib-0.8.6.dist-info}/WHEEL +0 -0
- {foamlib-0.8.5.dist-info → foamlib-0.8.6.dist-info}/licenses/LICENSE.txt +0 -0
foamlib/__init__.py
CHANGED
foamlib/_files/_files.py
CHANGED
@@ -100,9 +100,9 @@ class FoamFile(
|
|
100
100
|
assert isinstance(ret, dict)
|
101
101
|
v = ret[k]
|
102
102
|
assert isinstance(v, dict)
|
103
|
-
ret = cast(File, v)
|
103
|
+
ret = cast("File", v)
|
104
104
|
|
105
|
-
return cast(Dict_, ret)
|
105
|
+
return cast("Dict_", ret)
|
106
106
|
|
107
107
|
@property
|
108
108
|
def version(self) -> float:
|
@@ -127,7 +127,7 @@ class FoamFile(
|
|
127
127
|
if ret not in ("ascii", "binary"):
|
128
128
|
msg = "format is not 'ascii' or 'binary'"
|
129
129
|
raise ValueError(msg)
|
130
|
-
return cast(Literal[
|
130
|
+
return cast("Literal['ascii', 'binary']", ret)
|
131
131
|
|
132
132
|
@format.setter
|
133
133
|
def format(self, value: Literal["ascii", "binary"]) -> None:
|
@@ -412,7 +412,7 @@ class FoamFieldFile(FoamFile):
|
|
412
412
|
) -> Field:
|
413
413
|
"""Alias of `self["value"]`."""
|
414
414
|
return cast(
|
415
|
-
Field,
|
415
|
+
"Field",
|
416
416
|
self["value"],
|
417
417
|
)
|
418
418
|
|
@@ -461,7 +461,7 @@ class FoamFieldFile(FoamFile):
|
|
461
461
|
self,
|
462
462
|
) -> Field:
|
463
463
|
"""Alias of `self["internalField"]`."""
|
464
|
-
return cast(Field, self["internalField"])
|
464
|
+
return cast("Field", self["internalField"])
|
465
465
|
|
466
466
|
@internal_field.setter
|
467
467
|
def internal_field(
|
foamlib/_files/_parsing.py
CHANGED
@@ -16,6 +16,7 @@ else:
|
|
16
16
|
|
17
17
|
import numpy as np
|
18
18
|
from pyparsing import (
|
19
|
+
CaselessKeyword,
|
19
20
|
Combine,
|
20
21
|
Dict,
|
21
22
|
Forward,
|
@@ -157,6 +158,7 @@ def _dict_of(
|
|
157
158
|
data: ParserElement,
|
158
159
|
*,
|
159
160
|
directive: ParserElement | None = None,
|
161
|
+
data_entry: ParserElement | None = None,
|
160
162
|
located: bool = False,
|
161
163
|
) -> ParserElement:
|
162
164
|
dict_ = Forward()
|
@@ -164,7 +166,8 @@ def _dict_of(
|
|
164
166
|
keyword_entry = keyword + (dict_ | (data + Literal(";").suppress()))
|
165
167
|
|
166
168
|
if directive is not None:
|
167
|
-
|
169
|
+
assert data_entry is not None
|
170
|
+
keyword_entry |= directive + data_entry + LineEnd().suppress() # type: ignore [no-untyped-call]
|
168
171
|
|
169
172
|
if located:
|
170
173
|
keyword_entry = Located(keyword_entry)
|
@@ -183,15 +186,19 @@ def _keyword_entry_of(
|
|
183
186
|
data: ParserElement,
|
184
187
|
*,
|
185
188
|
directive: ParserElement | None = None,
|
189
|
+
data_entry: ParserElement | None = None,
|
186
190
|
located: bool = False,
|
187
191
|
) -> ParserElement:
|
188
192
|
keyword_entry = keyword + (
|
189
|
-
_dict_of(
|
193
|
+
_dict_of(
|
194
|
+
keyword, data, directive=directive, data_entry=data_entry, located=located
|
195
|
+
)
|
190
196
|
| (data + Literal(";").suppress())
|
191
197
|
)
|
192
198
|
|
193
199
|
if directive is not None:
|
194
|
-
|
200
|
+
assert data_entry is not None
|
201
|
+
keyword_entry |= directive + data_entry + LineEnd().suppress() # type: ignore [no-untyped-call]
|
195
202
|
|
196
203
|
if located:
|
197
204
|
keyword_entry = Located(keyword_entry)
|
@@ -261,7 +268,16 @@ _DICT = _dict_of(_TOKEN, _DATA)
|
|
261
268
|
_DATA_ENTRY = Forward()
|
262
269
|
_LIST_ENTRY = _DICT | _KEYWORD_ENTRY | _DATA_ENTRY
|
263
270
|
_LIST = _list_of(_LIST_ENTRY)
|
264
|
-
_NUMBER =
|
271
|
+
_NUMBER = (
|
272
|
+
common.number
|
273
|
+
| CaselessKeyword("nan").set_parse_action(lambda: np.nan)
|
274
|
+
| (CaselessKeyword("inf") | CaselessKeyword("infinity")).set_parse_action(
|
275
|
+
lambda: np.inf
|
276
|
+
)
|
277
|
+
| (CaselessKeyword("-inf") | CaselessKeyword("-infinity")).set_parse_action(
|
278
|
+
lambda: -np.inf
|
279
|
+
)
|
280
|
+
)
|
265
281
|
_DATA_ENTRY <<= _FIELD | _LIST | _DIMENSIONED | _DIMENSIONS | _NUMBER | _SWITCH | _TOKEN
|
266
282
|
|
267
283
|
_DATA <<= (
|
@@ -275,12 +291,16 @@ _DATA <<= (
|
|
275
291
|
def parse_data(s: str) -> Data:
|
276
292
|
if not s.strip():
|
277
293
|
return ""
|
278
|
-
return cast(Data, _DATA.parse_string(s, parse_all=True)[0])
|
294
|
+
return cast("Data", _DATA.parse_string(s, parse_all=True)[0])
|
279
295
|
|
280
296
|
|
281
297
|
_LOCATED_DICTIONARY = Group(
|
282
298
|
_keyword_entry_of(
|
283
|
-
_TOKEN,
|
299
|
+
_TOKEN,
|
300
|
+
Opt(_DATA, default=""),
|
301
|
+
directive=_DIRECTIVE,
|
302
|
+
data_entry=_DATA_ENTRY,
|
303
|
+
located=True,
|
284
304
|
)
|
285
305
|
)[...]
|
286
306
|
_LOCATED_DATA = Group(Located(_DATA.copy().add_parse_action(lambda tks: ["", tks[0]])))
|
@@ -421,7 +441,7 @@ class Parsed(Mapping[Tuple[str, ...], Union[Data, EllipsisType]]):
|
|
421
441
|
for k in keywords[:-1]:
|
422
442
|
v = r[k]
|
423
443
|
assert isinstance(v, dict)
|
424
|
-
r = cast(File, v)
|
444
|
+
r = cast("File", v)
|
425
445
|
|
426
446
|
assert isinstance(r, dict)
|
427
447
|
if keywords:
|
@@ -1,4 +1,4 @@
|
|
1
|
-
foamlib/__init__.py,sha256=
|
1
|
+
foamlib/__init__.py,sha256=fTmSxCwa3jslIzrR21plDa2dAdw0v7tFSX1pBqOi4_A,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=YAKw3RHEw8eCja4JAxobp6BC-2Kyy7AvG1O7yOqyMic,15414
|
13
13
|
foamlib/_files/_io.py,sha256=BGbbm6HKxL2ka0YMCmHqZQZ1R4PPQlkvWWb4FHMAS8k,2217
|
14
|
-
foamlib/_files/_parsing.py,sha256=
|
14
|
+
foamlib/_files/_parsing.py,sha256=9MOFG6Akk-xYIHs84aY8rHL2cGeWQLx7wQE4x7mfJek,14115
|
15
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.6.dist-info/METADATA,sha256=t4nSfDbDQtd2gelYCgSdFv2x6YWg8SFEQLb7Ol7ePAU,7968
|
18
|
+
foamlib-0.8.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
19
|
+
foamlib-0.8.6.dist-info/licenses/LICENSE.txt,sha256=5Dte9TUnLZzPRs4NQzl-Jc2-Ljd-t_v0ZR5Ng5r0UsY,35131
|
20
|
+
foamlib-0.8.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|