Skip to content

Commit 3a1ba26

Browse files
committed
Switch from deprecated optparse to argparse
1 parent 4aa6298 commit 3a1ba26

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

guake/main.py

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
builtins.__dict__["_"] = gettext
3939

40-
from optparse import OptionParser
40+
from argparse import ArgumentParser
4141

4242
log = logging.getLogger(__name__)
4343

@@ -78,8 +78,8 @@ def main():
7878
os.environ["TERM_PROGRAM"] = "guake"
7979

8080
# do not use version keywords here, pbr might be slow to find the version of Guake module
81-
parser = OptionParser()
82-
parser.add_option(
81+
parser = ArgumentParser()
82+
parser.add_argument(
8383
"-V",
8484
"--version",
8585
dest="version",
@@ -88,7 +88,7 @@ def main():
8888
help=_("Show Guake version number and exit"),
8989
)
9090

91-
parser.add_option(
91+
parser.add_argument(
9292
"-v",
9393
"--verbose",
9494
dest="verbose",
@@ -97,7 +97,7 @@ def main():
9797
help=_("Enable verbose logging"),
9898
)
9999

100-
parser.add_option(
100+
parser.add_argument(
101101
"-f",
102102
"--fullscreen",
103103
dest="fullscreen",
@@ -106,15 +106,15 @@ def main():
106106
help=_("Put Guake in fullscreen mode"),
107107
)
108108

109-
parser.add_option(
109+
parser.add_argument(
110110
"--unfullscreen",
111111
dest="unfullscreen",
112112
action="store_true",
113113
default=False,
114114
help=_("Put Guake out from fullscreen mode"),
115115
)
116116

117-
parser.add_option(
117+
parser.add_argument(
118118
"-t",
119119
"--toggle-visibility",
120120
dest="show_hide",
@@ -123,31 +123,31 @@ def main():
123123
help=_("Toggles the visibility of the terminal window"),
124124
)
125125

126-
parser.add_option(
126+
parser.add_argument(
127127
"--is-visible",
128128
dest="is_visible",
129129
action="store_true",
130130
default=False,
131131
help=_("Return 1 if Guake is visible, 0 otherwise"),
132132
)
133133

134-
parser.add_option(
134+
parser.add_argument(
135135
"--show",
136136
dest="show",
137137
action="store_true",
138138
default=False,
139139
help=_("Shows Guake main window"),
140140
)
141141

142-
parser.add_option(
142+
parser.add_argument(
143143
"--hide",
144144
dest="hide",
145145
action="store_true",
146146
default=False,
147147
help=_("Hides Guake main window"),
148148
)
149149

150-
parser.add_option(
150+
parser.add_argument(
151151
"-p",
152152
"--preferences",
153153
dest="show_preferences",
@@ -156,7 +156,7 @@ def main():
156156
help=_("Shows Guake preference window"),
157157
)
158158

159-
parser.add_option(
159+
parser.add_argument(
160160
"-a",
161161
"--about",
162162
dest="show_about",
@@ -165,7 +165,7 @@ def main():
165165
help=_("Shows Guake's about info"),
166166
)
167167

168-
parser.add_option(
168+
parser.add_argument(
169169
"-n",
170170
"--new-tab",
171171
dest="new_tab",
@@ -174,7 +174,7 @@ def main():
174174
help=_("Add a new tab (with current directory set to NEW_TAB)"),
175175
)
176176

177-
parser.add_option(
177+
parser.add_argument(
178178
"-s",
179179
"--select-tab",
180180
dest="select_tab",
@@ -183,7 +183,7 @@ def main():
183183
help=_("Select a tab (SELECT_TAB is the index of the tab)"),
184184
)
185185

186-
parser.add_option(
186+
parser.add_argument(
187187
"-g",
188188
"--selected-tab",
189189
dest="selected_tab",
@@ -192,7 +192,7 @@ def main():
192192
help=_("Return the selected tab index."),
193193
)
194194

195-
parser.add_option(
195+
parser.add_argument(
196196
"-x",
197197
"--uuid-index",
198198
dest="uuid_index",
@@ -201,7 +201,7 @@ def main():
201201
help=_("Return the index of the tab with the given terminal UUID, -1 if not found"),
202202
)
203203

204-
parser.add_option(
204+
parser.add_argument(
205205
"-l",
206206
"--selected-tablabel",
207207
dest="selected_tablabel",
@@ -210,7 +210,7 @@ def main():
210210
help=_("Return the selected tab label."),
211211
)
212212

213-
parser.add_option(
213+
parser.add_argument(
214214
"-S",
215215
"--select-terminal",
216216
dest="select_terminal",
@@ -223,31 +223,31 @@ def main():
223223
),
224224
)
225225

226-
parser.add_option(
226+
parser.add_argument(
227227
"--selected-terminal",
228228
dest="selected_terminal",
229229
action="store_true",
230230
default=False,
231231
help=_("Return the selected terminal index."),
232232
)
233233

234-
parser.add_option(
234+
parser.add_argument(
235235
"--split-vertical",
236236
dest="split_vertical",
237237
action="store_true",
238238
default=False,
239239
help=_("Split the selected tab vertically."),
240240
)
241241

242-
parser.add_option(
242+
parser.add_argument(
243243
"--split-horizontal",
244244
dest="split_horizontal",
245245
action="store_true",
246246
default=False,
247247
help=_("Split the selected tab horizontally."),
248248
)
249249

250-
parser.add_option(
250+
parser.add_argument(
251251
"-e",
252252
"--execute-command",
253253
dest="command",
@@ -256,7 +256,7 @@ def main():
256256
help=_("Execute an arbitrary command in a new tab."),
257257
)
258258

259-
parser.add_option(
259+
parser.add_argument(
260260
"-i",
261261
"--tab-index",
262262
dest="tab_index",
@@ -265,63 +265,63 @@ def main():
265265
help=_("Specify the tab to rename. Default is 0. Can be used to select tab by UUID."),
266266
)
267267

268-
parser.add_option(
268+
parser.add_argument(
269269
"--bgcolor",
270270
dest="bgcolor",
271271
action="store",
272272
default="",
273273
help=_("Set the hexadecimal (#rrggbb) background color of " "the selected tab."),
274274
)
275275

276-
parser.add_option(
276+
parser.add_argument(
277277
"--fgcolor",
278278
dest="fgcolor",
279279
action="store",
280280
default="",
281281
help=_("Set the hexadecimal (#rrggbb) foreground color of the " "selected tab."),
282282
)
283283

284-
parser.add_option(
284+
parser.add_argument(
285285
"--bgcolor-current",
286286
dest="bgcolor_current",
287287
action="store",
288288
default="",
289289
help=_("Set the hexadecimal (#rrggbb) background color of " "the current terminal."),
290290
)
291291

292-
parser.add_option(
292+
parser.add_argument(
293293
"--fgcolor-current",
294294
dest="fgcolor_current",
295295
action="store",
296296
default="",
297297
help=_("Set the hexadecimal (#rrggbb) foreground color of " "the current terminal."),
298298
)
299299

300-
parser.add_option(
300+
parser.add_argument(
301301
"--change-palette",
302302
dest="palette_name",
303303
action="store",
304304
default="",
305305
help=_("Change Guake palette scheme"),
306306
)
307307

308-
parser.add_option(
308+
parser.add_argument(
309309
"--reset-colors",
310310
dest="reset_colors",
311311
action="store_true",
312312
default=False,
313313
help=_("Set colors from settings."),
314314
)
315315

316-
parser.add_option(
316+
parser.add_argument(
317317
"--reset-colors-current",
318318
dest="reset_colors_current",
319319
action="store_true",
320320
default=False,
321321
help=_("Set colors of the current terminal from settings."),
322322
)
323323

324-
parser.add_option(
324+
parser.add_argument(
325325
"--rename-tab",
326326
dest="rename_tab",
327327
metavar="TITLE",
@@ -333,7 +333,7 @@ def main():
333333
),
334334
)
335335

336-
parser.add_option(
336+
parser.add_argument(
337337
"-r",
338338
"--rename-current-tab",
339339
dest="rename_current_tab",
@@ -343,7 +343,7 @@ def main():
343343
help=_("Rename the current tab. Reset to default if TITLE is a " 'single dash "-".'),
344344
)
345345

346-
parser.add_option(
346+
parser.add_argument(
347347
"-q",
348348
"--quit",
349349
dest="quit",
@@ -352,7 +352,7 @@ def main():
352352
help=_("Says to Guake go away =("),
353353
)
354354

355-
parser.add_option(
355+
parser.add_argument(
356356
"-u",
357357
"--no-startup-script",
358358
dest="execute_startup_script",
@@ -361,23 +361,23 @@ def main():
361361
help=_("Do not execute the start up script"),
362362
)
363363

364-
parser.add_option(
364+
parser.add_argument(
365365
"--save-preferences",
366366
dest="save_preferences",
367367
action="store",
368368
default=None,
369369
help=_("Save Guake preferences to this filename"),
370370
)
371371

372-
parser.add_option(
372+
parser.add_argument(
373373
"--restore-preferences",
374374
dest="restore_preferences",
375375
action="store",
376376
default=None,
377377
help=_("Restore Guake preferences from this file"),
378378
)
379379

380-
parser.add_option(
380+
parser.add_argument(
381381
"--support",
382382
dest="support",
383383
action="store_true",
@@ -430,7 +430,7 @@ def main():
430430
)
431431
sys.exit(1)
432432

433-
options = parser.parse_args()[0]
433+
options = parser.parse_args()
434434
if options.version:
435435
from guake import gtk_version
436436
from guake import guake_version

0 commit comments

Comments
 (0)