Pretty print JSON when dumping

Closes https://git.vvvvvvaria.org/decentral1se/xbotlib/issues/8.
This commit is contained in:
Luke Murphy 2021-01-31 21:41:25 +01:00
parent e0cc4203d3
commit 8e7db79903
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 2 additions and 1 deletions

View File

@ -3,6 +3,7 @@
# xbotlib 0.16.0 (2021-01-??)
- Fix logging of exceptions and increase info for stack traces ([#2](https://github.com/decentral1se/xbotlib/issues/2))
- Format JSON to human readable when saving ([#8](https://git.vvvvvvaria.org/decentral1se/xbotlib/issues/8))
# xbotlib 0.15.2 (2021-01-24)

View File

@ -49,7 +49,7 @@ class SimpleDatabase(dict):
"""Save the databse to disk."""
try:
with open(self.filename, "w") as handle:
handle.write(dumps(self))
handle.write(dumps(self, indent=2, sort_keys=True))
except Exception as exception:
message = f"Saving file storage failed: {exception}"
self.log.error(message)