summaryrefslogtreecommitdiffstats
path: root/Utilities/Sphinx/create_identifiers.py
blob: 4db7a3f68aa8bb40e1806a8d019e4b9563fc1b0a (plain)
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
#!/usr/bin/env python

import sys, os

if len(sys.argv) != 2:
  sys.exit(-1)
name = sys.argv[1] + "/CMake.qhp"

f = open(name)

if not f:
  sys.exit(-1)

lines = f.read().splitlines()

if not lines:
  sys.exit(-1)

newlines = []

for line in lines:
  if "<keyword name=\"command\"" in line:
    if not "id=\"" in line:
      prefix = "<keyword name=\"command\" "
      part1, part2 = line.split(prefix)
      head, tail = part2.split("#command:")
      cmdname, rest = tail.split("\"")
      line = part1 + prefix + "id=\"command/" + cmdname + "\" " + part2
  newlines.append(line + "\n")

f = open(name, "w")
f.writelines(newlines)