Skip to content
This repository has been archived by the owner on Oct 23, 2019. It is now read-only.

Commit

Permalink
Add __name__ guard to format_json.py
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdaemon committed Feb 14, 2019
1 parent 02950e6 commit ebc5ada
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions format_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import json
from pathlib import Path

path = Path().resolve()
if __name__ == '__main__':
path = Path().resolve()

for file in path.rglob("*.json"):
print(file)
with file.open(encoding='utf8') as f:
data = json.load(f, object_pairs_hook=collections.OrderedDict)
for file in path.rglob("*.json"):
print(file)
with file.open(encoding='utf8') as f:
data = json.load(f, object_pairs_hook=collections.OrderedDict)

with file.open('w', encoding='utf8') as f:
print(json.dumps(data, indent=4), file=f)
with file.open('w', encoding='utf8') as f:
print(json.dumps(data, indent=4), file=f)

0 comments on commit ebc5ada

Please sign in to comment.