foamlib 0.4.1__tar.gz → 0.4.3__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.1 → foamlib-0.4.3}/PKG-INFO +1 -1
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib/__init__.py +1 -1
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib/_files/_base.py +1 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib/_files/_files.py +3 -3
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib/_files/_parsing.py +13 -9
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib.egg-info/PKG-INFO +1 -1
- {foamlib-0.4.1 → foamlib-0.4.3}/LICENSE.txt +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/README.md +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib/_cases/__init__.py +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib/_cases/_async.py +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib/_cases/_base.py +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib/_cases/_sync.py +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib/_cases/_util.py +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib/_files/__init__.py +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib/_files/_io.py +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib/_files/_serialization.py +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib/_util.py +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib/py.typed +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib.egg-info/SOURCES.txt +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib.egg-info/dependency_links.txt +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib.egg-info/requires.txt +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/foamlib.egg-info/top_level.txt +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/pyproject.toml +0 -0
- {foamlib-0.4.1 → foamlib-0.4.3}/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
|
@@ -149,7 +149,8 @@ _FIELD = (
|
|
149
149
|
)
|
150
150
|
_TOKEN = QuotedString('"', unquote_results=False) | _IDENTIFIER
|
151
151
|
_DATA = Forward()
|
152
|
-
|
152
|
+
_KEYWORD = Combine(Literal("(") + Word(identchars + " ") + Literal(")")) | _TOKEN
|
153
|
+
_KEYWORD_ENTRY = Dict(Group(_keyword_entry_of(_KEYWORD, _DATA)), asdict=True)
|
153
154
|
_DATA_ENTRY = Forward()
|
154
155
|
_LIST_ENTRY = _KEYWORD_ENTRY | _DATA_ENTRY
|
155
156
|
_LIST = _list_of(_LIST_ENTRY)
|
@@ -163,7 +164,7 @@ _DATA <<= _DATA_ENTRY[1, ...].set_parse_action(
|
|
163
164
|
|
164
165
|
_FILE = (
|
165
166
|
Dict(
|
166
|
-
Group(_keyword_entry_of(
|
167
|
+
Group(_keyword_entry_of(_KEYWORD, Opt(_DATA, default=""), located=True))[...]
|
167
168
|
+ Opt(
|
168
169
|
Group(
|
169
170
|
Located(
|
@@ -173,7 +174,7 @@ _FILE = (
|
|
173
174
|
)
|
174
175
|
)
|
175
176
|
)
|
176
|
-
+ Group(_keyword_entry_of(
|
177
|
+
+ Group(_keyword_entry_of(_KEYWORD, Opt(_DATA, default=""), located=True))[...]
|
177
178
|
)
|
178
179
|
.ignore(c_style_comment)
|
179
180
|
.ignore(cpp_style_comment)
|
@@ -266,17 +267,20 @@ class Parsed(Mapping[Tuple[str, ...], Union[FoamFileBase.Data, EllipsisType]]):
|
|
266
267
|
|
267
268
|
return start, end
|
268
269
|
|
269
|
-
def as_dict(self) -> FoamFileBase.
|
270
|
-
ret: FoamFileBase.
|
270
|
+
def as_dict(self) -> FoamFileBase._File:
|
271
|
+
ret: FoamFileBase._File = {}
|
271
272
|
for keywords, (_, data, _) in self._parsed.items():
|
272
273
|
r = ret
|
273
274
|
for k in keywords[:-1]:
|
274
|
-
assert isinstance(r, dict)
|
275
275
|
v = r[k]
|
276
276
|
assert isinstance(v, dict)
|
277
|
-
r = v
|
277
|
+
r = cast(FoamFileBase._File, v)
|
278
278
|
|
279
279
|
assert isinstance(r, dict)
|
280
|
-
|
280
|
+
if keywords:
|
281
|
+
r[keywords[-1]] = {} if data is ... else data
|
282
|
+
else:
|
283
|
+
assert data is not ...
|
284
|
+
r[None] = data
|
281
285
|
|
282
286
|
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
|