diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-05-07 01:04:20 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-05-07 14:26:31 +0200 |
commit | 948de609900745835656d4566a90fee64c5343da (patch) | |
tree | e4862655453cc6213f2a1713fc1548462a38a8df /libtests/qtest/aes/data2 | |
parent | f50274ef4660cb21177937ff49c9d11675cef8a9 (diff) | |
download | qpdf-948de609900745835656d4566a90fee64c5343da.tar.zst |
Objects json: write incrementally and in numeric order
The following script was used to adjust 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 'objects' not in data:
continue
trailer = None
to_sort = []
for k, v in data['objects'].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])
newobjects = {x[1]: x[2] for x in sorted(to_sort)}
if trailer is not None:
newobjects['trailer'] = trailer
data['objects'] = newobjects
print(json_dumps(data))
----------
Diffstat (limited to 'libtests/qtest/aes/data2')
0 files changed, 0 insertions, 0 deletions