Skip to content

Commit

Permalink
support loading and saving text files as json
Browse files Browse the repository at this point in the history
  • Loading branch information
javierluraschi committed Jul 22, 2024
1 parent 857a544 commit 1ced055
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions python/hal9/iobind.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def add_extension(path, contents):
_, extension = os.path.splitext(path)
if not extension:
if isinstance(contents, dict) or isinstance(contents, list):
if isinstance(contents, dict) or isinstance(contents, list) or isinstance(contents, str):
path = path + ".json"
else:
path = path + ".pkl"
Expand Down Expand Up @@ -74,8 +74,6 @@ def save(name, contents, hidden = False):

if isinstance(contents, str):
file_path.write_text(contents)
elif isinstance(contents, bytes):
file_path.write_bytes(contents)
else:
with open(file_path, 'wb') as file:
pickle.dump(contents, file)
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hal9"
version = "2.4.9"
version = "2.5.0"
description = ""
authors = ["Javier Luraschi <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 1ced055

Please sign in to comment.