Sun, 19 May 2024 17:20:16 +0200
Relocated the Version information into a top level '__version__.py' module.
10308
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10308
diff
changeset
|
3 | # Copyright (c) 2023 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
10308
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a function to create an argparse.Namespace object for the web |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | browser. |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | """ |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | import argparse |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | import sys |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | def createArgparseNamespace(argv=None): |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | """ |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | Function to create an argparse.Namespace object. |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | @param argv list of command line arguments to be parsed |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | @type list of str |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | @return created argument parser object |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | @rtype argparse.ArgumentParser |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | """ |
10716
11cdcc824469
Relocated the Version information into a top level '__version__.py' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
24 | from eric7.__version__ import Version |
10308
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | # 1. create the argument parser |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | parser = argparse.ArgumentParser( |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | description="Web Browser application of the eric tool suite.", |
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10308
diff
changeset
|
29 | epilog="Copyright (c) 2002 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>.", |
10308
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | ) |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | # 2. add the arguments |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | parser.add_argument( |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | "-V", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | "--version", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | action="version", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | version="%(prog)s {0}".format(Version), |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | help="show version information and exit", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | ) |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | parser.add_argument( |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | "--config", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | metavar="config_dir", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | help="use the given directory as the one containing the config files", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | ) |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | parser.add_argument( |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | "--settings", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | metavar="settings_dir", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | help="use the given directory to store the settings files", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | ) |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | parser.add_argument( |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | "--name", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | metavar="browser name", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | default="", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | help="name to be used for the browser instance", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | ) |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | parser.add_argument( |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | "--new-tab", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | metavar="URL", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | action="append", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | help="open a new tab for the given URL", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | ) |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | parser.add_argument( |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | "--private", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | action="store_true", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | help="start the browser in private browsing mode", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | ) |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | parser.add_argument( |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | "--qthelp", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | action="store_true", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | help="start the browser with support for QtHelp", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | ) |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | parser.add_argument( |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | "--quiet", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | action="store_true", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | help="don't show any startup error messages", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | ) |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | parser.add_argument( |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | "--search", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | metavar="searchword", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | help="search for the given word", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | ) |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | parser.add_argument( |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | "--shutdown", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | action="store_true", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | help="shut down the browser instance", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | ) |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | parser.add_argument( |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | "--single", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | action="store_true", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | help="start the browser as a single application", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | ) |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | parser.add_argument( |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | "home", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | nargs="?", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | default="", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | metavar="file | URL", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | help="open a file or URL", |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | ) |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | # 3. create the Namespace object by parsing the command line |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | if argv is None: |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | argv = sys.argv[1:] |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | args = parser.parse_args(argv) |
d19766190e17
Changed the way the argparse.Namespace object is created for the web browser because it is needed for the eric main window as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | return args |