QGIS/scripts/process_contexthelp.py

25 lines
734 B
Python
Raw Normal View History

2015-12-19 15:09:09 +01:00
import os
import glob
import sys
cpp = open(sys.argv[1], "w")
cpp.write(
"#include \"qgscontexthelp.h\"\n"
"#include <QCoreApplication>\n\n"
"QHash<QString, QString> QgsContextHelp::gContextHelpTexts;\n"
"\n"
"void QgsContextHelp::init()\n"
"{\n"
" if( !gContextHelpTexts.isEmpty() )\n"
" return;\n"
)
for f in sorted(glob.glob('resources/context_help/*')):
n = os.path.basename(f)
with open(f) as content:
cpp.write("\n gContextHelpTexts.insert( \"{0}\", QCoreApplication::translate( \"context_help\", \"{1}\") );".format(
n, content.read().replace("\\", "&#92;").replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n"\n\"')))
cpp.write("\n}\n")
cpp.close()