Skip to content

Commit ebafaf1

Browse files
authored
Merge pull request #84 from Jylpah/dev
version 0.3.7
2 parents 44a86b8 + 79adedb commit ebafaf1

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pyutils"
3-
version = "0.3.6"
3+
version = "0.3.7"
44
authors = [{ name = "Jylpah", email = "[email protected]" }]
55
description = "Misc Python utils and classes"
66
readme = "README.md"

src/pyutils/jsonexportable.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,21 @@ def from_objs(
144144
]
145145

146146
@classmethod
147-
async def open_json(cls, filename: Path | str) -> Self | None:
147+
async def open_json(
148+
cls, filename: Path | str, exceptions: bool = False
149+
) -> Self | None:
148150
"""Open replay JSON file and return class instance"""
149151
try:
150152
async with open(filename, "r") as f:
151153
return cls.parse_raw(await f.read())
152154
except ValidationError as err:
153-
error(f"Error parsing file: {filename}: {err}")
155+
debug(f"Error parsing file: {filename}: {err}")
156+
if exceptions:
157+
raise
154158
except OSError as err:
155-
error(f"Error reading file: {filename}: {err}")
159+
debug(f"Error reading file: {filename}: {err}")
160+
if exceptions:
161+
raise
156162
return None
157163

158164
@classmethod

0 commit comments

Comments
 (0)