foamlib 0.3.8__tar.gz → 0.3.10__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.8
3
+ Version: 0.3.10
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
@@ -28,22 +28,28 @@ License-File: LICENSE.txt
28
28
  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
+ Provides-Extra: numpy
32
+ Requires-Dist: numpy<2,>=1; extra == "numpy"
31
33
  Provides-Extra: lint
32
34
  Requires-Dist: ruff; extra == "lint"
33
- Provides-Extra: typing
34
- Requires-Dist: mypy<2,>=1; extra == "typing"
35
- Requires-Dist: pytest<9,>=7; extra == "typing"
36
- Requires-Dist: pytest-asyncio<0.24,>=0.21; extra == "typing"
37
- Requires-Dist: numpy<2,>=1; extra == "typing"
38
35
  Provides-Extra: test
36
+ Requires-Dist: foamlib[numpy]; extra == "test"
39
37
  Requires-Dist: pytest<9,>=7; extra == "test"
40
38
  Requires-Dist: pytest-asyncio<0.24,>=0.21; extra == "test"
41
39
  Requires-Dist: pytest-cov; extra == "test"
42
- Requires-Dist: numpy<2,>=1; extra == "test"
40
+ Provides-Extra: typing
41
+ Requires-Dist: foamlib[test]; extra == "typing"
42
+ Requires-Dist: mypy<2,>=1; extra == "typing"
43
43
  Provides-Extra: docs
44
+ Requires-Dist: foamlib[numpy]; extra == "docs"
44
45
  Requires-Dist: sphinx<8,>=7; extra == "docs"
45
46
  Requires-Dist: sphinx_rtd_theme; extra == "docs"
46
- Requires-Dist: numpy<2,>=1; extra == "docs"
47
+ Provides-Extra: dev
48
+ Requires-Dist: foamlib[numpy]; extra == "dev"
49
+ Requires-Dist: foamlib[lint]; extra == "dev"
50
+ Requires-Dist: foamlib[test]; extra == "dev"
51
+ Requires-Dist: foamlib[typing]; extra == "dev"
52
+ Requires-Dist: foamlib[docs]; extra == "dev"
47
53
 
48
54
  [<img alt="foamlib" src="https://github.com/gerlero/foamlib/raw/main/logo.png" height="50">](https://github.com/gerlero/foamlib)
49
55
 
@@ -1,6 +1,6 @@
1
1
  """A Python interface for interacting with OpenFOAM."""
2
2
 
3
- __version__ = "0.3.8"
3
+ __version__ = "0.3.10"
4
4
 
5
5
  from ._cases import AsyncFoamCase, FoamCase, FoamCaseBase
6
6
  from ._files import FoamDict, FoamFieldFile, FoamFile
@@ -56,23 +56,29 @@ class FoamCaseBase(Sequence["FoamCaseBase.TimeDirectory"]):
56
56
  return self.path.name
57
57
 
58
58
  def __getitem__(self, key: str) -> FoamFieldFile:
59
- try:
59
+ if (self.path / key).is_file():
60
60
  return FoamFieldFile(self.path / key)
61
- except FileNotFoundError as e:
62
- raise KeyError(key) from e
61
+ elif (self.path / f"{key}.gz").is_file():
62
+ return FoamFieldFile(self.path / f"{key}.gz")
63
+ else:
64
+ raise KeyError(key)
63
65
 
64
66
  def __contains__(self, obj: object) -> bool:
65
67
  if isinstance(obj, FoamFieldFile):
66
68
  return obj.path.parent == self.path
67
69
  elif isinstance(obj, str):
68
- return (self.path / obj).is_file()
70
+ return (self.path / obj).is_file() or (
71
+ self.path / f"{obj}.gz"
72
+ ).is_file()
69
73
  else:
70
74
  return False
71
75
 
72
76
  def __iter__(self) -> Iterator[FoamFieldFile]:
73
77
  for p in self.path.iterdir():
74
- if p.is_file():
75
- yield FoamFieldFile(p.name)
78
+ if p.is_file() and (
79
+ p.suffix != ".gz" or not p.with_suffix("").is_file()
80
+ ):
81
+ yield FoamFieldFile(p)
76
82
 
77
83
  def __len__(self) -> int:
78
84
  return len(list(iter(self)))
@@ -114,7 +120,7 @@ class FoamCaseBase(Sequence["FoamCaseBase.TimeDirectory"]):
114
120
  self, index: Union[int, slice, float, str]
115
121
  ) -> Union["FoamCaseBase.TimeDirectory", Sequence["FoamCaseBase.TimeDirectory"]]:
116
122
  if isinstance(index, str):
117
- return FoamCaseBase.TimeDirectory(self.path / str(index))
123
+ return FoamCaseBase.TimeDirectory(self.path / index)
118
124
  elif isinstance(index, float):
119
125
  for time in self._times:
120
126
  if time.time == index:
@@ -1,3 +1,4 @@
1
+ import gzip
1
2
  import sys
2
3
  from copy import deepcopy
3
4
  from pathlib import Path
@@ -47,6 +48,10 @@ class FoamFileIO:
47
48
  def _read(self) -> Tuple[bytes, Parsed]:
48
49
  if not self.__defer_io:
49
50
  contents = self.path.read_bytes()
51
+
52
+ if self.path.suffix == ".gz":
53
+ contents = gzip.decompress(contents)
54
+
50
55
  if contents != self.__contents:
