eric6/eric6_api.py

Fri, 23 Aug 2019 20:08:33 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 23 Aug 2019 20:08:33 +0200
changeset 7163
00166038bba5
parent 6949
a5255f1ba3f0
child 7192
a22eee00b052
permissions
-rw-r--r--

eric6_api: added the -i switch to ignore the existence of builtin modules when creating API files.

15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 #!/usr/bin/env python3
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6303
diff changeset
4 # Copyright (c) 2003 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5 #
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 """
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3669
diff changeset
8 Eric6 API Generator.
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 This is the main Python script of the API generator. It is
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 this script that gets called via the API generation interface.
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 This script can be used via the commandline as well.
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
15 from __future__ import unicode_literals
3778
0c5bc18da740 Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3697
diff changeset
16
6949
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
17 import os
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
18 import sys
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
19
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
20 sys.path.insert(1, os.path.dirname(__file__))
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
21
4289
6c1ab651c9ce Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
22 import Toolbox.PyQt4ImportHook # __IGNORE_WARNING__
3778
0c5bc18da740 Added more changes to make eric6 usable with PyQt4 as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3697
diff changeset
23
2538
b2642e7a4c18 Fixed a few PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2526
diff changeset
24 try: # Only for Py2
4343
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
25 import Globals.compatibility_fixes # __IGNORE_WARNING__
2526
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
26 except (ImportError):
a91cba8291b9 Minimum modifications to start Eric5 with Py2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
27 pass
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
28
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 import glob
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 import fnmatch
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
6110
a7b096ecf963 Fix for eric6_api to include the path to the EditorConfig package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
32 # make ThirdParty package available as a packages repository
a7b096ecf963 Fix for eric6_api to include the path to the EditorConfig package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
33 sys.path.insert(2, os.path.join(os.path.dirname(__file__),
a7b096ecf963 Fix for eric6_api to include the path to the EditorConfig package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
34 "ThirdParty", "EditorConfig"))
a7b096ecf963 Fix for eric6_api to include the path to the EditorConfig package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
35
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 import Utilities.ModuleParser
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 from DocumentationTools.APIGenerator import APIGenerator
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 from UI.Info import Version
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 import Utilities
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 import DocumentationTools
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 908
diff changeset
42
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 def usage():
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 Function to print some usage information.
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 It prints a reference of all commandline parameters that may
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 be used and ends the application.
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3669
diff changeset
50 print("eric6_api")
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 print()
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6303
diff changeset
52 print("Copyright (c) 2004 - 2019 Detlev Offenbach"
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
53 " <detlev@die-offenbachs.de>.")
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 print()
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 print("Usage:")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 print()
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3669
diff changeset
57 print(" eric6_api [options] files...")
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 print()
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 print("where files can be either python modules, package")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 print("directories or ordinary directories.")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 print()
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 print("Options:")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 print()
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
64 print(" -b name or --base=name")
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 print(" Use the given name as the name of the base package.")
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
66 print(" -e eol-type or --eol=eol-type")
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
67 print(" Use the given eol type to terminate lines.")
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
68 print(" Valid values are 'cr', 'lf' and 'crlf'.")
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
69 print(" --exclude-file=pattern")
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
70 print(" Specify a filename pattern of files to be excluded.")
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
71 print(" This option may be repeated multiple times.")
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 print(" -h or --help")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 print(" Show this help and exit.")
7163
00166038bba5 eric6_api: added the -i switch to ignore the existence of builtin modules when creating API files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6949
diff changeset
74 print(" -i or --ignore")
00166038bba5 eric6_api: added the -i switch to ignore the existence of builtin modules when creating API files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6949
diff changeset
75 print(" Ignore the set of builtin modules")
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
76 print(" -l language or --language=language")
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
77 print(" Generate an API file for the given programming language.")
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
78 print(" Supported programming languages are:")
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
79 for lang in sorted(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
80 DocumentationTools.supportedExtensionsDictForApis.keys()):
2008
1ed291dbd2d5 Fixed an issue causing a wrong help text for eric5_api.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
81 print(" * {0}".format(lang))
1ed291dbd2d5 Fixed an issue causing a wrong help text for eric5_api.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
82 print(" The default is 'Python3'.")
1ed291dbd2d5 Fixed an issue causing a wrong help text for eric5_api.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
83 print(" This option may be repeated multiple times.")
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 print(" -o filename or --output=filename")
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
85 print(" Write the API information to the named file."
5616
adcffadf4962 Reworked some __IGNORE_WARNING__ comments to be more specific.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
86 " A '%L' placeholder") # __IGNORE_WARNING_M601__
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
87 print(" is replaced by the language of the API file"
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
88 " (see --language).")
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 print(" -p or --private")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 print(" Include private methods and functions.")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 print(" -R, -r or --recursive")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 print(" Perform a recursive search for source files.")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 print(" -t ext or --extension=ext")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 print(" Add the given extension to the list of file extensions.")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 print(" This option may be given multiple times.")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 print(" -V or --version")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 print(" Show version information and exit.")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 print(" -x directory or --exclude=directory")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 print(" Specify a directory basename to be excluded.")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 print(" This option may be repeated multiple times.")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 sys.exit(1)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 908
diff changeset
103
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 def version():
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 Function to show the version information.
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
108 print(
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3669
diff changeset
109 """eric6_api {0}\n"""
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
110 """\n"""
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3669
diff changeset
111 """Eric6 API generator.\n"""
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
112 """\n"""
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6303
diff changeset
113 """Copyright (c) 2004 - 2019 Detlev Offenbach"""
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
114 """ <detlev@die-offenbachs.de>\n"""
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
115 """This is free software; see the LICENSE.GPL3 for copying"""
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
116 """ conditions.\n"""
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
117 """There is NO warranty; not even for MERCHANTABILITY or FITNESS"""
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
118 """ FOR A\n"""
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
119 """PARTICULAR PURPOSE.""".format(Version))
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 sys.exit(1)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
122
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 def main():
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 Main entry point into the application.
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 global supportedExtensions
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 import getopt
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 try:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2997
diff changeset
132 opts, args = getopt.getopt(
7163
00166038bba5 eric6_api: added the -i switch to ignore the existence of builtin modules when creating API files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6949
diff changeset
133 sys.argv[1:], "b:e:hil:o:pRrt:Vx:",
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
134 ["base=", "eol=", "exclude=", "exclude-file=", "extension=",
7163
00166038bba5 eric6_api: added the -i switch to ignore the existence of builtin modules when creating API files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6949
diff changeset
135 "help", "ignore", "language=", "output=", "private", "recursive",
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 "version", ])
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 except getopt.error:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 usage()
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139
6303
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6110
diff changeset
140 excludeDirs = [".svn", ".hg", ".git", ".ropeproject", ".eric6project",
ec9ebaf206fb Got rid of the Windows "DotNet"-Hack (i.e. using _ instead of . as first character of special directories).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6110
diff changeset
141 "dist", "build", "doc", "docs"]
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 excludePatterns = []
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 outputFileName = ""
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 recursive = False
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 basePackage = ""
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 includePrivate = False
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 progLanguages = []
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 extensions = []
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
149 newline = None
7163
00166038bba5 eric6_api: added the -i switch to ignore the existence of builtin modules when creating API files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6949
diff changeset
150 ignoreBuiltinModules = False
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 for k, v in opts:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 if k in ["-o", "--output"]:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 outputFileName = v
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 elif k in ["-R", "-r", "--recursive"]:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 recursive = True
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 elif k in ["-x", "--exclude"]:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 excludeDirs.append(v)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 elif k == "--exclude-file":
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 excludePatterns.append(v)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 elif k in ["-h", "--help"]:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 usage()
7163
00166038bba5 eric6_api: added the -i switch to ignore the existence of builtin modules when creating API files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6949
diff changeset
163 elif k in ["-i", "--ignore"]:
00166038bba5 eric6_api: added the -i switch to ignore the existence of builtin modules when creating API files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6949
diff changeset
164 ignoreBuiltinModules = True
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 elif k in ["-V", "--version"]:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 version()
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 elif k in ["-t", "--extension"]:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 if not v.startswith("."):
433
988006cb898f Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
169 v = ".{0}".format(v)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 extensions.append(v)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 elif k in ["-b", "--base"]:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 basePackage = v
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 elif k in ["-p", "--private"]:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 includePrivate = True
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 elif k in ["-l", "--language"]:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 if v not in progLanguages:
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
177 if v not in \
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
178 DocumentationTools.supportedExtensionsDictForApis:
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
179 sys.stderr.write(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
180 "Wrong language given: {0}. Aborting\n".format(v))
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 sys.exit(1)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 else:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 progLanguages.append(v)
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
184 elif k in ["-e", "--eol"]:
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
185 if v.lower() == "cr":
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
186 newline = '\r'
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
187 elif v.lower() == "lf":
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
188 newline = '\n'
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
189 elif v.lower() == "crlf":
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
190 newline = '\r\n'
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 if not args:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 usage()
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 if outputFileName == "":
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 sys.stderr.write("No output file given. Aborting\n")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 sys.exit(1)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 if len(progLanguages) == 0:
40
c2e5472b112c Changed some code to adjust eric5 to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
200 progLanguages = ["Python3"]
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 for progLanguage in sorted(progLanguages):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 basename = ""
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 apis = []
1342
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
205 basesDict = {}
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 supportedExtensions = \
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 DocumentationTools.supportedExtensionsDictForApis[progLanguage]
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 supportedExtensions.extend(extensions)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 if "%L" in outputFileName:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 outputFile = outputFileName.replace("%L", progLanguage)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 else:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 if len(progLanguages) == 1:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 outputFile = outputFileName
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 else:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 root, ext = os.path.splitext(outputFileName)
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
217 outputFile = "{0}-{1}{2}".format(root, progLanguage.lower(),
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
218 ext)
1342
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
219 basesFile = os.path.splitext(outputFile)[0] + '.bas'
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 for arg in args:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 if os.path.isdir(arg):
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2997
diff changeset
223 if os.path.exists(os.path.join(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2997
diff changeset
224 arg, Utilities.joinext("__init__", ".py"))):
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 basename = os.path.dirname(arg)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 if arg == '.':
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 sys.stderr.write("The directory '.' is a package.\n")
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
228 sys.stderr.write(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
229 "Please repeat the call giving its real name.\n")
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 sys.stderr.write("Ignoring the directory.\n")
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 continue
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 else:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 basename = arg
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 if basename:
433
988006cb898f Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
235 basename = "{0}{1}".format(basename, os.sep)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 if recursive and not os.path.islink(arg):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 names = [arg] + Utilities.getDirs(arg, excludeDirs)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 else:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 names = [arg]
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 else:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 basename = ""
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 names = [arg]
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 for filename in sorted(names):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 inpackage = False
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 if os.path.isdir(filename):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 files = []
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 for ext in supportedExtensions:
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
250 files.extend(glob.glob(os.path.join(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
251 filename, Utilities.joinext("*", ext))))
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
252 initFile = os.path.join(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
253 filename, Utilities.joinext("__init__", ext))
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 if initFile in files:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 inpackage = True
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 files.remove(initFile)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 files.insert(0, initFile)
788
5b1b59777460 Added a feature where flags can be given at the end of a source file. The only flag supported is 'FileType' to overwrite the filetype detection mechanism.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 433
diff changeset
258 elif progLanguage != "Python3":
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 # assume package
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 inpackage = True
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 else:
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
262 if Utilities.isWindowsPlatform() and \
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
263 glob.has_magic(filename):
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 files = glob.glob(filename)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 else:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 files = [filename]
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 for file in files:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 skipIt = False
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 for pattern in excludePatterns:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 if fnmatch.fnmatch(os.path.basename(file), pattern):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 skipIt = True
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 break
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 if skipIt:
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 continue
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 try:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2997
diff changeset
278 module = Utilities.ModuleParser.readModule(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2997
diff changeset
279 file,
7163
00166038bba5 eric6_api: added the -i switch to ignore the existence of builtin modules when creating API files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6949
diff changeset
280 basename=basename, inpackage=inpackage,
00166038bba5 eric6_api: added the -i switch to ignore the existence of builtin modules when creating API files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6949
diff changeset
281 ignoreBuiltinModules=ignoreBuiltinModules)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 apiGenerator = APIGenerator(module)
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
283 api = apiGenerator.genAPI(True, basePackage,
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
284 includePrivate)
1342
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
285 bases = apiGenerator.genBases(includePrivate)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 except IOError as v:
433
988006cb898f Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
287 sys.stderr.write("{0} error: {1}\n".format(file, v[1]))
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 continue
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 except ImportError as v:
433
988006cb898f Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
290 sys.stderr.write("{0} error: {1}\n".format(file, v))
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 continue
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 for apiEntry in api:
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
294 if apiEntry not in apis:
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 apis.append(apiEntry)
1342
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
296 for basesEntry in bases:
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
297 if bases[basesEntry]:
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
298 basesDict[basesEntry] = bases[basesEntry][:]
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
299 sys.stdout.write("-- {0} -- {1} ok\n".format(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
300 progLanguage, file))
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 outdir = os.path.dirname(outputFile)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 if outdir and not os.path.exists(outdir):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 os.makedirs(outdir)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 try:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 908
diff changeset
306 out = open(outputFile, "w", encoding="utf-8", newline=newline)
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
307 out.write("\n".join(sorted(apis)) + "\n")
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 out.close()
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 except IOError as v:
433
988006cb898f Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
310 sys.stderr.write("{0} error: {1}\n".format(outputFile, v[1]))
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 sys.exit(3)
1342
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
312 try:
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
313 out = open(basesFile, "w", encoding="utf-8", newline=newline)
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
314 for baseEntry in sorted(basesDict.keys()):
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
315 out.write("{0} {1}\n".format(
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
316 baseEntry, " ".join(sorted(basesDict[baseEntry]))))
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
317 out.close()
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
318 except IOError as v:
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
319 sys.stderr.write("{0} error: {1}\n".format(basesFile, v[1]))
30226d5a7ffb Added code to write base class information to be used by the eric assistant plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
320 sys.exit(3)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 sys.stdout.write('\nDone.\n')
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 sys.exit(0)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 if __name__ == '__main__':
18
3b1f5d872fd7 More renaming to eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
326 main()
4566
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4543
diff changeset
327
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4543
diff changeset
328 #
a2e8f3c420ec Dealt with the M801 code style checker messages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4543
diff changeset
329 # eflag: noqa = M801

eric ide

mercurial