Beispiel #1
0
def main(argv):
    # Using local path for gtkscintilla2 so don't default to checking
    checkGTK = False
    cleanGenerated = False
    qtStyleInterface = True
    # The --gtk-check option checks for full coverage of the gtkscintilla2 API but
    # depends on a particular directory so is not mentioned in --help.
    opts, args = getopt.getopt(
        argv, "hcgu", ["help", "clean", "gtk-check", "underscore-names"])
    for opt, arg in opts:
        if opt in ("-h", "--help"):
            usage()
            sys.exit()
        elif opt in ("-c", "--clean"):
            cleanGenerated = True
        elif opt in ("-g", "--gtk-check"):
            checkGTK = True
        elif opt in ("-u", "--underscore-names"):
            qtStyleInterface = False

    options = {"qtStyle": qtStyleInterface}
    f = readInterface(cleanGenerated)
    try:
        GenerateFile("ScintillaEdit.cpp.template", "ScintillaEdit.cpp", "/* ",
                     True, printCPPFile(f, options))
        GenerateFile("ScintillaEdit.h.template", "ScintillaEdit.h", "/* ",
                     True, printHFile(f, options))
        GenerateFile("../ScintillaEditPy/ScintillaConstants.py.template",
                     "../ScintillaEditPy/ScintillaConstants.py", "# ", True,
                     printPyFile(f, options))
        if checkGTK:
            names = set(methodNames(f))
            #~ print("\n".join(names))
            namesGtk = set(gtkNames())
            for name in namesGtk:
                if name not in names:
                    print(name, "not found in Qt version")
            for name in names:
                if name not in namesGtk:
                    print(name, "not found in GTK+ version")
    except:
        raise

    if cleanGenerated:
        for file in [
                "ScintillaEdit.cpp", "ScintillaEdit.h",
                "../ScintillaEditPy/ScintillaConstants.py"
        ]:
            try:
                os.remove(file)
            except OSError:
                pass
	def generateAPI(self, args):
		os.chdir(os.path.join("..", "ScintillaEdit"))
		if not self.qtStyleInterface:
			args.insert(0, '--underscore-names')
		WidgetGen.main(args)
		f = WidgetGen.readInterface(False)
		os.chdir(os.path.join("..", "ScintillaEditPy"))
		options = {"qtStyle": self.qtStyleInterface}
		GenerateFile("typesystem_ScintillaEdit.xml.template", "typesystem_ScintillaEdit.xml",
			"<!-- ", True, printTypeSystemFile(f, options))