1616
1717import codecs
1818import os
19- import os .path as osp
2019import sys
2120from optparse import OptionParser
2221
2322from pygments .styles import STYLE_MAP
2423
2524import trepan .api
26- from trepan .clifns import path_expanduser_abs
25+ from trepan .clifns import default_configfile
2726from trepan .inout .output import DebuggerUserOutput
2827from trepan .lib .file import readable
2928
3029try :
3130 import prompt_toolkit # NOQA
32- have_prompt_toolkit = True
3331except ImportError :
3432 have_prompt_toolkit = False
33+ else :
34+ have_prompt_toolkit = True
3535
36- try :
37- import prompt_toolkit # NOQA
38- have_gnu_readline = True
39- except ImportError :
40- have_gnu_readline = False
41-
42-
43- def default_configfile (base_filename : str ) -> str :
44- """Return fully expanded configuration filename location for
45- base_filename. python2 and python3 debuggers share the same
46- directory: ~/.config/trepan.py
47- """
48- file_dir = osp .join (os .environ .get ("HOME" , "~" ), ".config" , "trepanpy" )
49- file_dir = path_expanduser_abs (file_dir )
50-
51- if not osp .isdir (file_dir ):
52- os .makedirs (file_dir , mode = 0o755 )
53- return osp .join (file_dir , base_filename )
36+ have_gnu_readline = False
5437
5538
5639def add_startup_file (dbg_initfiles : list ):
@@ -334,21 +317,6 @@ def process_options(pkg_version: str, sys_argv: str, option_list=None):
334317 )
335318
336319 readline = None
337- if have_gnu_readline :
338- optparser .add_option (
339- "--gnu-readline" ,
340- dest = "use_gnu_readline" ,
341- action = "store_true" ,
342- default = True ,
343- help = "Try using GNU-Readline" ,
344- )
345- optparser .add_option (
346- "--no-gnu-readline" ,
347- dest = "use_gnu_readline" ,
348- action = "store_false" ,
349- default = True ,
350- help = "Do not use GNU-Readline" ,
351- )
352320 if have_prompt_toolkit :
353321 optparser .add_option (
354322 "--prompt-toolkit" ,
@@ -365,7 +333,6 @@ def process_options(pkg_version: str, sys_argv: str, option_list=None):
365333 help = "Do not use prompt_toolkit" ,
366334 )
367335
368-
369336 # Set up to stop on the first non-option because that's the name
370337 # of the script to be debugged on arguments following that are
371338 # that scripts options that should be left untouched. We would
@@ -386,21 +353,19 @@ def process_options(pkg_version: str, sys_argv: str, option_list=None):
386353 )
387354 opts .edit_mode = "emacs"
388355
389-
390- if hasattr (opts , "use_prompt_toolkit" ) and opts .use_prompt_toolkit :
391- readline = "prompt_toolkit"
392- elif hasattr (opts , "use_gnu_readline" ) and opts .use_gnu_readline :
393- readline = "gnu_readline"
394- else :
395- readline = None
356+ readline = (
357+ "prompt_toolkit"
358+ if hasattr (opts , "use_prompt_toolkit" ) and opts .use_prompt_toolkit
359+ else "readline"
360+ )
396361
397362 dbg_opts = {
398363 "from_ipython" : opts .from_ipython ,
399364 "interface_opts" : {
400365 "readline" : readline ,
401366 "debugger_name" : "trepan3k" ,
402367 "edit_mode" : opts .edit_mode ,
403- }
368+ },
404369 }
405370
406371 # Handle debugger startup command files: --nx (-n) and --command.
0 commit comments