diff -r 9986ec0e559a -r 10516539f238 eric5_api.py --- a/eric5_api.py Tue Oct 15 22:03:54 2013 +0200 +++ b/eric5_api.py Fri Oct 18 23:00:41 2013 +0200 @@ -5,7 +5,7 @@ # """ -Eric5 API Generator +Eric5 API Generator. This is the main Python script of the API generator. It is this script that gets called via the API generation interface. @@ -42,7 +42,8 @@ """ print("eric5_api") print() - print("Copyright (c) 2004 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>.") + print("Copyright (c) 2004 - 2013 Detlev Offenbach" + " <detlev@die-offenbachs.de>.") print() print("Usage:") print() @@ -66,13 +67,16 @@ print(" -l language or --language=language") print(" Generate an API file for the given programming language.") print(" Supported programming languages are:") - for lang in sorted(DocumentationTools.supportedExtensionsDictForApis.keys()): + for lang in sorted( + DocumentationTools.supportedExtensionsDictForApis.keys()): print(" * {0}".format(lang)) print(" The default is 'Python3'.") print(" This option may be repeated multiple times.") print(" -o filename or --output=filename") - print(" Write the API information to the named file. A '%L' placeholder") - print(" is replaced by the language of the API file (see --language).") + print(" Write the API information to the named file." + " A '%L' placeholder") + print(" is replaced by the language of the API file" + " (see --language).") print(" -p or --private") print(" Include private methods and functions.") print(" -R, -r or --recursive") @@ -113,14 +117,15 @@ try: opts, args = getopt.getopt(sys.argv[1:], "b:e:hl:o:pRrt:Vx:", - ["base=", "eol=", "exclude=", "exclude-file=", "extension=", "help", - "language=", "output=", "private", "recursive", + ["base=", "eol=", "exclude=", "exclude-file=", "extension=", + "help", "language=", "output=", "private", "recursive", "version", ]) except getopt.error: usage() excludeDirs = ["CVS", ".svn", "_svn", ".ropeproject", "_ropeproject", - ".eric5project", "_eric5project", "dist", "build", "doc", "docs"] + ".eric5project", "_eric5project", "dist", "build", "doc", + "docs"] excludePatterns = [] outputFileName = "" recursive = False @@ -154,8 +159,9 @@ elif k in ["-l", "--language"]: if v not in progLanguages: if v not in \ - list(DocumentationTools.supportedExtensionsDictForApis.keys()): - sys.stderr.write("Wrong language given: {0}. Aborting\n".format(v)) + DocumentationTools.supportedExtensionsDictForApis: + sys.stderr.write( + "Wrong language given: {0}. Aborting\n".format(v)) sys.exit(1) else: progLanguages.append(v) @@ -192,17 +198,19 @@ outputFile = outputFileName else: root, ext = os.path.splitext(outputFileName) - outputFile = "{0}-{1}{2}".format(root, progLanguage.lower(), ext) + outputFile = "{0}-{1}{2}".format(root, progLanguage.lower(), + ext) basesFile = os.path.splitext(outputFile)[0] + '.bas' for arg in args: if os.path.isdir(arg): if os.path.exists(os.path.join(arg, - Utilities.joinext("__init__", ".py"))): + Utilities.joinext("__init__", ".py"))): basename = os.path.dirname(arg) if arg == '.': sys.stderr.write("The directory '.' is a package.\n") - sys.stderr.write("Please repeat the call giving its real name.\n") + sys.stderr.write( + "Please repeat the call giving its real name.\n") sys.stderr.write("Ignoring the directory.\n") continue else: @@ -223,10 +231,10 @@ if os.path.isdir(filename): files = [] for ext in supportedExtensions: - files.extend(glob.glob(os.path.join(filename, - Utilities.joinext("*", ext)))) - initFile = os.path.join(filename, - Utilities.joinext("__init__", ext)) + files.extend(glob.glob(os.path.join( + filename, Utilities.joinext("*", ext)))) + initFile = os.path.join( + filename, Utilities.joinext("__init__", ext)) if initFile in files: inpackage = True files.remove(initFile) @@ -235,7 +243,8 @@ # assume package inpackage = True else: - if Utilities.isWindowsPlatform() and glob.has_magic(filename): + if Utilities.isWindowsPlatform() and \ + glob.has_magic(filename): files = glob.glob(filename) else: files = [filename] @@ -253,7 +262,8 @@ module = Utilities.ModuleParser.readModule(file, basename=basename, inpackage=inpackage) apiGenerator = APIGenerator(module) - api = apiGenerator.genAPI(True, basePackage, includePrivate) + api = apiGenerator.genAPI(True, basePackage, + includePrivate) bases = apiGenerator.genBases(includePrivate) except IOError as v: sys.stderr.write("{0} error: {1}\n".format(file, v[1])) @@ -268,7 +278,8 @@ for basesEntry in bases: if bases[basesEntry]: basesDict[basesEntry] = bases[basesEntry][:] - sys.stdout.write("-- {0} -- {1} ok\n".format(progLanguage, file)) + sys.stdout.write("-- {0} -- {1} ok\n".format( + progLanguage, file)) outdir = os.path.dirname(outputFile) if outdir and not os.path.exists(outdir):