51
56
  self.__contents = contents
52
57
  self.__parsed = None
@@ -63,6 +68,9 @@ class FoamFileIO:
63
68
  self.__contents = contents
64
69
  self.__parsed = None
65
70
  if not self.__defer_io:
71
+ if self.path.suffix == ".gz":
72
+ contents = gzip.compress(contents)
73
+
66
74
  self.path.write_bytes(contents)
67
75
  self.__dirty = False
68
76
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foamlib
3
- Version: 0.3.8
3
+ Version: 0.3.10
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
@@ -28,22 +28,28 @@ License-File: LICENSE.txt
28
28
  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
+ Provides-Extra: numpy
32
+ Requires-Dist: numpy<2,>=1; extra == "numpy"
31
33
  Provides-Extra: lint
32
34
  Requires-Dist: ruff; extra == "lint"
33
- Provides-Extra: typing
34
- Requires-Dist: mypy<2,>=1; extra == "typing"
35
- Requires-Dist: pytest<9,>=7; extra == "typing"
36
- Requires-Dist: pytest-asyncio<0.24,>=0.21; extra == "typing"
37
- Requires-Dist: numpy<2,>=1; extra == "typing"
38
35
  Provides-Extra: test
36
+ Requires-Dist: foamlib[numpy]; extra == "test"
39
37
  Requires-Dist: pytest<9,>=7; extra == "test"
40
38
  Requires-Dist: pytest-asyncio<0.24,>=0.21; extra == "test"
41
39
  Requires-Dist: pytest-cov; extra == "test"
42
- Requires-Dist: numpy<2,>=1; extra == "test"
40
+ Provides-Extra: typing
41
+ Requires-Dist: foamlib[test]; extra == "typing"
42
+ Requires-Dist: mypy<2,>=1; extra == "typing"
43
43
  Provides-Extra: docs
44
+ Requires-Dist: foamlib[numpy]; extra == "docs"
44
45
  Requires-Dist: sphinx<8,>=7; extra == "docs"
45
46
  Requires-Dist: sphinx_rtd_theme; extra == "docs"
46
- Requires-Dist: numpy<2,>=1; extra == "docs"
47
+ Provides-Extra: dev
48
+ Requires-Dist: foamlib[numpy]; extra == "dev"
49
+ Requires-Dist: foamlib[lint]; extra == "dev"
50
+ Requires-Dist: foamlib[test]; extra == "dev"
51
+ Requires-Dist: foamlib[typing]; extra == "dev"
52
+ Requires-Dist: foamlib[docs]; extra == "dev"
47
53
 
48
54
  [<img alt="foamlib" src="https://github.com/gerlero/foamlib/raw/main/logo.png" height="50">](https://github.com/gerlero/foamlib)
49
55
 
@@ -4,22 +4,30 @@ pyparsing<4,>=3
4
4
  [:python_version < "3.11"]
5
5
  typing-extensions<5,>=4
6
6
 
7
+ [dev]
8
+ foamlib[numpy]
9
+ foamlib[lint]
10
+ foamlib[test]
11
+ foamlib[typing]
12
+ foamlib[docs]
13
+
7
14
  [docs]
15
+ foamlib[numpy]
8
16
  sphinx<8,>=7
9
17
  sphinx_rtd_theme
10
- numpy<2,>=1
11
18
 
12
19
  [lint]
13
20
  ruff
14
21
 
22
+ [numpy]
23
+ numpy<2,>=1
24
+
15
25
  [test]
26
+ foamlib[numpy]
16
27
  pytest<9,>=7
17
28
  pytest-asyncio<0.24,>=0.21
18
29
  pytest-cov
19
- numpy<2,>=1
20
30
 
21
31
  [typing]
32
+ foamlib[test]
22
33
  mypy<2,>=1
23
- pytest<9,>=7
24
- pytest-asyncio<0.24,>=0.21
25
- numpy<2,>=1
@@ -36,23 +36,29 @@ dependencies = [
36
36
  dynamic = ["version"]
37
37
 
38
38
  [project.optional-dependencies]
39
+ numpy = ["numpy>=1,<2"]
39
40
  lint = ["ruff"]
40
- typing = [
41
- "mypy>=1,<2",
42
- "pytest>=7,<9",
43
- "pytest-asyncio>=0.21,<0.24",
44
- "numpy>=1,<2",
45
- ]
46
41
  test = [
42
+ "foamlib[numpy]",
47
43
  "pytest>=7,<9",
48
44
  "pytest-asyncio>=0.21,<0.24",
49
45
  "pytest-cov",
50
- "numpy>=1,<2",
46
+ ]
47
+ typing = [
48
+ "foamlib[test]",
49
+ "mypy>=1,<2",
51
50
  ]
52
51
  docs = [
52
+ "foamlib[numpy]",
53
53
  "sphinx>=7,<8",
54
54
  "sphinx_rtd_theme",
55
- "numpy>=1,<2",
55
+ ]
56
+ dev = [
57
+ "foamlib[numpy]",
58
+ "foamlib[lint]",
59
+ "foamlib[test]",
60
+ "foamlib[typing]",
61
+ "foamlib[docs]",
56
62
  ]
57
63
 
58
64
  [project.urls]
File without changes
File without changes
File without changes
File without changes
File without changes