+ if m.group(4) == 'textmode':
+ textsymbols.append(m.group(1))
+ else:
+ mathsymbols.append(m.group(1))
+ return (mathsymbols, textsymbols)
+
+
+def getreplacements(filename):
+ replacements = {}
+ replacements['|'] = 'vert'
+ replacements['/'] = 'slash'
+ replacements['\\'] = 'backslash'
+ replacements['*'] = 'ast'
+ replacements['AA'] = 'textrm_AA'
+ replacements['O'] = 'textrm_O'
+ cppfile = open(filename, 'rt')
+ regexp = re.compile(r'.*"([^"]+)",\s*"([^"]+)"')
+ found = False
+ for line in cppfile.readlines():
+ if found:
+ m = regexp.match(line)
+ if m:
+ replacements[m.group(1)] = m.group(2)
+ else:
+ return replacements
+ elif line.find('PngMap sorted_png_map') == 0:
+ found = True
+
+
+def gettoolbaritems(filename):
+ items = []
+ uifile = open(filename, 'rt')
+ regexp = re.compile(r'.*Item "([^"\[]+)(\[\[[^\]]+\]\])?"\s*"math-insert\s+([^"]+)"')
+ for line in uifile.readlines():
+ m = regexp.match(line)
+ if m:
+ if '\\' + m.group(1) == m.group(3):
+ items.append(m.group(1))
+ return items
+
+
+def getmakefileentries(filename):
+ items = []
+ makefile = open(filename, 'rt')
+ regexp = re.compile(r'.*images/math/(.+)\.png')
+ for line in makefile.readlines():
+ m = regexp.match(line)
+ if m:
+ items.append(m.group(1))
+ return items