foamlib 0.4.0__tar.gz → 0.4.2__tar.gz
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-0.4.0 → foamlib-0.4.2}/PKG-INFO +1 -1
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib/__init__.py +1 -1
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib/_files/_base.py +1 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib/_files/_files.py +3 -3
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib/_files/_parsing.py +14 -7
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib.egg-info/PKG-INFO +1 -1
- {foamlib-0.4.0 → foamlib-0.4.2}/LICENSE.txt +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/README.md +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib/_cases/__init__.py +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib/_cases/_async.py +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib/_cases/_base.py +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib/_cases/_sync.py +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib/_cases/_util.py +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib/_files/__init__.py +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib/_files/_io.py +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib/_files/_serialization.py +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib/_util.py +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib/py.typed +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib.egg-info/SOURCES.txt +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib.egg-info/dependency_links.txt +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib.egg-info/requires.txt +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/foamlib.egg-info/top_level.txt +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/pyproject.toml +0 -0
- {foamlib-0.4.0 → foamlib-0.4.2}/setup.cfg +0 -0
@@ -97,9 +97,9 @@ class FoamFile(
|
|
97
97
|
assert isinstance(ret, dict)
|
98
98
|
v = ret[k]
|
99
99
|
assert isinstance(v, dict)
|
100
|
-
ret = v
|
100
|
+
ret = cast(FoamFileBase._File, v)
|
101
101
|
|
102
|
-
return ret
|
102
|
+
return cast(FoamFileBase._Dict, ret)
|
103
103
|
|
104
104
|
def create(self, *, exist_ok: bool = False, parents: bool = False) -> Self:
|
105
105
|
"""
|
@@ -356,7 +356,7 @@ class FoamFile(
|
|
356
356
|
def __fspath__(self) -> str:
|
357
357
|
return str(self.path)
|
358
358
|
|
359
|
-
def as_dict(self) -> FoamFileBase.
|
359
|
+
def as_dict(self) -> FoamFileBase._File:
|
360
360
|
"""Return a nested dict representation of the file."""
|
361
361
|
_, parsed = self._read()
|
362
362
|
d = parsed.as_dict()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import array
|
2
2
|
import sys
|
3
|
-
from typing import Tuple, Union
|
3
|
+
from typing import Tuple, Union, cast
|
4
4
|
|
5
5
|
if sys.version_info >= (3, 9):
|
6
6
|
from collections.abc import Iterator, Mapping, MutableMapping, Sequence
|
@@ -14,6 +14,7 @@ else:
|
|
14
14
|
|
15
15
|
from pyparsing import (
|
16
16
|
CharsNotIn,
|
17
|
+
Combine,
|
17
18
|
Dict,
|
18
19
|
Forward,
|
19
20
|
Group,
|
@@ -134,7 +135,10 @@ _DIMENSIONS = (
|
|
134
135
|
Literal("[").suppress() + common.number * 7 + Literal("]").suppress()
|
135
136
|
).set_parse_action(lambda tks: FoamFileBase.DimensionSet(*tks))
|
136
137
|
_TENSOR = _list_of(common.number) | common.number
|
137
|
-
_IDENTIFIER =
|
138
|
+
_IDENTIFIER = Combine(
|
139
|
+
Word(identchars + "$", printables, exclude_chars="{(;)}")
|
140
|
+
+ Opt(Literal("(") + Word(printables, exclude_chars="{(;)}") + Literal(")"))
|
141
|
+
)
|
138
142
|
_DIMENSIONED = (Opt(_IDENTIFIER) + _DIMENSIONS + _TENSOR).set_parse_action(
|
139
143
|
lambda tks: FoamFileBase.Dimensioned(*reversed(tks.as_list()))
|
140
144
|
)
|
@@ -262,17 +266,20 @@ class Parsed(Mapping[Tuple[str, ...], Union[FoamFileBase.Data, EllipsisType]]):
|
|
262
266
|
|
263
267
|
return start, end
|
264
268
|
|
265
|
-
def as_dict(self) -> FoamFileBase.
|
266
|
-
ret: FoamFileBase.
|
269
|
+
def as_dict(self) -> FoamFileBase._File:
|
270
|
+
ret: FoamFileBase._File = {}
|
267
271
|
for keywords, (_, data, _) in self._parsed.items():
|
268
272
|
r = ret
|
269
273
|
for k in keywords[:-1]:
|
270
|
-
assert isinstance(r, dict)
|
271
274
|
v = r[k]
|
272
275
|
assert isinstance(v, dict)
|
273
|
-
r = v
|
276
|
+
r = cast(FoamFileBase._File, v)
|
274
277
|
|
275
278
|
assert isinstance(r, dict)
|
276
|
-
|
279
|
+
if keywords:
|
280
|
+
r[keywords[-1]] = {} if data is ... else data
|
281
|
+
else:
|
282
|
+
assert data is not ...
|
283
|
+
r[None] = data
|
277
284
|
|
278
285
|
return ret
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|