11#!/usr/bin/env python
22# -*- coding: iso-8859-1 -*-
3- # Copyright (C) 2013, 2015, 2020, 2023 Rocky Bernstein <rocky@gnu.org>
3+ # Copyright (C) 2013, 2015, 2020, 2023-2024
4+ # Rocky Bernstein <rocky@gnu.org>
45#
56# This program is free software: you can redistribute it and/or modify
67# it under the terms of the GNU General Public License as published by
2324import pyficache
2425
2526# Our local modules
26- from trepan import (
27- clifns as Mclifns ,
28- debugger as Mdebugger ,
29- exception as Mexcept ,
30- misc as Mmisc ,
31- )
27+ import trepan .debugger
28+
29+ from trepan .clifns import whence_file
30+ from trepan .exception import DebuggerQuit , DebuggerRestart
3231from trepan .interfaces .bullwinkle import BWInterface
3332from trepan .lib .file import readable
33+ from trepan .misc import wrapped_lines
3434
3535# The name of the debugger we are currently going by.
3636__title__ = "trepan"
3939from trepan .version import __version__
4040
4141
42- def process_options (debugger_name , pkg_version , sys_argv , option_list = None ):
43- """Handle debugger options. Set `option_list' if you are writing
42+ def process_options (pkg_version , sys_argv , option_list = None ):
43+ """Handle debugger options. Set `` option_list`` if you are writing
4444 another main program and want to extend the existing set of debugger
4545 options.
4646
@@ -90,7 +90,7 @@ def process_options(debugger_name, pkg_version, sys_argv, option_list=None):
9090
9191
9292def postprocess_options (dbg , opts ):
93- """Handle options (`opts') that feed into the debugger (`dbg' )"""
93+ """Handle options (`opts') that feed into the debugger (`` dbg`` )"""
9494 # Set dbg.settings['printset']
9595 print_events = []
9696 if opts .fntrace :
@@ -109,28 +109,27 @@ def postprocess_options(dbg, opts):
109109
110110 dbg .settings ["highlight" ] = "plain"
111111
112- Mdebugger .debugger_obj = dbg
112+ trepan .debugger_obj = dbg
113113 return
114114
115115
116116def main (dbg = None , sys_argv = list (sys .argv )):
117117 """Routine which gets run if we were invoked directly"""
118- global __title__
119118
120119 # Save the original just for use in the restart that works via exec.
121120 orig_sys_argv = list (sys_argv )
122- opts , dbg_opts , sys_argv = process_options (__title__ , __version__ , sys_argv )
121+ opts , dbg_opts , sys_argv = process_options (__version__ , sys_argv )
123122 dbg_opts ["orig_sys_argv" ] = sys_argv
124123 dbg_opts ["interface" ] = BWInterface ()
125124 dbg_opts ["processor" ] = "bullwinkle"
126125
127126 if dbg is None :
128- dbg = Mdebugger .Trepan (dbg_opts )
127+ dbg = trepan . debugger .Trepan (dbg_opts )
129128 dbg .core .add_ignore (main )
130129 pass
131130 postprocess_options (dbg , opts )
132131
133- # process_options has munged sys.argv to remove any options that
132+ # process_options has munged sys.argv to remove any
134133 # options that belong to this debugger. The original options to
135134 # invoke the debugger and script are in global sys_argv
136135 if len (sys_argv ) == 0 :
@@ -140,7 +139,7 @@ def main(dbg=None, sys_argv=list(sys.argv)):
140139 else :
141140 mainpyfile = sys_argv [0 ] # Get script filename.
142141 if not osp .isfile (mainpyfile ):
143- mainpyfile = Mclifns . whence_file (mainpyfile )
142+ mainpyfile = whence_file (mainpyfile )
144143 is_readable = readable (mainpyfile )
145144 if is_readable is None :
146145 print (
@@ -207,16 +206,16 @@ def main(dbg=None, sys_argv=list(sys.argv)):
207206 dbg .core .execution_status = "Terminated"
208207 dbg .intf [- 1 ].msg ("The program finished - quit or restart" )
209208 dbg .core .processor .process_commands ()
210- except Mexcept . DebuggerQuit :
209+ except DebuggerQuit :
211210 break
212- except Mexcept . DebuggerRestart :
211+ except DebuggerRestart :
213212 dbg .core .execution_status = "Restart requested"
214213 if dbg .program_sys_argv :
215214 sys .argv = list (dbg .program_sys_argv )
216215 part1 = "Restarting %s with arguments:" % dbg .core .filename (mainpyfile )
217216 args = " " .join (dbg .program_sys_argv [1 :])
218217 dbg .intf [- 1 ].msg (
219- Mmisc . wrapped_lines (part1 , args , dbg .settings ["width" ])
218+ wrapped_lines (part1 , args , dbg .settings ["width" ])
220219 )
221220 else :
222221 break
0 commit comments