diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-05-07 01:08:31 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-05-07 14:26:31 +0200 |
commit | a9fbbd5dca1f39e9eafc8ddf8ada30dffd68e4df (patch) | |
tree | f5b141539d5972280958b4aa03f9492e17cb4f54 /examples/qtest/bookmarks/test.--show-open.x.out | |
parent | 948de609900745835656d4566a90fee64c5343da (diff) | |
download | qpdf-a9fbbd5dca1f39e9eafc8ddf8ada30dffd68e4df.tar.zst |
Objectinfo json: write incrementally and in numeric order
This script was used on test data:
----------
#!/usr/bin/env python3
import json
import sys
import re
def json_dumps(data):
return json.dumps(data, ensure_ascii=False,
indent=2, separators=(',', ': '))
for filename in sys.argv[1:]:
with open(filename, 'r') as f:
data = json.loads(f.read())
if 'objectinfo' not in data:
continue
trailer = None
to_sort = []
for k, v in data['objectinfo'].items():
if k == 'trailer':
trailer = v
else:
m = re.match(r'^(\d+) \d+ R', k)
if m:
to_sort.append([int(m.group(1)), k, v])
newobjectinfo = {x[1]: x[2] for x in sorted(to_sort)}
if trailer is not None:
newobjectinfo['trailer'] = trailer
data['objectinfo'] = newobjectinfo
print(json_dumps(data))
----------
Diffstat (limited to 'examples/qtest/bookmarks/test.--show-open.x.out')
0 files changed, 0 insertions, 0 deletions