foamlib 0.3.10__py3-none-any.whl → 0.3.12__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.
@@ -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.12
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
@@ -36,12 +36,12 @@ Requires-Dist: foamlib[typing] ; extra == 'dev'
36
36
  Requires-Dist: foamlib[docs] ; extra == 'dev'
37
37
  Provides-Extra: docs
38
38
  Requires-Dist: foamlib[numpy] ; extra == 'docs'
39
- Requires-Dist: sphinx <8,>=7 ; extra == 'docs'
39
+ Requires-Dist: sphinx <9,>=7 ; extra == 'docs'
40
40
  Requires-Dist: sphinx-rtd-theme ; extra == 'docs'
41
41
  Provides-Extra: lint
42
42
  Requires-Dist: ruff ; extra == 'lint'
43
43
  Provides-Extra: numpy
44
- Requires-Dist: numpy <2,>=1 ; extra == 'numpy'
44
+ Requires-Dist: numpy <3,>=1 ; extra == 'numpy'
45
45
  Provides-Extra: test
46
46
  Requires-Dist: foamlib[numpy] ; extra == 'test'
47
47
  Requires-Dist: pytest <9,>=7 ; extra == 'test'
@@ -0,0 +1,18 @@
1
+ foamlib/__init__.py,sha256=vhhhADNxwAVfkJ0_bm28V9p2b-Mo5Mgua44ZIo2hl88,432
2
+ foamlib/_util.py,sha256=vL03aAzpWdZyYIhe2WTxHiz9b4lnttVnRuzqUmZvXXk,3047
3
+ foamlib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ foamlib/_cases/__init__.py,sha256=4bHQRLtYh0IBOuuCSwUbipZEPqIF0sypU2xtoc6YW3c,166
5
+ foamlib/_cases/_async.py,sha256=Rfbq3rerYZdt4lX7YxnStj4LSqwH2j0rAmbPkSDHhP0,4995
6
+ foamlib/_cases/_base.py,sha256=jHgZAR1z7pZHPC0XTDTNXVfTJ8BKFv_ESYwUz2NPzWw,11416
7
+ foamlib/_cases/_sync.py,sha256=irMprDmcvjvdIj82griGhXvDU_L9UnyAbyJjS74Z3ug,3961
8
+ foamlib/_files/__init__.py,sha256=vDkPj8u8bX_I_m2YfeKvXBgwg8D1ufyFCfHGHKN3JPQ,140
9
+ foamlib/_files/_base.py,sha256=YA5a-i5HZuA3JslCD6r-DwZzpSA8r42dqSXef286Ako,2050
10
+ foamlib/_files/_files.py,sha256=4rZb3HMJADmJBGmRpChiujJNX1UIxhgHI5YPEmEOWvE,10784
11
+ foamlib/_files/_io.py,sha256=pGYMoLI5Dz2Y90EB1CtklZiffpDTGuQbbbkyqRe0JAo,2115
12
+ foamlib/_files/_parsing.py,sha256=SW1c1adDTg3e65hhZv5ZFDX8j654E88FDn13zl8gJ8c,7694
13
+ foamlib/_files/_serialization.py,sha256=LCeaLWtNvkcs0dfowL7nViiByxw7U_fvgueVjFliipU,3462
14
+ foamlib-0.3.12.dist-info/LICENSE.txt,sha256=5Dte9TUnLZzPRs4NQzl-Jc2-Ljd-t_v0ZR5Ng5r0UsY,35131
15
+ foamlib-0.3.12.dist-info/METADATA,sha256=5DDxoDLrNBs1fXupfQCTxSzb6Z1a3w34IvImEgiSrRc,5458
16
+ foamlib-0.3.12.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
17
+ foamlib-0.3.12.dist-info/top_level.txt,sha256=ZdVYtetXGwPwyfL-WhlhbTFQGAwKX5P_gXxtH9JYFPI,8
18
+ foamlib-0.3.12.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (72.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5