2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-23 11:28:56 +00:00
qpdf/qpdf
Jay Berkenbilt a9fbbd5dca 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))
----------
2022-05-07 08:26:31 -04:00
..
qtest Objectinfo json: write incrementally and in numeric order 2022-05-07 08:26:31 -04:00
CMakeLists.txt Make assert handling less error-prone 2022-05-03 18:31:22 -04:00
fix-qdf.cc Formatting: remove space in range-style for loops 2022-04-30 13:26:43 -04:00
pdf_from_scratch.cc Use fluent replaceKey 2022-04-29 20:39:54 -04:00
qpdf-ctest.c Make assert handling less error-prone 2022-05-03 18:31:22 -04:00
qpdf.cc Programmatically apply new formatting to code 2022-04-04 08:10:40 -04:00
qpdf.testcov Mark weak encryption with API changes (fixes #576) 2022-04-30 17:24:15 -04:00
qpdfjob-ctest.c Make assert handling less error-prone 2022-05-03 18:31:22 -04:00
sizes.cc Add new Pl_String Pipeline 2022-05-03 18:54:51 -04:00
test_driver.cc Add next to Pl_String and fix comments 2022-05-07 08:26:31 -04:00
test_large_file.cc Make Pipeline::write take an unsigned char const* (API change) 2022-05-03 18:31:22 -04:00
test_parsedoffset.cc Code clean up: use range-style for loops wherever possible 2022-04-30 13:27:18 -04:00
test_pdf_doc_encoding.cc Code clean up: use range-style for loops wherever possible 2022-04-30 13:27:18 -04:00
test_pdf_unicode.cc Code clean up: use range-style for loops wherever possible 2022-04-30 13:27:18 -04:00
test_renumber.cc Code clean up: use range-style for loops wherever possible 2022-04-30 13:27:18 -04:00
test_shell_glob.cc Programmatically apply new formatting to code 2022-04-04 08:10:40 -04:00
test_tokenizer.cc Add new FileInputSource constructors 2022-05-04 12:07:11 -04:00
test_unicode_filenames.cc Programmatically apply new formatting to code 2022-04-04 08:10:40 -04:00
test_xref.cc Code clean up: use range-style for loops wherever possible 2022-04-30 13:27:18 -04:00