Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/maggma/stores/file_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def query( # type: ignore
# TODO - could add more logic for detecting different file types
# and more nuanced exception handling
try:
with zopen(d["path"], "r", encoding=self.encoding) as f:
with zopen(d["path"], "rt", encoding=self.encoding) as f:
data = f.read()
except Exception as e:
data = f"Unable to read: {e}"
Expand Down
6 changes: 3 additions & 3 deletions src/maggma/stores/mongolike.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def connect(self, force_reset: bool = False):

# create the .json file if it does not exist
if not self.read_only and not Path(self.paths[0]).exists():
with zopen(self.paths[0], "w", encoding=self.encoding) as f:
with zopen(self.paths[0], "wt", encoding=self.encoding) as f:
data: list[dict] = []
bytesdata = orjson.dumps(data)
f.write(bytesdata.decode("utf-8"))
Expand All @@ -711,7 +711,7 @@ def read_json_file(self, path) -> list:
Args:
path: Path to the JSON file to be read
"""
with zopen(path, "r") as f:
with zopen(path, "rt") as f:
data = f.read()
data = data.decode() if isinstance(data, bytes) else data
objects = bson.json_util.loads(data) if "$oid" in data else orjson.loads(data)
Expand Down Expand Up @@ -761,7 +761,7 @@ def update_json_file(self):
"""
Updates the json file when a write-like operation is performed.
"""
with zopen(self.paths[0], "w", encoding=self.encoding) as f:
with zopen(self.paths[0], "wt", encoding=self.encoding) as f:
data = list(self.query())
for d in data:
d.pop("_id")
Expand Down
Loading