foamlib 0.4.1__py3-none-any.whl → 0.4.2__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 CHANGED
@@ -1,6 +1,6 @@
1
1
  """A Python interface for interacting with OpenFOAM."""
2
2
 
3
- __version__ = "0.4.1"
3
+ __version__ = "0.4.2"
4
4
 
5
5
  from ._cases import (
6
6
  AsyncFoamCase,
foamlib/_files/_base.py CHANGED
@@ -51,6 +51,7 @@ class FoamFileBase:
51
51
  """
52
52
 
53
53
  _Dict = Dict[str, Union["Data", "_Dict"]]
54
+ _File = Dict[Optional[str], Union["Data", "_Dict"]]
54
55
 
55
56
  _SetData = Union[
56
57
  str,
foamlib/_files/_files.py CHANGED
@@ -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._Dict:
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
@@ -266,17 +266,20 @@ class Parsed(Mapping[Tuple[str, ...], Union[FoamFileBase.Data, EllipsisType]]):
266
266
 
267
267
  return start, end
268
268
 
269
- def as_dict(self) -> FoamFileBase._Dict:
270
- ret: FoamFileBase._Dict = {}
269
+ def as_dict(self) -> FoamFileBase._File:
270
+ ret: FoamFileBase._File = {}
271
271
  for keywords, (_, data, _) in self._parsed.items():
272
272
  r = ret
273
273
  for k in keywords[:-1]:
274
- assert isinstance(r, dict)
275
274
  v = r[k]
276
275
  assert isinstance(v, dict)
277
- r = v
276
+ r = cast(FoamFileBase._File, v)
278
277
 
279
278
  assert isinstance(r, dict)
280
- r[keywords[-1]] = {} if data is ... else data
279
+ if keywords:
280
+ r[keywords[-1]] = {} if data is ... else data
281
+ else:
282
+ assert data is not ...
283
+ r[None] = data
281
284
 
282
285
  return ret
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foamlib
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: A Python interface for interacting with OpenFOAM
5
5
  Author-email: "Gabriel S. Gerlero" <ggerlero@cimec.unl.edu.ar>
6
6
  Project-URL: Homepage, https://github.com/gerlero/foamlib
@@ -1,4 +1,4 @@
1
- foamlib/__init__.py,sha256=Lm0oAsj1KsJFBiIAaNSSE231t6g92HybfoXNwBoFUBQ,446
1
+ foamlib/__init__.py,sha256=jybejTK1oM5i5b-9ymupfu5dfoxg_2daivPQ94THPII,446
2
2
  foamlib/_util.py,sha256=UMzXmTFgvbp46w6k3oEZJoYC98pFgEK6LN5uLOwrlCg,397
3
3
  foamlib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  foamlib/_cases/__init__.py,sha256=xnQpR64EvFtCh07qnSz7kjQ1IhJXjRDwaZWwQGZhGv4,280
@@ -7,13 +7,13 @@ foamlib/_cases/_base.py,sha256=JrYJplmXV84qwgerdVSCHz2rCI-KWB4IvTBPMkYpecw,12657
7
7
  foamlib/_cases/_sync.py,sha256=CloQgd-93jxfSXIt7J5NxcAu3N_iF3eXMKO-NfNOgi4,4522
8
8
  foamlib/_cases/_util.py,sha256=v6sHxHCEgagsVuup0S1xJW-x9py5xj3bUye8PiFfb3o,925
9
9
  foamlib/_files/__init__.py,sha256=-UqB9YTH6mrJfXCX00kPTAAY20XG64u1MGPw_1ewLVs,148
10
- foamlib/_files/_base.py,sha256=sy1RP08pdv079KD_UBy7xUYEnXyNK35AiKVcCalYmPU,1873
11
- foamlib/_files/_files.py,sha256=2bvl2YZ0bqHpbQV35vzYO7wWNOo_2WDF9LbyLagIvBE,16193
10
+ foamlib/_files/_base.py,sha256=zaFDjLE6jB7WtGWk8hfKusjLtlGu6CZV16AHJpRUibs,1929
11
+ foamlib/_files/_files.py,sha256=-3mDRIsaQaxHF74q0Zfzlrhfieb7w_EPOFScSx8wRPE,16245
12
12
  foamlib/_files/_io.py,sha256=f_tYI7AqaFsQ8mtK__fEoIUqpYb3YmrI8X5D8updmNM,2084
13
- foamlib/_files/_parsing.py,sha256=eqY3grOnBdeXQLmM418VFKtCrpSd7FnLXuQ8h4mzD2M,8189
13
+ foamlib/_files/_parsing.py,sha256=MDz5AzoI6wJw_uIbVPlD1Naxm8AzA6iOrKkhCbaJLxg,8295
14
14
  foamlib/_files/_serialization.py,sha256=3yb9fgjCpDoRfZoLsbZaIFrkZ3vGBzleFRw6IbaZuuY,3408
15
- foamlib-0.4.1.dist-info/LICENSE.txt,sha256=5Dte9TUnLZzPRs4NQzl-Jc2-Ljd-t_v0ZR5Ng5r0UsY,35131
16
- foamlib-0.4.1.dist-info/METADATA,sha256=u17GpI0WPbXEBVwUo0lJI6J8sApdaTYzwX_DGbPr0rw,5457
17
- foamlib-0.4.1.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
18
- foamlib-0.4.1.dist-info/top_level.txt,sha256=ZdVYtetXGwPwyfL-WhlhbTFQGAwKX5P_gXxtH9JYFPI,8
19
- foamlib-0.4.1.dist-info/RECORD,,
15
+ foamlib-0.4.2.dist-info/LICENSE.txt,sha256=5Dte9TUnLZzPRs4NQzl-Jc2-Ljd-t_v0ZR5Ng5r0UsY,35131
16
+ foamlib-0.4.2.dist-info/METADATA,sha256=pF9f6WuWV5YAkN7X4yGujILaBXzATeysOuftxBO41cc,5457
17
+ foamlib-0.4.2.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
18
+ foamlib-0.4.2.dist-info/top_level.txt,sha256=ZdVYtetXGwPwyfL-WhlhbTFQGAwKX5P_gXxtH9JYFPI,8
19
+ foamlib-0.4.2.dist-info/RECORD,,