foamlib 0.3.10__tar.gz → 0.3.11__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foamlib
3
- Version: 0.3.10
3
+ Version: 0.3.11
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
@@ -29,7 +29,7 @@ Requires-Dist: aioshutil<2,>=1
29
29
  Requires-Dist: pyparsing<4,>=3
30
30
  Requires-Dist: typing-extensions<5,>=4; python_version < "3.11"
31
31
  Provides-Extra: numpy
32
- Requires-Dist: numpy<2,>=1; extra == "numpy"
32
+ Requires-Dist: numpy<3,>=1; extra == "numpy"
33
33
  Provides-Extra: lint
34
34
  Requires-Dist: ruff; extra == "lint"
35
35
  Provides-Extra: test
@@ -1,6 +1,6 @@
1
1
  """A Python interface for interacting with OpenFOAM."""
2
2
 
3
- __version__ = "0.3.10"
3
+ __version__ = "0.3.11"
4
4
 
5
5
  from ._cases import AsyncFoamCase, FoamCase, FoamCaseBase
6
6
  from ._files import FoamDict, FoamFieldFile, FoamFile
@@ -498,7 +498,7 @@ class AsyncFoamCase(FoamCaseBase):
498
498
  else:
499
499
  for p in self._clean_paths():
500
500
  if p.is_dir():
501
- await aioshutil.rmtree(p)
501
+ await aioshutil.rmtree(p) # type: ignore [call-arg]
502
502
  else:
503
503
  p.unlink()
504
504
 
@@ -599,7 +599,7 @@ class AsyncFoamCase(FoamCaseBase):
599
599
 
600
600
  async def restore_0_dir(self) -> None:
601
601
  """Restore the 0 directory from the 0.orig directory."""
602
- await aioshutil.rmtree(self.path / "0", ignore_errors=True)
602
+ await aioshutil.rmtree(self.path / "0", ignore_errors=True) # type: ignore [call-arg]
603
603
  await aioshutil.copytree(self.path / "0.orig", self.path / "0")
604
604
 
605
605
  async def copy(self, dest: Union[Path, str]) -> "AsyncFoamCase":
@@ -54,11 +54,10 @@ def _list_of(entry: ParserElement) -> ParserElement:
54
54
  )
55
55
 
56
56
 
57
- def _dictionary_of(
57
+ def _keyword_entry_of(
58
58
  keyword: ParserElement,
59
59
  data_entries: ParserElement,
60
60
  *,
61
- len: Union[int, EllipsisType] = ...,
62
61
  located: bool = False,
63
62
  ) -> ParserElement:
64
63
  subdict = Forward()
@@ -73,7 +72,7 @@ def _dictionary_of(
73
72
 
74
73
  subdict <<= Dict(Group(keyword_entry)[...], asdict=not located)
75
74
 
76
- return Dict(Group(keyword_entry)[len], asdict=not located)
75
+ return keyword_entry
77
76
 
78
77
 
79
78
  _binary_contents = Forward()
@@ -146,7 +145,7 @@ _FIELD = (
146
145
  )
147
146
  _TOKEN = QuotedString('"', unquote_results=False) | _IDENTIFIER
148
147
  _DATA = Forward()
149
- _KEYWORD_ENTRY = _dictionary_of(_TOKEN, _DATA, len=1)
148
+ _KEYWORD_ENTRY = Dict(Group(_keyword_entry_of(_TOKEN, _DATA)), asdict=True)
150
149
  _DATA_ENTRY = Forward()
151
150
  _LIST_ENTRY = _KEYWORD_ENTRY | _DATA_ENTRY
152
151
  _LIST = _list_of(_LIST_ENTRY)
@@ -159,7 +158,19 @@ _DATA <<= _DATA_ENTRY[1, ...].set_parse_action(
159
158
  )
160
159
 
161
160
  _FILE = (
162
- _dictionary_of(_TOKEN, Opt(_DATA, default=""), located=True)
161
+ Dict(
162
+ Group(_keyword_entry_of(_TOKEN, Opt(_DATA, default=""), located=True))[...]
163
+ + Opt(
164
+ Group(
165
+ Located(
166
+ _DATA_ENTRY[1, ...].set_parse_action(
167
+ lambda tks: ["", tuple(tks) if len(tks) > 1 else tks[0]]
168
+ )
169
+ )
170
+ )
171
+ )
172
+ + Group(_keyword_entry_of(_TOKEN, Opt(_DATA, default=""), located=True))[...]
173
+ )
163
174
  .ignore(c_style_comment)
164
175
  .ignore(cpp_style_comment)
165
176
  .ignore(Literal("#include") + ... + LineEnd()) # type: ignore [no-untyped-call]
@@ -203,8 +214,11 @@ class Parsed(Mapping[Tuple[str, ...], Union[FoamDict.Data, EllipsisType]]):
203
214
  return ret
204
215
 
205
216
  def __getitem__(
206
- self, keywords: Tuple[str, ...]
217
+ self, keywords: Union[str, Tuple[str, ...]]
207
218
  ) -> Union[FoamDict.Data, EllipsisType]:
219
+ if isinstance(keywords, str):
220
+ keywords = (keywords,)
221
+
208
222
  _, data, _ = self._parsed[keywords]
209
223
  return data
210
224
 
@@ -39,12 +39,14 @@ def dumpb(
39
39
  entries = []
40
40
  for k, v in data.items():
41
41
  b = dumpb(v, kind=kind)
42
- if isinstance(v, Mapping):
42
+ if not k:
43
+ entries.append(b)
44
+ elif isinstance(v, Mapping):
43
45
  entries.append(dumpb(k) + b"\n" + b"{\n" + b + b"\n}")
44
- elif b:
45
- entries.append(dumpb(k) + b" " + b + b";")
46
- else:
46
+ elif not b:
47
47
  entries.append(dumpb(k) + b";")
48
+ else:
49
+ entries.append(dumpb(k) + b" " + b + b";")
48
50
 
49
51
  return b"\n".join(entries)
50
52
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foamlib
3
- Version: 0.3.10
3
+ Version: 0.3.11
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
@@ -29,7 +29,7 @@ Requires-Dist: aioshutil<2,>=1
29
29
  Requires-Dist: pyparsing<4,>=3
30
30
  Requires-Dist: typing-extensions<5,>=4; python_version < "3.11"
31
31
  Provides-Extra: numpy
32
- Requires-Dist: numpy<2,>=1; extra == "numpy"
32
+ Requires-Dist: numpy<3,>=1; extra == "numpy"
33
33
  Provides-Extra: lint
34
34
  Requires-Dist: ruff; extra == "lint"
35
35
  Provides-Extra: test
@@ -20,7 +20,7 @@ sphinx_rtd_theme
20
20
  ruff
21
21
 
22
22
  [numpy]
23
- numpy<2,>=1
23
+ numpy<3,>=1
24
24
 
25
25
  [test]
26
26
  foamlib[numpy]
@@ -36,7 +36,7 @@ dependencies = [
36
36
  dynamic = ["version"]
37
37
 
38
38
  [project.optional-dependencies]
39
- numpy = ["numpy>=1,<2"]
39
+ numpy = ["numpy>=1,<3"]
40
40
  lint = ["ruff"]
41
41
  test = [
42
42
  "foamlib[numpy]",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes