From ebc5adaa7f27fe75aed7cc8c9a9c0b9b4cd96a64 Mon Sep 17 00:00:00 2001 From: linuxdaemon Date: Thu, 14 Feb 2019 14:29:52 -0600 Subject: [PATCH] Add __name__ guard to format_json.py --- format_json.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/format_json.py b/format_json.py index b3edb3769..40b1dc3d7 100644 --- a/format_json.py +++ b/format_json.py @@ -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)