File: fix-features-fea.py

package info (click to toggle)
fonts-sahel 3.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,552 kB
  • sloc: python: 109; sh: 76; makefile: 4
file content (30 lines) | stat: -rwxr-xr-x 725 bytes parent folder | download
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
#!/usr/bin/env python3
import sys


def fix_line(line):
    trimmed_line = line.strip()
    if not trimmed_line.startswith(r"pos \uni"):
        return line

    if trimmed_line.endswith("< 0 0 0 0 >;"):
        return ""

    parts = list(filter(lambda x: x != "", trimmed_line.split(" ")))
    if len(parts) != 11:
        return line

    return " ".join(
        [parts[0], parts[1], parts[6]] + parts[-4:])+"\n"


if __name__ == "__main__":
    if len(sys.argv) < 3:
        print("You should enter <input> and <output> file path")
        sys.exit(1)

    with open(sys.argv[1]) as f:
        input_lines = f.readlines()

    with open(sys.argv[2], 'w') as f:
        f.write("".join(list(map(fix_line, input_lines))))