File: colspec.py

package info (click to toggle)
debian-reference 2.131
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 33,684 kB
  • sloc: python: 586; makefile: 574; sh: 528; sed: 80
file content (107 lines) | stat: -rwxr-xr-x 4,387 bytes parent folder | download | duplicates (3)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python3
# vim: set sw=4 sts=4 expandtab:

"""
colspec.py - set colspec in XML to correct values

Copyright (C) 2009 Osamu Aoki, GPL
"""

import sys
import re

VERSION = "1.0.1"

if __name__ == "__main__":
    table_id = ""
    tgroup_cols = 0

    for line in sys.stdin.readlines():
        line = line[0:-1]
        if re.match('.*table id="', line):
            table_id = re.sub(r'.*table id="([^"]*)".*', r"\1", line)
        #            print "table id =" + table_id
        elif re.match(".*<title>", line):
            title = re.sub(r".*<title>([^<]*)</title>.*", r"\1", line)
        #            print "title =" + title
        elif re.match('.*tgroup cols="', line):
            tgroup_cols = int(re.sub(r'.*tgroup cols="([^"]*)".*', r"\1", line))
            #            print "tgroup_cols =", tgroup_cols
            cols = 0
            if tgroup_cols == 2:
                colwidth = (40, 60)
            elif tgroup_cols == 3:
                colwidth = (30, 30, 40)
            elif tgroup_cols == 4:
                colwidth = (20, 12, 6, 62)
            elif tgroup_cols == 5:
                colwidth = (20, 12, 6, 12, 50)
            elif tgroup_cols == 6:
                colwidth = (20, 12, 6, 12, 12, 38)
            elif tgroup_cols == 7:
                colwidth = (20, 12, 6, 12, 12, 12, 26)
            elif tgroup_cols == 8:
                colwidth = (20, 12, 6, 6, 6, 6, 6, 26)
            # List of exceptions
            if table_id == "thenumericmodefoinchmodbcommands":
                colwidth = (20, 80)
            elif table_id == "listofnotablesysupsforfileaccess":
                colwidth = (20, 80)
            elif table_id == "listofnotablesysommandexecutions":
                colwidth = (20, 80)
            elif table_id == "listoftypesoftimestamps":
                colwidth = (20, 80)
            elif table_id == "listofnotablesysupsforfileaccess":
                colwidth = (20, 80)
            elif table_id == "listofnotablepinpinningtechnique":
                colwidth = (20, 80)
            elif table_id == "listofkeyboardreigurationmethods":
                colwidth = (20, 80)
            elif table_id == "listoffilesystemalusagescenarios":
                colwidth = (20, 80)
            elif table_id == "thereplacementexpression":
                colwidth = (30, 70)
            elif table_id == "thekeybindingsofmc":
                colwidth = (30, 70)
            elif table_id == "listofkeywebsiteaspecificpackage":
                colwidth = (30, 70)
            elif table_id == "listofspecialdevicefiles":
                colwidth = (30, 20, 50)
            elif table_id == "listofdebianarchivearea":
                colwidth = (20, 20, 60)
            elif table_id == "listofviewsforaptitude":
                colwidth = (20, 20, 60)
            elif table_id == "listofrunlevelsationoftheirusage":
                colwidth = (20, 20, 60)
            elif table_id == "listofsshauthenttocolsandmethods":
                colwidth = (20, 40, 40)
            elif table_id == "listofterminologornetworkdevices":
                colwidth = (20, 20, 25, 35)
            elif table_id == "tableofkeywordsundicatefonttypes":
                colwidth = (25, 25, 25, 25)
            elif table_id == "listofinsecureanservicesandports":
                colwidth = (25, 25, 25, 25)
            elif table_id == "therelationshipbsuiteandcodename":
                colwidth = (25, 25, 25, 25)
            elif table_id == "theumaskvalueexamples":
                colwidth = (20, 25, 25, 30)
            elif table_id == "dimportantconfigilesforpam_unixi":
                colwidth = (20, 20, 10, 10, 40)
            elif table_id == "listoftoolstogeneratepassword":
                colwidth = (15, 15, 10, 15, 45)
            elif table_id == "listofnetworkaddressranges":
                colwidth = (10, 40, 30, 10, 10)

        if re.match('.*table pgwide="', line):
            print(re.sub(r'(.*table pgwide=)"0"(.*)', r'\1"1"\2', line))
        elif re.match('.*colspec colwidth="', line):
            x = str(colwidth[cols])
            cols += 1
            print(
                re.sub(r'(.*colspec colwidth=").*', r"\1", line)
                + str(x)
                + "*"
                + re.sub(r'.*colspec colwidth="[^"]*(".*)', r"\1", line)
            )
        else:
            print(line)