Skip to content

Commit 17855fe

Browse files
committed
Reduce code duplication.
1 parent 2541b9f commit 17855fe

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/pymatgen/io/vasp/outputs.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5803,18 +5803,16 @@ def __init__(self, dirname: str | Path):
58035803
dirname: The directory containing the VASP calculation as a string or Path.
58045804
"""
58055805
self.path = Path(dirname).absolute()
5806-
5807-
# Note that py3.12 has Path.walk(). But we need to use os.walk to ensure backwards compatibility for now.
5808-
self.files = [str(Path(d) / f).lstrip(str(self.path)) for d, _, fnames in os.walk(self.path) for f in fnames]
5809-
self._parsed_files: dict[str, Any] = {}
5806+
self.reset()
58105807

58115808
def reset(self):
58125809
"""
58135810
Reset all loaded files and recheck the directory for files. Use this when the contents of the directory has
58145811
changed.
58155812
"""
5813+
# Note that py3.12 has Path.walk(). But we need to use os.walk to ensure backwards compatibility for now.
58165814
self.files = [str(Path(d) / f).lstrip(str(self.path)) for d, _, fnames in os.walk(self.path) for f in fnames]
5817-
self._parsed_files = {}
5815+
self._parsed_files: dict[str, Any] = {}
58185816

58195817
def __len__(self):
58205818
return len(self.files)

0 commit comments

Comments
 (0)