Pretty print update

This commit is contained in:
paulevsGitch 2020-09-27 01:11:35 +03:00
parent 4358767de7
commit f6a0f33a19
108 changed files with 2199 additions and 1006 deletions

View file

@ -1,22 +1,22 @@
import json
import os
import re
data = {}
def save_json(json_file):
with open(json_file) as read_file:
data = json.load(read_file)
with open(json_file, "w") as data_file:
json.dump(data, data_file, indent=4, sort_keys=True)
dump = json.dumps(data, sort_keys=True, indent=4, separators=(',', ': '))
new_data = re.sub('\n +', lambda match: '\n' + '\t' * (len(match.group().strip('\n')) / 3), dump)
print >> open(json_file, 'w'), new_data
path = "D:\\BetterEnd\\BetterEnd_1.16.3\\utility_res\\item"
def scan_rec(path):
for r, d, f in os.walk(path):
for file in f:
if '.json' in file:
save_json(os.path.join(r, file))
print("Saved " + file)
for dir in d:
scan_rec(os.path.join(r, dir))
files = []
# r=root, d=directories, f = files
for r, d, f in os.walk(path):
for file in f:
if '.json' in file:
files.append(os.path.join(r, file))
for f in files:
print(f)
save_json(f)
scan_rec(os.path.abspath("./../src/main/resources/assets/betterend"))