cbe6d70855
The content of this branch was automatically imported from Fedora ELN with the following as its source: https://src.fedoraproject.org/rpms/ca-certificates#5221e001cb29e491c529e5d5e8c1d26c84f4d9b4
35 lines
828 B
Python
35 lines
828 B
Python
#!/usr/bin/python3
|
|
|
|
# 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)
|