Skip to content

Commit 312d4cf

Browse files
Make is_valid_poscar less noisy (#422)
* Make `is_valid_poscar` less noisy * pre-commit auto-fixes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 20cefaf commit 312d4cf

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

src/custodian/vasp/utils.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,13 @@ def is_valid_poscar(filename: str, directory: str = "./") -> bool:
125125
"""
126126
filepath = os.path.join(directory, filename)
127127

128-
# Check file exists
129-
if not os.path.isfile(filepath):
130-
logger.warning(f"{filename} does not exist in {directory}")
131-
return False
132-
133-
# Check file is not empty
134-
if os.path.getsize(filepath) == 0:
135-
logger.warning(f"{filename} is empty")
128+
# Check file exists and is not blank
129+
if not os.path.isfile(filepath) or os.path.getsize(filepath) == 0:
136130
return False
137131

138132
# Try to parse as POSCAR
139133
try:
140134
Poscar.from_file(filepath)
141135
return True
142-
except Exception as exc:
143-
logger.warning(f"{filename} could not be parsed: {exc}")
136+
except Exception:
144137
return False

0 commit comments

Comments
 (0)