File: split-file.py

package info (click to toggle)
pytables 3.10.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,228 kB
  • sloc: ansic: 82,212; python: 65,296; cpp: 753; sh: 394; makefile: 100
file content (39 lines) | stat: -rw-r--r-- 1,161 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
Split out a monolithic file with many different runs of
indexed_search.py. The resulting files are meant for use in
get-figures.py.

Usage: python split-file.py prefix filename
"""

import sys
from pathlib import Path

prefix = sys.argv[1]
filename = sys.argv[2]
sf = None
for line in Path(filename).read_text().splitlines():
    if line.startswith("Processing database:"):
        if sf:
            sf.close()
        line2 = line.split(":")[1]
        # Check if entry is compressed and if has to be processed
        line2 = line2[: line2.rfind(".")]
        params = line2.split("-")
        optlevel = 0
        complib = None
        for param in params:
            if param[0] == "O" and param[1].isdigit():
                optlevel = int(param[1])
            elif param[:-1] in ("zlib", "lzo"):
                complib = param
        if "PyTables" in prefix:
            if complib:
                sfilename = f"{prefix}-O{optlevel}-{complib}.out"
            else:
                sfilename = f"{prefix}-O{optlevel}.out"
        else:
            sfilename = f"{prefix}.out"
        sf = open(sfilename, "a")
    if sf:
        sf.write(line)