foamlib 0.2.4__tar.gz → 0.2.5__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.
Files changed (25) hide show
  1. {foamlib-0.2.4 → foamlib-0.2.5}/PKG-INFO +9 -10
  2. {foamlib-0.2.4 → foamlib-0.2.5}/README.md +1 -1
  3. {foamlib-0.2.4 → foamlib-0.2.5}/foamlib/__init__.py +1 -1
  4. {foamlib-0.2.4 → foamlib-0.2.5}/foamlib/_cases.py +18 -10
  5. {foamlib-0.2.4 → foamlib-0.2.5}/foamlib/_dictionaries/_base.py +8 -1
  6. {foamlib-0.2.4 → foamlib-0.2.5}/foamlib/_dictionaries/_files.py +14 -8
  7. {foamlib-0.2.4 → foamlib-0.2.5}/foamlib/_dictionaries/_parsing.py +8 -2
  8. {foamlib-0.2.4 → foamlib-0.2.5}/foamlib/_dictionaries/_serialization.py +11 -19
  9. foamlib-0.2.4/foamlib/_subprocesses.py → foamlib-0.2.5/foamlib/_util.py +35 -8
  10. {foamlib-0.2.4 → foamlib-0.2.5}/foamlib.egg-info/PKG-INFO +9 -10
  11. {foamlib-0.2.4 → foamlib-0.2.5}/foamlib.egg-info/SOURCES.txt +1 -1
  12. {foamlib-0.2.4 → foamlib-0.2.5}/foamlib.egg-info/requires.txt +8 -6
  13. {foamlib-0.2.4 → foamlib-0.2.5}/pyproject.toml +3 -24
  14. {foamlib-0.2.4 → foamlib-0.2.5}/tests/test_dictionaries.py +1 -1
  15. {foamlib-0.2.4 → foamlib-0.2.5}/LICENSE.txt +0 -0
  16. {foamlib-0.2.4 → foamlib-0.2.5}/foamlib/_dictionaries/__init__.py +0 -0
  17. {foamlib-0.2.4 → foamlib-0.2.5}/foamlib/py.typed +0 -0
  18. {foamlib-0.2.4 → foamlib-0.2.5}/foamlib.egg-info/dependency_links.txt +0 -0
  19. {foamlib-0.2.4 → foamlib-0.2.5}/foamlib.egg-info/top_level.txt +0 -0
  20. {foamlib-0.2.4 → foamlib-0.2.5}/setup.cfg +0 -0
  21. {foamlib-0.2.4 → foamlib-0.2.5}/tests/test_basic.py +0 -0
  22. {foamlib-0.2.4 → foamlib-0.2.5}/tests/test_flange.py +0 -0
  23. {foamlib-0.2.4 → foamlib-0.2.5}/tests/test_flange_async.py +0 -0
  24. {foamlib-0.2.4 → foamlib-0.2.5}/tests/test_pitz.py +0 -0
  25. {foamlib-0.2.4 → foamlib-0.2.5}/tests/test_pitz_async.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foamlib
3
- Version: 0.2.4
3
+ Version: 0.2.5
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
@@ -27,15 +27,14 @@ Description-Content-Type: text/markdown
27
27
  License-File: LICENSE.txt
28
28
  Requires-Dist: aioshutil<2,>=1
29
29
  Requires-Dist: pyparsing<4,>=3
30
- Requires-Dist: typing-extensions<5,>=4
30
+ Requires-Dist: typing-extensions<5,>=4; python_version < "3.11"
31
31
  Provides-Extra: lint
32
- Requires-Dist: mypy<2,>=1; extra == "lint"
33
- Requires-Dist: pytest<9,>=7; extra == "lint"
34
- Requires-Dist: pytest-asyncio<0.24,>=0.21; extra == "lint"
35
- Requires-Dist: numpy<2,>=1; extra == "lint"
36
- Requires-Dist: black; extra == "lint"
37
- Requires-Dist: flake8; extra == "lint"
38
- Requires-Dist: Flake8-pyproject; extra == "lint"
32
+ 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"
39
38
  Provides-Extra: test
40
39
  Requires-Dist: pytest<9,>=7; extra == "test"
41
40
  Requires-Dist: pytest-asyncio<0.24,>=0.21; extra == "test"
