Search
SailfishOS Open Build Service
>
Projects
>
home:nephros
:
hw
:
j1
>
ca-certificates-new
> sort-blocks.py
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File sort-blocks.py of Package ca-certificates-new
#!/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)