Skip to content

Commit

Permalink
Fix ResourceResolver docstring; add repr
Browse files Browse the repository at this point in the history
  • Loading branch information
pmrv committed Jul 10, 2024
1 parent c2270c9 commit 8385900
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions pyiron_snippets/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,13 @@ class ResourceResolver(AbstractResolver):
Search results can be restricted by passing a (list of) globs. If a list is given, entries matching at least one of
them are returned.
>>> exe = ResourceResolver(..., "lammps")
>>> exe.list() # doctest: +SKIP
>>> res = ResourceResolver(..., "lammps")
>>> res.list() # doctest: +SKIP
[
('v1', '/my/resources/lammps/bin/run_lammps_v1.sh),
('v1_mpi', '/my/resources/lammps/bin/run_lammps_v1_mpi.sh),
('v2_default', '/my/resources/lammps/bin/run_lammps_v2_default.sh),
"bin",
"potentials",
"potentials.csv"
]
>>> exe.default_version # doctest: +SKIP
"v2_default"
>>> exe.dict("v1*") # doctest: +SKIP
{
'v1': '/my/resources/lammps/bin/run_lammps_v1.sh),
'v1_mpi': '/my/resources/lammps/bin/run_lammps_v1_mpi.sh)
}
"""
__slots__ = "_resource_paths", "_module", "_subdirs"
def __init__(self, resource_paths, module, *subdirs):
Expand Down Expand Up @@ -236,6 +229,14 @@ def __init__(self, resource_paths, code, module=None, suffix=EXE_SUFFIX):
module, 'bin',
)

def __repr__(self):
inner = repr(self._resolver._resource_paths)
inner += f", {repr(self._glob)}"
inner += f", {repr(self._resolver._module)}"
# recover suffix
inner += f", {repr(self._glob.split(".")[-1])}"
return f"{type(self).__name__}({inner})"

def _search(self, name):
seen = set()
def cond(path):
Expand Down

0 comments on commit 8385900

Please sign in to comment.