ca-certificates/sort-blocks.py
Kai Engert f0b0be2c1f - Changed the packaged bundle to use the flexible p11-kit-object-v1 file format,
as a preparation to fix bugs in the interaction between p11-kit-trust and
  Mozilla applications, such as Firefox, Thunderbird etc.
- Changed update-ca-trust to add comments to extracted PEM format files.
- Added an utility to help with comparing output of the trust dump command.
2017-02-13 21:04:08 +01:00

35 lines
825 B
Python

#!/usr/bin/python
# Expected input is a file, where blocks of lines are separated by newline.
# Blocks will be sorted.
# Intention is to prepare files for comparison, were lines inside each block are
# in stable order, but the order of blocks is random.
import sys
import string
if (len(sys.argv) != 2):
print "syntax: " + sys.argv[0] + " input-filename"
sys.exit(1)
filename = sys.argv[1]
block = []
block_list = []
with open(filename, 'r') as f:
for line in f:
if (len(line) == 1):
if len(block) == 0:
continue
else:
combined_string = string.join(block, '')
block_list.append(combined_string)
block = []
else:
block.append(line)
block_list.sort()
for block in block_list:
print block