@@ -52,7 +51,7 @@ Requires-Dist: numpy<2,>=1; extra == "docs"
52
51
  [![CI](https://github.com/gerlero/foamlib/actions/workflows/ci.yml/badge.svg)](https://github.com/gerlero/foamlib/actions/workflows/ci.yml)
53
52
  [![Codecov](https://codecov.io/gh/gerlero/foamlib/branch/main/graph/badge.svg)](https://codecov.io/gh/gerlero/foamlib)
54
53
  [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
55
- [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
54
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
56
55
  [![PyPI](https://img.shields.io/pypi/v/foamlib)](https://pypi.org/project/foamlib/)
57
56
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/foamlib)](https://pypi.org/project/foamlib/)
58
57
  [![Docker image](https://img.shields.io/badge/docker%20image-gerlero%2Ffoamlib-informational)](https://hub.docker.com/r/gerlero/foamlib/)
@@ -4,7 +4,7 @@
4
4
  [![CI](https://github.com/gerlero/foamlib/actions/workflows/ci.yml/badge.svg)](https://github.com/gerlero/foamlib/actions/workflows/ci.yml)
5
5
  [![Codecov](https://codecov.io/gh/gerlero/foamlib/branch/main/graph/badge.svg)](https://codecov.io/gh/gerlero/foamlib)
6
6
  [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
7
- [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
7
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
8
8
  [![PyPI](https://img.shields.io/pypi/v/foamlib)](https://pypi.org/project/foamlib/)
9
9
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/foamlib)](https://pypi.org/project/foamlib/)
10
10
  [![Docker image](https://img.shields.io/badge/docker%20image-gerlero%2Ffoamlib-informational)](https://hub.docker.com/r/gerlero/foamlib/)
@@ -1,4 +1,4 @@
1
- __version__ = "0.2.4"
1
+ __version__ = "0.2.5"
2
2
 
3
3
  from ._cases import FoamCase, AsyncFoamCase, FoamCaseBase
4
4
  from ._dictionaries import FoamFile, FoamFieldFile, FoamDictionaryBase
@@ -1,3 +1,4 @@
1
+ import sys
1
2
  import os
2
3
  import asyncio
3
4
  import multiprocessing
@@ -8,19 +9,26 @@ from contextlib import asynccontextmanager
8
9
  from typing import (
9
10
  Optional,
10
11
  Union,
11
- Collection,
12
- Mapping,
13
- Set,
14
- Sequence,
15
- AsyncGenerator,
16
- Callable,
17
- Iterator,
18
12
  overload,
19
13
  )
20
14
 
15
+ if sys.version_info >= (3, 9):
16
+ from collections.abc import (
17
+ Collection,
18
+ Mapping,
19
+ Set,
20
+ Sequence,
21
+ AsyncGenerator,
22
+ Callable,
23
+ Iterator,
24
+ )
25
+ else:
26
+ from typing import Collection, Mapping, Sequence, AsyncGenerator, Callable, Iterator
27
+ from typing import AbstractSet as Set
28
+
21
29
  import aioshutil
22
30
 
23
- from ._subprocesses import run_process, run_process_async, CalledProcessError
31
+ from ._util import is_sequence, run_process, run_process_async, CalledProcessError
24
32
  from ._dictionaries import FoamFile, FoamFieldFile
25
33
 
26
34
 
@@ -132,7 +140,7 @@ class FoamCaseBase(Sequence["FoamCaseBase.TimeDirectory"]):
132
140
  has_decompose_par_dict = (self.path / "system" / "decomposeParDict").is_file()
133
141
  has_block_mesh_dict = (self.path / "system" / "blockMeshDict").is_file()
134
142
 
135
- paths: Set[Path] = set()
143
+ paths = set()
136
144
 
137
145
  for p in self.path.iterdir():
138
146
  if p.is_dir():
@@ -215,7 +223,7 @@ class FoamCaseBase(Sequence["FoamCaseBase.TimeDirectory"]):
215
223
  def _parallel_cmd(
216
224
  self, cmd: Union[Sequence[Union[str, Path]], str, Path]
217
225
  ) -> Union[Sequence[Union[str, Path]], str]:
218
- if isinstance(cmd, str) or not isinstance(cmd, Sequence):
226
+ if not is_sequence(cmd):
219
227
  return f"mpiexec -np {self._nprocessors} {cmd} -parallel"
220
228
  else:
221
229
  return [
@@ -1,6 +1,13 @@
1
+ import sys
2
+
1
3
  from abc import abstractmethod
2
4
  from dataclasses import dataclass
3
- from typing import Dict, NamedTuple, Optional, Sequence, Union
5
+ from typing import Dict, NamedTuple, Optional, Union
6
+
7
+ if sys.version_info >= (3, 9):
8
+ from collections.abc import Sequence
9
+ else:
10
+ from typing import Sequence
4
11
 
5
12
 
6
13
  class FoamDictionaryBase:
@@ -1,21 +1,23 @@
1
+ import sys
2
+
1
3
  from pathlib import Path
2
4
  from typing import (
3
5
  Any,
4
- Iterator,
5
- Mapping,
6
- MutableMapping,
7
6
  Optional,
8
- Sequence,
9
7
  Tuple,
10
8
  Union,
11
9
  cast,
12
10
  )
13
11
 
14
- from typing_extensions import Self
12
+ if sys.version_info >= (3, 9):
13
+ from collections.abc import Iterator, Mapping, MutableMapping, Sequence
14
+ else:
15
+ from typing import Iterator, Mapping, MutableMapping, Sequence
15
16
 
16
- from ._base import FoamDictionaryBase
17
- from ._parsing import Parsed, as_dict, get_entry_locn, get_value, parse
18
- from ._serialization import serialize_entry
17
+ if sys.version_info >= (3, 11):
18
+ from typing import Self
19
+ else:
20
+ from typing_extensions import Self
19
21
 
20
22
  try:
21
23
  import numpy as np
@@ -23,6 +25,10 @@ try:
23
25
  except ModuleNotFoundError:
24
26
  pass
25
27
 
28
+ from ._base import FoamDictionaryBase
29
+ from ._parsing import Parsed, as_dict, get_entry_locn, get_value, parse
30
+ from ._serialization import serialize_entry
31
+
26
32
 
27
33
  class _FoamFileBase:
28
34
  def __init__(self, path: Union[str, Path]) -> None:
@@ -1,4 +1,11 @@
1
- from typing import Mapping, MutableMapping, Optional, Sequence, Tuple
1
+ import sys
2
+
3
+ from typing import Optional, Tuple
4
+
5
+ if sys.version_info >= (3, 9):
6
+ from collections.abc import Mapping, MutableMapping, Sequence
7
+ else:
8
+ from typing import Mapping, MutableMapping, Sequence
2
9
 
3
10
  from pyparsing import (
4
11
  Dict,
@@ -163,7 +170,6 @@ def as_dict(parsed: Parsed) -> FoamDictionaryBase._Dict:
163
170
  """
164
171
  ret: FoamDictionaryBase._Dict = {}
165
172
  for keywords, (_, value, _) in parsed.items():
166
-
167
173
  r = ret
168
174
  for k in keywords[:-1]:
169
175
  assert isinstance(r, dict)
@@ -1,23 +1,15 @@
1
- from contextlib import suppress
2
- from typing import Any, Mapping, Sequence
1
+ import sys
3
2
 
4
- from ._base import FoamDictionaryBase
3
+ from contextlib import suppress
4
+ from typing import Any
5
5
 
6
- try:
7
- import numpy as np
8
- except ModuleNotFoundError:
9
- numpy = False
6
+ if sys.version_info >= (3, 9):
7
+ from collections.abc import Mapping
10
8
  else:
11
- numpy = True
9
+ from typing import Mapping
12
10
 
13
-
14
- def _is_sequence(value: Any) -> bool:
15
- return (
16
- isinstance(value, Sequence)
17
- and not isinstance(value, str)
18
- or numpy
19
- and isinstance(value, np.ndarray)
20
- )
11
+ from ._base import FoamDictionaryBase
12
+ from .._util import is_sequence
21
13
 
22
14
 
23
15
  def _serialize_bool(value: Any) -> str:
@@ -30,14 +22,14 @@ def _serialize_bool(value: Any) -> str:
30
22
 
31
23
 
32
24
  def _serialize_list(value: Any) -> str:
33
- if _is_sequence(value):
25
+ if is_sequence(value):
34
26
  return f"({' '.join(_serialize_value(v) for v in value)})"
35
27
  else:
36
28
  raise TypeError(f"Not a valid sequence: {type(value)}")
37
29
 
38
30
 
39
31
  def _serialize_field(value: Any) -> str:
40
- if _is_sequence(value):
32
+ if is_sequence(value):
41
33
  try:
42
34
  s = _serialize_list(value)
43
35
  except TypeError:
@@ -64,7 +56,7 @@ def _serialize_field(value: Any) -> str:
64
56
 
65
57
 
66
58
  def _serialize_dimensions(value: Any) -> str:
67
- if _is_sequence(value) and len(value) == 7:
59
+ if is_sequence(value) and len(value) == 7:
68
60
  return f"[{' '.join(str(v) for v in value)}]"
69
61
  else:
70
62
  raise TypeError(f"Not a valid dimension set: {type(value)}")
@@ -1,12 +1,40 @@
1
1
  import asyncio
2
2
  import sys
3
+ import subprocess
3
4
 
4
5
  from pathlib import Path
5
- from typing import Union, Sequence, Mapping
6
- import subprocess
7
- from subprocess import CalledProcessError
6
+ from typing import Any, Union
7
+
8
+ if sys.version_info >= (3, 9):
9
+ from collections.abc import Mapping, Sequence
10
+ else:
11
+ from typing import Mapping, Sequence
12
+
13
+ if sys.version_info >= (3, 10):
14
+ from typing import TypeGuard
15
+ else:
16
+ from typing_extensions import TypeGuard
17
+
18
+ try:
19
+ import numpy as np
20
+ except ModuleNotFoundError:
21
+ numpy = False
22
+ else:
23
+ numpy = True
24
+
25
+
26
+ def is_sequence(
27
+ value: Any,
28
+ ) -> TypeGuard[Union["Sequence[Any]", "np.ndarray[Any, Any]"]]:
29
+ return (
30
+ isinstance(value, Sequence)
31
+ and not isinstance(value, str)
32
+ or numpy
33
+ and isinstance(value, np.ndarray)
34
+ )
35
+
8
36
 
9
- __all__ = ["run_process", "run_process_async", "CalledProcessError"]
37
+ CalledProcessError = subprocess.CalledProcessError
10
38
 
11
39
 
12
40
  def run_process(
@@ -16,7 +44,7 @@ def run_process(
16
44
  cwd: Union[None, str, Path] = None,
17
45
  env: Union[None, Mapping[str, str]] = None,
18
46
  ) -> "subprocess.CompletedProcess[bytes]":
19
- shell = isinstance(cmd, str) or not isinstance(cmd, Sequence)
47
+ shell = not is_sequence(cmd)
20
48
 
21
49
  if sys.version_info < (3, 8):
22
50
  if shell:
@@ -28,8 +56,7 @@ def run_process(
28
56
  cmd,
29
57
  cwd=cwd,
30
58
  env=env,
31
- stdout=subprocess.PIPE,
32
- stderr=subprocess.PIPE,
59
+ capture_output=True,
33
60
  shell=shell,
34
61
  check=check,
35
62
  )
@@ -44,7 +71,7 @@ async def run_process_async(
44
71
  cwd: Union[None, str, Path] = None,
45
72
  env: Union[None, Mapping[str, str]] = None,
46
73
  ) -> "subprocess.CompletedProcess[bytes]":
47
- if isinstance(cmd, str) or not isinstance(cmd, Sequence):
74
+ if not is_sequence(cmd):
48
75
  proc = await asyncio.create_subprocess_shell(
49
76
  str(cmd),
50
77
  cwd=cwd,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foamlib
3
- Version: 0.2.4
3
+ Version: 0.2.5
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
@@ -27,15 +27,14 @@ Description-Content-Type: text/markdown
27
27
  License-File: LICENSE.txt
28
28
  Requires-Dist: aioshutil<2,>=1
29
29
  Requires-Dist: pyparsing<4,>=3
30
- Requires-Dist: typing-extensions<5,>=4
30
+ Requires-Dist: typing-extensions<5,>=4; python_version < "3.11"
31
31
  Provides-Extra: lint
32
- Requires-Dist: mypy<2,>=1; extra == "lint"
33
- Requires-Dist: pytest<9,>=7; extra == "lint"
34
- Requires-Dist: pytest-asyncio<0.24,>=0.21; extra == "lint"
35
- Requires-Dist: numpy<2,>=1; extra == "lint"
36
- Requires-Dist: black; extra == "lint"
37
- Requires-Dist: flake8; extra == "lint"
38
- Requires-Dist: Flake8-pyproject; extra == "lint"
32
+ 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"
39
38
  Provides-Extra: test
40
39
  Requires-Dist: pytest<9,>=7; extra == "test"
41
40
  Requires-Dist: pytest-asyncio<0.24,>=0.21; extra == "test"
@@ -52,7 +51,7 @@ Requires-Dist: numpy<2,>=1; extra == "docs"
52
51
  [![CI](https://github.com/gerlero/foamlib/actions/workflows/ci.yml/badge.svg)](https://github.com/gerlero/foamlib/actions/workflows/ci.yml)
53
52
  [![Codecov](https://codecov.io/gh/gerlero/foamlib/branch/main/graph/badge.svg)](https://codecov.io/gh/gerlero/foamlib)
54
53
  [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
55
- [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
54
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
56
55
  [![PyPI](https://img.shields.io/pypi/v/foamlib)](https://pypi.org/project/foamlib/)
57
56
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/foamlib)](https://pypi.org/project/foamlib/)
58
57
  [![Docker image](https://img.shields.io/badge/docker%20image-gerlero%2Ffoamlib-informational)](https://hub.docker.com/r/gerlero/foamlib/)
@@ -3,7 +3,7 @@ README.md
3
3
  pyproject.toml
4
4
  foamlib/__init__.py
5
5
  foamlib/_cases.py
6
- foamlib/_subprocesses.py
6
+ foamlib/_util.py
7
7
  foamlib/py.typed
8
8
  foamlib.egg-info/PKG-INFO
9
9
  foamlib.egg-info/SOURCES.txt
@@ -1,5 +1,7 @@
1
1
  aioshutil<2,>=1
2
2
  pyparsing<4,>=3
3
+
4
+ [:python_version < "3.11"]
3
5
  typing-extensions<5,>=4
4
6
 
5
7
  [docs]
@@ -8,16 +10,16 @@ sphinx_rtd_theme
8
10
  numpy<2,>=1
9
11
 
10
12
  [lint]
11
- mypy<2,>=1
13
+ ruff
14
+
15
+ [test]
12
16
  pytest<9,>=7
13
17
  pytest-asyncio<0.24,>=0.21
18
+ pytest-cov
14
19
  numpy<2,>=1
15
- black
16
- flake8
17
- Flake8-pyproject
18
20
 
19
- [test]
21
+ [typing]
22
+ mypy<2,>=1
20
23
  pytest<9,>=7
21
24
  pytest-asyncio<0.24,>=0.21
22
- pytest-cov
23
25
  numpy<2,>=1
@@ -30,20 +30,18 @@ classifiers = [
30
30
  dependencies = [
31
31
  "aioshutil>=1,<2",
32
32
  "pyparsing>=3,<4",
33
- "typing-extensions>=4,<5",
33
+ "typing-extensions>=4,<5; python_version<'3.11'",
34
34
  ]
35
35
 
36
36
  dynamic = ["version"]
37
37
 
38
38
  [project.optional-dependencies]
39
- lint = [
39
+ lint = ["ruff"]
40
+ typing = [
40
41
  "mypy>=1,<2",
41
42
  "pytest>=7,<9",
42
43
  "pytest-asyncio>=0.21,<0.24",
43
44
  "numpy>=1,<2",
44
- "black",
45
- "flake8",
46
- "Flake8-pyproject",
47
45
  ]
48
46
  test = [
49
47
  "pytest>=7,<9",
@@ -74,22 +72,3 @@ packages = [
74
72
  "tests",
75
73
  ]
76
74
  strict = true
77
-
78
- [tool.flake8]
79
- count = true
80
- ignore = [
81
- "E203", # whitespace before ':'
82
- "E501", # line too long
83
- "E704", # multiple statements on one line (def)
84
- "F403", # 'from foamlib import *' used; unable to detect undefined names
85
- "F405", # 'FoamDimensionSet' may be undefined, or defined from star imports: foamlib
86
- "W503", # line break before binary operator
87
- ]
88
- exclude = [
89
- ".git",
90
- "__pycache__",
91
- "docs/source/conf.py",
92
- "build",
93
- "dist",
94
- "venv",
95
- ]
@@ -6,7 +6,7 @@ from typing import Sequence
6
6
 
7
7
  import numpy as np
8
8
 
9
- from foamlib import *
9
+ from foamlib import FoamCase, FoamFile, FoamFieldFile
10
10
  from foamlib._dictionaries._parsing import _VALUE
11
11
 
12
12
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes