src/eric7/eric7_api.py

branch
eric7
changeset 10298
a148416e7e7d
parent 10295
e0e7f81cc164
child 10303
ee1aadab1215
equal deleted inserted replaced
10297:019045db2bec 10298:a148416e7e7d
36 description=( 36 description=(
37 "Create API files to be used by 'QScintilla' or the 'eric Assistant'" 37 "Create API files to be used by 'QScintilla' or the 'eric Assistant'"
38 " plugin." 38 " plugin."
39 ), 39 ),
40 epilog="Copyright (c) 2004 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>.", 40 epilog="Copyright (c) 2004 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>.",
41 add_help=False,
42 ) 41 )
43 42
44 parser.add_argument( 43 parser.add_argument(
45 "file", 44 "file",
46 nargs="*", 45 nargs="+",
47 help="'file' can be either python modules, package directories or ordinary" 46 help="'file' can be either python modules, package directories or ordinary"
48 " directories. At least one 'file' argument must be given.", 47 " directories. At least one 'file' argument must be given.",
49 ) 48 )
50 parser.add_argument( 49 parser.add_argument(
51 "-b", 50 "-b",
63 "--exclude-file", 62 "--exclude-file",
64 action="append", 63 action="append",
65 default=[], 64 default=[],
66 help="Specify a filename pattern of files to be excluded. This option may be" 65 help="Specify a filename pattern of files to be excluded. This option may be"
67 " repeated multiple times.", 66 " repeated multiple times.",
68 )
69 parser.add_argument(
70 "-h", "--help", action="store_true", help="Show this help and exit."
71 ) 67 )
72 parser.add_argument( 68 parser.add_argument(
73 "-i", 69 "-i",
74 "--ignore", 70 "--ignore",
75 action="store_true", 71 action="store_true",
88 "-o", 84 "-o",
89 "--output", 85 "--output",
90 default="", 86 default="",
91 help="Write the API information to the named file. A '%%L'" # noqa: M601 87 help="Write the API information to the named file. A '%%L'" # noqa: M601
92 " placeholder is replaced by the language of the API file (see --language).", 88 " placeholder is replaced by the language of the API file (see --language).",
89 required=True,
93 ) 90 )
94 parser.add_argument( 91 parser.add_argument(
95 "-p", 92 "-p",
96 "--private", 93 "--private",
97 action="store_true", 94 action="store_true",
113 " be given multiple times.", 110 " be given multiple times.",
114 ) 111 )
115 parser.add_argument( 112 parser.add_argument(
116 "-V", 113 "-V",
117 "--version", 114 "--version",
118 action="store_true", 115 action="version",
116 version="%(prog)s {0}".format(Version),
119 help="Show version information and exit.", 117 help="Show version information and exit.",
120 ) 118 )
121 parser.add_argument( 119 parser.add_argument(
122 "-x", 120 "-x",
123 "--exclude", 121 "--exclude",
128 ) 126 )
129 127
130 return parser 128 return parser
131 129
132 130
133 def version():
134 """
135 Function to show the version information.
136 """
137 print(
138 """eric7_api {0}\n"""
139 """\n"""
140 """eric API generator.\n"""
141 """\n"""
142 """Copyright (c) 2004 - 2023 Detlev Offenbach"""
143 """ <detlev@die-offenbachs.de>\n"""
144 """This is free software; see LICENSE.txt for copying"""
145 """ conditions.\n"""
146 """There is NO warranty; not even for MERCHANTABILITY or FITNESS"""
147 """ FOR A\n"""
148 """PARTICULAR PURPOSE.""".format(Version)
149 )
150
151
152 def main(): 131 def main():
153 """ 132 """
154 Main entry point into the application. 133 Main entry point into the application.
155 """ 134 """
156 global supportedExtensions 135 global supportedExtensions
157 136
158 parser = createArgumentParser() 137 parser = createArgumentParser()
159 args = parser.parse_args() 138 args = parser.parse_args()
160
161 if args.help:
162 parser.print_help()
163 sys.exit(1)
164 elif args.version:
165 version()
166 sys.exit(1)
167
168 if not args.file:
169 parser.error(
170 "At least one file, Python module, Python package or directory must be"
171 " given."
172 )
173
174 if not args.output:
175 parser.error("No output file given.")
176 139
177 excludeDirs = [ 140 excludeDirs = [
178 ".svn", 141 ".svn",
179 ".hg", 142 ".hg",
180 ".git", 143 ".git",

eric ide

mercurial