Skip to content

Commit

Permalink
Use xjson.pprint instead of json.dump for output.
Browse files Browse the repository at this point in the history
Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
  • Loading branch information
mithro committed Dec 13, 2018
1 parent 3ffd6da commit de75899
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
9 changes: 3 additions & 6 deletions fuzzers/005-tilegrid/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import os, sys, json, re

from prjxray import xjson

# matches lib/include/prjxray/xilinx/xc7series/block_type.h
block_type_i2s = {
0: 'CLB_IO_CLK',
Expand Down Expand Up @@ -539,12 +541,7 @@ def run(tiles_fn, json_fn, deltas_fns, verbose=False):
db_add_segments(database, segments)

# Save
json.dump(
database,
open(json_fn, 'w'),
sort_keys=True,
indent=4,
separators=(',', ': '))
xjson.pprint(open(json_fn, 'w'), database)


def main():
Expand Down
5 changes: 3 additions & 2 deletions fuzzers/074-dump_all/cleanup_site_pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import sys
import copy

from prjxray import xjson

# 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
# assemble arch defs, so we re-origin the coordinates to be relative to the tile
Expand Down Expand Up @@ -113,8 +115,7 @@ def main():

site_pin['name'] = site_pin['name'][len(orig_site_name) + 1:]

json.dump(output_site_pins, sys.stdout, indent=2)
sys.stdout.write('\n')
xjson.pprint(sys.stdout, output_site_pins)


if __name__ == "__main__":
Expand Down
5 changes: 3 additions & 2 deletions fuzzers/074-dump_all/create_node_tree.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import argparse
import datetime
import progressbar
import json
import os.path
import prjxray.lib
import pickle
import collections

from prjxray import xjson


def build_node_index(fname):
node_index = {}
Expand Down Expand Up @@ -271,7 +272,7 @@ def main():

print('{} Writing node tree'.format(datetime.datetime.now()))
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__':
Expand Down
6 changes: 4 additions & 2 deletions fuzzers/074-dump_all/generate_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import pickle
import sys

from prjxray import xjson


def get_tile_grid_info(fname):
with open(fname, 'r') as f:
Expand Down Expand Up @@ -606,7 +608,7 @@ def main():

print('{} Writing tileconn'.format(datetime.datetime.now()))
with open(tileconn_file, 'w') as f:
json.dump(tileconn, f, indent=2)
xjson.pprint(f, tileconn)
else:
with open(wire_map_file, 'rb') as f:
wire_map = pickle.load(f)
Expand Down Expand Up @@ -651,7 +653,7 @@ def main():
if len(error_nodes) > 0:
error_nodes_file = os.path.join(args.output_dir, 'error_nodes.json')
with open(error_nodes_file, 'w') as f:
json.dump(error_nodes, f, indent=2)
xjson.pprint(f, error_nodes)

ignored_wires = []
ignored_wires_file = args.ignored_wires
Expand Down
5 changes: 3 additions & 2 deletions fuzzers/074-dump_all/reduce_site_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import os
import os.path
import re
import json

from prxray import xjson


def main():
Expand Down Expand Up @@ -55,7 +56,7 @@ def main():
with open(os.path.join(args.output_dir,
'site_type_{}.json'.format(site_type)),
'w') as f:
json.dump(proto_site_type, f, indent=2)
xjson.pprint(f, proto_site_type)


if __name__ == '__main__':
Expand Down
5 changes: 3 additions & 2 deletions fuzzers/074-dump_all/reduce_tile_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import os
import functools

from prxray import xjson

def check_and_strip_prefix(name, prefix):
assert name.startswith(prefix), repr((name, prefix))
Expand Down Expand Up @@ -323,10 +324,10 @@ def main():
with open(os.path.join(
args.output_dir, 'tile_type_{}_site_type_{}.json'.format(
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:
json.dump(reduced_tile, f, indent=2)
xjson.pprint(f, reduced_tile)


if __name__ == '__main__':
Expand Down

0 comments on commit de75899

Please sign in to comment.