Skip to content

Commit

Permalink
Merge pull request #84 from Jylpah/dev
Browse files Browse the repository at this point in the history
version 0.3.7
  • Loading branch information
Jylpah authored Sep 24, 2023
2 parents 44a86b8 + 79adedb commit ebafaf1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pyutils"
version = "0.3.6"
version = "0.3.7"
authors = [{ name = "Jylpah", email = "[email protected]" }]
description = "Misc Python utils and classes"
readme = "README.md"
Expand Down
12 changes: 9 additions & 3 deletions src/pyutils/jsonexportable.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,21 @@ def from_objs(
]

@classmethod
async def open_json(cls, filename: Path | str) -> Self | None:
async def open_json(
cls, filename: Path | str, exceptions: bool = False
) -> Self | None:
"""Open replay JSON file and return class instance"""
try:
async with open(filename, "r") as f:
return cls.parse_raw(await f.read())
except ValidationError as err:
error(f"Error parsing file: {filename}: {err}")
debug(f"Error parsing file: {filename}: {err}")
if exceptions:
raise
except OSError as err:
error(f"Error reading file: {filename}: {err}")
debug(f"Error reading file: {filename}: {err}")
if exceptions:
raise
return None

@classmethod
Expand Down

0 comments on commit ebafaf1

Please sign in to comment.