Use xjson.pprint instead of json.dump for output.

Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
This commit is contained in:
Tim 'mithro' Ansell 2018-12-13 14:55:04 -08:00
parent 178002d348
commit fb2d809659
6 changed files with 19 additions and 16 deletions

View File

@ -2,6 +2,8 @@
import os, sys, json, re import os, sys, json, re
from prjxray import xjson
def load_tiles(tiles_fn): def load_tiles(tiles_fn):
''' '''
@ -57,12 +59,7 @@ def run(tiles_fn, json_fn, verbose=False):
database = make_database(tiles) database = make_database(tiles)
# Save # Save
json.dump( xjson.pprint(open(json_fn, 'w'), database)
database,
open(json_fn, 'w'),
sort_keys=True,
indent=4,
separators=(',', ': '))
def main(): def main():

View File

@ -15,6 +15,8 @@ import re
import sys import sys
import copy import copy
from prjxray import xjson
# All site names appear to follow the pattern <type>_X<abs coord>Y<abs coord>. # All site names appear to follow the pattern <type>_X<abs coord>Y<abs coord>.
# Generally speaking, only the tile relatively coordinates are required to # Generally speaking, only the tile relatively coordinates are required to
# assemble arch defs, so we re-origin the coordinates to be relative to the tile # assemble arch defs, so we re-origin the coordinates to be relative to the tile
@ -113,8 +115,7 @@ def main():
site_pin['name'] = site_pin['name'][len(orig_site_name) + 1:] site_pin['name'] = site_pin['name'][len(orig_site_name) + 1:]
json.dump(output_site_pins, sys.stdout, indent=2) xjson.pprint(sys.stdout, output_site_pins)
sys.stdout.write('\n')
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -1,12 +1,13 @@
import argparse import argparse
import datetime import datetime
import progressbar import progressbar
import json
import os.path import os.path
import prjxray.lib import prjxray.lib
import pickle import pickle
import collections import collections
from prjxray import xjson
def build_node_index(fname): def build_node_index(fname):
node_index = {} node_index = {}
@ -271,7 +272,7 @@ def main():
print('{} Writing node tree'.format(datetime.datetime.now())) print('{} Writing node tree'.format(datetime.datetime.now()))
with open(os.path.join(args.output_dir, 'node_tree.json'), 'w') as f: with open(os.path.join(args.output_dir, 'node_tree.json'), 'w') as f:
json.dump(nodes, f, indent=2) xjson.pprint(f, nodes)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -13,6 +13,8 @@ import datetime
import pickle import pickle
import sys import sys
from prjxray import xjson
def get_tile_grid_info(fname): def get_tile_grid_info(fname):
with open(fname, 'r') as f: with open(fname, 'r') as f:
@ -606,7 +608,7 @@ def main():
print('{} Writing tileconn'.format(datetime.datetime.now())) print('{} Writing tileconn'.format(datetime.datetime.now()))
with open(tileconn_file, 'w') as f: with open(tileconn_file, 'w') as f:
json.dump(tileconn, f, indent=2) xjson.pprint(f, tileconn)
else: else:
with open(wire_map_file, 'rb') as f: with open(wire_map_file, 'rb') as f:
wire_map = pickle.load(f) wire_map = pickle.load(f)
@ -651,7 +653,7 @@ def main():
if len(error_nodes) > 0: if len(error_nodes) > 0:
error_nodes_file = os.path.join(args.output_dir, 'error_nodes.json') error_nodes_file = os.path.join(args.output_dir, 'error_nodes.json')
with open(error_nodes_file, 'w') as f: with open(error_nodes_file, 'w') as f:
json.dump(error_nodes, f, indent=2) xjson.pprint(f, error_nodes)
ignored_wires = [] ignored_wires = []
ignored_wires_file = args.ignored_wires ignored_wires_file = args.ignored_wires

View File

@ -11,7 +11,8 @@ import prjxray.lib
import os import os
import os.path import os.path
import re import re
import json
from prxray import xjson
def main(): def main():
@ -55,7 +56,7 @@ def main():
with open(os.path.join(args.output_dir, with open(os.path.join(args.output_dir,
'site_type_{}.json'.format(site_type)), 'site_type_{}.json'.format(site_type)),
'w') as f: 'w') as f:
json.dump(proto_site_type, f, indent=2) xjson.pprint(f, proto_site_type)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -18,6 +18,7 @@ import multiprocessing
import os import os
import functools import functools
from prxray import xjson
def check_and_strip_prefix(name, prefix): def check_and_strip_prefix(name, prefix):
assert name.startswith(prefix), repr((name, prefix)) assert name.startswith(prefix), repr((name, prefix))
@ -323,10 +324,10 @@ def main():
with open(os.path.join( with open(os.path.join(
args.output_dir, 'tile_type_{}_site_type_{}.json'.format( args.output_dir, 'tile_type_{}_site_type_{}.json'.format(
tile_type, site_types[site_type]['type'])), 'w') as f: tile_type, site_types[site_type]['type'])), 'w') as f:
json.dump(site_types[site_type], f, indent=2) xjson.pprint(f, site_types[site_type])
with open(tile_type_file, 'w') as f: with open(tile_type_file, 'w') as f:
json.dump(reduced_tile, f, indent=2) xjson.pprint(f, reduced_tile)
if __name__ == '__main__': if __name__ == '__main__':