Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmod committed Feb 1, 2024
1 parent 6c33f6a commit 35600b9
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions whotracksme/website/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
import pathlib
import os

def myconverter(o):
if isinstance(o, datetime.datetime):
return o.isoformat()
def write_json(path, **data):
def myconverter(o):
if isinstance(o, datetime.datetime):
return o.isoformat()

def write_json(aPath, **aDict):
pathlib.Path(os.path.dirname(aPath)).mkdir(parents=True, exist_ok=True)
jsonString = simplejson.dumps(aDict, indent=2, default = myconverter)
jsonFile = open(aPath, "w")
jsonFile.write(jsonString)
jsonFile.close()
pathlib.Path(os.path.dirname(path)).mkdir(parents=True, exist_ok=True)
json = simplejson.dumps(data, indent=2, default = myconverter)
with open(path, "w") as file:
file.write(json)

def without_keys(d, keys):
return {k: d[k] for k in d.keys() - keys}
Expand Down

0 comments on commit 35600b9

Please sign in to comment.