From c10044ddc0363b5cdcd0a449c15b151747649c21 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Tue, 8 Jan 2013 21:39:24 +0100 Subject: [PATCH] Add consistency checks. development/tools/generate_symbols_images.py now checks for each symbol in lib/symbols whether its image is listed in lib/Makefile.am and whether it has a toolbar entry in lib/ui/stdtoolbars.inc. --- development/tools/generate_symbols_images.py | 45 ++++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/development/tools/generate_symbols_images.py b/development/tools/generate_symbols_images.py index 7787e5d253..a043c9c94e 100644 --- a/development/tools/generate_symbols_images.py +++ b/development/tools/generate_symbols_images.py @@ -75,7 +75,30 @@ def getreplacements(filename): found = True -def createimage(name, path, template, lyxexe, tempdir, replacements): +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 + + +def createimage(name, path, template, lyxexe, tempdir, replacements, toolbaritems, makefileentries): """ Create the image file for symbol name in path. """ if name in replacements.keys(): @@ -91,10 +114,20 @@ def createimage(name, path, template, lyxexe, tempdir, replacements): return filename = name pngname = os.path.join(path, filename + '.png') + if name in toolbaritems: + if filename in makefileentries: + suffix = ' (found in toolbar and makefile)' + else: + suffix = ' (found in only in toolbar)' + else: + if filename in makefileentries: + suffix = ' (found only in makefile)' + else: + suffix = ' (not found)' if os.path.exists(pngname): - print 'Skipping ' + name + print 'Skipping ' + name + suffix return - print 'Generating ' + name + print 'Generating ' + name + suffix lyxname = os.path.join(tempdir, filename) lyxfile = open(lyxname + '.lyx', 'wt') lyxfile.write(template.replace('$a$', '$\\' + name + '$')) @@ -140,13 +173,17 @@ def main(argv): symbols = getlist(argv[1], base) cppfile = os.path.join(os.path.dirname(base), '../../src/frontends/qt4/GuiApplication.cpp') replacements = getreplacements(cppfile) + uifile = os.path.join(os.path.dirname(base), '../../lib/ui/stdtoolbars.inc') + toolbaritems = gettoolbaritems(uifile) + makefile = os.path.join(os.path.dirname(base), '../../lib/Makefile.am') + makefileentries = getmakefileentries(makefile) lyxtemplate = base + '.lyx' templatefile = open(base + '.lyx', 'rt') template = templatefile.read() templatefile.close() tempdir = tempfile.mkdtemp() for i in symbols: - createimage(i, argv[2], template, argv[1], tempdir, replacements) + createimage(i, argv[2], template, argv[1], tempdir, replacements, toolbaritems, makefileentries) shutil.rmtree(tempdir) else: error(usage(argv[0])) -- 2.39.2