Skip to content

Commit

Permalink
write resources.file() for python 3.9-3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
orbeckst committed Jun 17, 2024
1 parent edbc90d commit 376a079
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gromacs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,13 @@ def _generate_template_dict(dirname):
.. SeeAlso:: importlib.resources
"""
# for Python >= 3.12:
# replace `sys.modules[__name__].__package__` with `__name__`
return dict(
(entry.name, entry)
for entry in resources.files(__name__).joinpath(dirname).iterdir()
for entry in resources.files(sys.modules[__name__].__package__)
.joinpath(dirname)
.iterdir()
if not entry.name.endswith(("~", "__pycache__", "__init__.py"))
)

Expand Down

0 comments on commit 376a079

Please sign in to comment.