Skip to content

Commit 165213c

Browse files
committed
reformat via black version 22.3.0
1 parent 291d17c commit 165213c

162 files changed

Lines changed: 3605 additions & 2959 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v2.0.0
3+
rev: v4.0.1
44
hooks:
55
- id: debug-statements
66
- id: end-of-file-fixer
77
- repo: https://github.com/psf/black
8-
rev: 19.10b0
8+
rev: 22.3.0
99
hooks:
1010
- id: black
1111
language_version: python3

trepan/__main__.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,19 @@ def main(dbg=None, sys_argv=list(sys.argv)):
8888
if is_readable is None:
8989
print(
9090
"%s: Python script file '%s' does not exist"
91-
% (__title__, mainpyfile,)
91+
% (
92+
__title__,
93+
mainpyfile,
94+
)
9295
)
9396
sys.exit(1)
9497
elif not is_readable:
9598
print(
96-
"%s: Can't read Python script file '%s'" % (__title__, mainpyfile,)
99+
"%s: Can't read Python script file '%s'"
100+
% (
101+
__title__,
102+
mainpyfile,
103+
)
97104
)
98105
sys.exit(1)
99106
return
@@ -227,7 +234,10 @@ def write_wrapper(*args, **kwargs):
227234
print("%s: Compiled Python script given and we can't use that." % __title__)
228235
print(
229236
"%s: Substituting non-compiled name: %s"
230-
% (__title__, mainpyfile_noopt,)
237+
% (
238+
__title__,
239+
mainpyfile_noopt,
240+
)
231241
)
232242
mainpyfile = mainpyfile_noopt
233243
pass

trepan/api.py

Lines changed: 78 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -127,85 +127,84 @@ def run_exec(statement, debug_opts=None, start_opts=None, globals_=None, locals_
127127

128128
def debug(dbg_opts=None, start_opts=None, post_mortem=True, step_ignore=1, level=0):
129129
"""
130-
Enter the debugger.
131-
132-
Parameters
133-
----------
134-
135-
level : how many stack frames go back. Usually it will be
136-
the default 0. But sometimes though there may be calls in setup to the debugger
137-
that you may want to skip.
138-
139-
step_ignore : how many line events to ignore after the
140-
debug() call. 0 means don't even wait for the debug() call to finish.
141-
142-
param dbg_opts : is an optional "options" dictionary that gets fed
143-
trepan.Debugger(); `start_opts' are the optional "options"
144-
dictionary that gets fed to trepan.Debugger.core.start().
145-
146-
Use like this:
147-
148-
.. code-block:: python
149-
150-
... # Possibly some Python code
151-
import trepan.api # Needed only once
152-
... # Possibly some more Python code
153-
trepan.api.debug() # You can wrap inside conditional logic too
154-
pass # Stop will be here.
155-
# Below is code you want to use the debugger to do things.
156-
.... # more Python code
157-
# If you get to a place in the program where you aren't going
158-
# want to debug any more, but want to remove debugger trace overhead:
159-
trepan.api.stop()
160-
161-
Parameter "level" specifies how many stack frames go back. Usually it will be
162-
the default 0. But sometimes though there may be calls in setup to the debugger
163-
that you may want to skip.
164-
165-
Parameter "step_ignore" specifies how many line events to ignore after the
166-
debug() call. 0 means don't even wait for the debug() call to finish.
167-
168-
In situations where you want an immediate stop in the "debug" call
169-
rather than the statement following it ("pass" above), add parameter
170-
step_ignore=0 to debug() like this::
171-
172-
import trepan.api # Needed only once
173-
# ... as before
174-
trepan.api.debug(step_ignore=0)
175-
# ... as before
176-
177-
Module variable _debugger_obj_ from module trepan.debugger is used as
178-
the debugger instance variable; it can be subsequently used to change
179-
settings or alter behavior. It should be of type Debugger (found in
180-
module trepan). If not, it will get changed to that type::
181-
182-
$ python
183-
>>> from trepan.debugger import debugger_obj
184-
>>> type(debugger_obj)
185-
<type 'NoneType'>
186-
>>> import trepan.api
187-
>>> trepan.api.debug()
188-
...
189-
(Trepan) c
190-
>>> from trepan.debugger import debugger_obj
191-
>>> debugger_obj
192-
<trepan.debugger.Debugger instance at 0x7fbcacd514d0>
193-
>>>
194-
195-
If however you want your own separate debugger instance, you can
196-
create it from the debugger _class Debugger()_ from module
197-
trepan.debugger::
198-
199-
$ python
200-
>>> from trepan.debugger import Debugger
201-
>>> dbgr = Debugger() # Add options as desired
202-
>>> dbgr
203-
<trepan.debugger.Debugger instance at 0x2e25320>
204-
205-
`dbg_opts' is an optional "options" dictionary that gets fed
206-
trepan.Debugger(); `start_opts' are the optional "options"
207-
dictionary that gets fed to trepan.Debugger.core.start().
208-
"""
130+
Enter the debugger.
131+
132+
Parameters
133+
----------
134+
135+
level : how many stack frames go back. Usually it will be
136+
the default 0. But sometimes though there may be calls in setup to the debugger
137+
that you may want to skip.
138+
139+
step_ignore : how many line events to ignore after the
140+
debug() call. 0 means don't even wait for the debug() call to finish.
141+
142+
param dbg_opts : is an optional "options" dictionary that gets fed
143+
trepan.Debugger(); `start_opts' are the optional "options"
144+
dictionary that gets fed to trepan.Debugger.core.start().
145+
146+
Use like this:
147+
148+
.. code-block:: python
149+
150+
... # Possibly some Python code
151+
import trepan.api # Needed only once
152+
... # Possibly some more Python code
153+
trepan.api.debug() # You can wrap inside conditional logic too
154+
pass # Stop will be here.
155+
# Below is code you want to use the debugger to do things.
156+
.... # more Python code
157+
# If you get to a place in the program where you aren't going
158+
# want to debug any more, but want to remove debugger trace overhead:
159+
trepan.api.stop()
160+
161+
Parameter "level" specifies how many stack frames go back. Usually it will be
162+
the default 0. But sometimes though there may be calls in setup to the debugger
163+
that you may want to skip.
164+
165+
Parameter "step_ignore" specifies how many line events to ignore after the
166+
debug() call. 0 means don't even wait for the debug() call to finish.
167+
168+
In situations where you want an immediate stop in the "debug" call
169+
rather than the statement following it ("pass" above), add parameter
170+
step_ignore=0 to debug() like this::
171+
172+
import trepan.api # Needed only once
173+
# ... as before
174+
trepan.api.debug(step_ignore=0)
175+
# ... as before
176+
177+
Module variable _debugger_obj_ from module trepan.debugger is used as
178+
the debugger instance variable; it can be subsequently used to change
179+
settings or alter behavior. It should be of type Debugger (found in
180+
module trepan). If not, it will get changed to that type::
181+
182+
$ python
183+
>>> from trepan.debugger import debugger_obj
184+
>>> type(debugger_obj)
185+
<type 'NoneType'>
186+
>>> import trepan.api
187+
>>> trepan.api.debug()
188+
...
189+
(Trepan) c
190+
>>> from trepan.debugger import debugger_obj
191+
>>> debugger_obj
192+
<trepan.debugger.Debugger instance at 0x7fbcacd514d0>
193+
>>>
194+
195+
If however you want your own separate debugger instance, you can
196+
create it from the debugger _class Debugger()_ from module
197+
trepan.debugger::
198+
199+
$ python
200+
>>> from trepan.debugger import Debugger
201+
>>> dbgr = Debugger() # Add options as desired
202+
>>> dbgr
203+
<trepan.debugger.Debugger instance at 0x2e25320>
204+
205+
`dbg_opts' is an optional "options" dictionary that gets fed
206+
trepan.Debugger(); `start_opts' are the optional "options"
207+
dictionary that gets fed to trepan.Debugger.core.start()."""
209208
if not isinstance(Mdebugger.debugger_obj, Mdebugger.Trepan):
210209
Mdebugger.debugger_obj = Mdebugger.Trepan(dbg_opts)
211210
Mdebugger.debugger_obj.core.add_ignore(debug, stop)

trepan/bwcli.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def process_options(debugger_name, pkg_version, sys_argv, option_list=None):
8686

8787

8888
def _postprocess_options(dbg, opts):
89-
""" Handle options (`opts') that feed into the debugger (`dbg')"""
89+
"""Handle options (`opts') that feed into the debugger (`dbg')"""
9090
# Set dbg.settings['printset']
9191
print_events = []
9292
if opts.fntrace:
@@ -141,12 +141,19 @@ def main(dbg=None, sys_argv=list(sys.argv)):
141141
if is_readable is None:
142142
print(
143143
"%s: Python script file '%s' does not exist"
144-
% (__title__, mainpyfile,)
144+
% (
145+
__title__,
146+
mainpyfile,
147+
)
145148
)
146149
sys.exit(1)
147150
elif not is_readable:
148151
print(
149-
"%s: Can't read Python script file '%s'" % (__title__, mainpyfile,)
152+
"%s: Can't read Python script file '%s'"
153+
% (
154+
__title__,
155+
mainpyfile,
156+
)
150157
)
151158
sys.exit(1)
152159
return
@@ -158,7 +165,10 @@ def main(dbg=None, sys_argv=list(sys.argv)):
158165
print("%s: Compiled Python script given and we can't use that." % __title__)
159166
print(
160167
"%s: Substituting non-compiled name: %s"
161-
% (__title__, mainpyfile_noopt,)
168+
% (
169+
__title__,
170+
mainpyfile_noopt,
171+
)
162172
)
163173
mainpyfile = mainpyfile_noopt
164174
pass

trepan/bwprocessor/command/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# You should have received a copy of the GNU General Public License
1212
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1313
# """ Copyright (C) 2008, 2009, 2013 Rocky Bernstein <rocky@gnu.org> """
14-
__import__('pkg_resources').declare_namespace(__name__)
14+
__import__("pkg_resources").declare_namespace(__name__)
1515

1616
import glob, os
1717

@@ -23,13 +23,15 @@
2323
__command_dir__ = os.path.dirname(__file__)
2424

2525
# A glob pattern that will get all *.py files but not __init__.py
26-
__py_files__ = glob.glob(os.path.join(__command_dir__, '[a-z]*.py'))
26+
__py_files__ = glob.glob(os.path.join(__command_dir__, "[a-z]*.py"))
2727

2828
# Take the basename of the filename and drop off '.py'. That minus the
2929
# files in exclude_files and tha becomes the list of modules that
3030
# commands.py will use to import
31-
exclude_files = ['mock.py']
32-
__modules__ = [ os.path.basename(filename[0:-3]) for
33-
filename in __py_files__
34-
if os.path.basename(filename) not in exclude_files]
35-
__all__ = __modules__ + exclude_files
31+
exclude_files = ["mock.py"]
32+
__modules__ = [
33+
os.path.basename(filename[0:-3])
34+
for filename in __py_files__
35+
if os.path.basename(filename) not in exclude_files
36+
]
37+
__all__ = __modules__ + exclude_files

trepan/bwprocessor/command/base_cmd.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
NotImplementedMessage = "This method must be overriden in a subclass"
2424

25-
__all__ = ['DebuggerCommand']
25+
__all__ = ["DebuggerCommand"]
2626

2727

2828
class DebuggerCommand:
2929
"""Base Class for Debugger commands. We pull in some helper
3030
functions for command from module cmdfns."""
3131

32-
category = 'misc'
32+
category = "misc"
3333

3434
def __init__(self, proc):
3535
"""proc contains the command processor object that this
@@ -42,13 +42,13 @@ def __init__(self, proc):
4242
# execution like errmsg(), msg(), and msg_nocr() might. (See
4343
# the note below on these latter 3 methods.)
4444
#
45-
self.core = proc.core
45+
self.core = proc.core
4646
self.debugger = proc.debugger
4747
self.settings = self.debugger.settings
4848
return
4949

5050
aliases = ()
51-
name = 'YourCommandName'
51+
name = "YourCommandName"
5252

5353
# Note for errmsg, msg, and msg_nocr we don't want to simply make
5454
# an assignment of method names like self.msg = self.debugger.intf.msg,
@@ -57,42 +57,44 @@ def __init__(self, proc):
5757
# in the course of the program and if we made such an method assignemnt
5858
# we wouldn't pick up that change in our self.msg
5959
def errmsg(self, msg, opts={}):
60-
""" Convenience short-hand for self.debugger.intf.errmsg """
60+
"""Convenience short-hand for self.debugger.intf.errmsg"""
6161
try:
62-
return(self.debugger.intf[-1].errmsg(msg))
62+
return self.debugger.intf[-1].errmsg(msg)
6363
except EOFError:
6464
# FIXME: what do we do here?
6565
pass
6666
return None
6767

6868
def msg(self, msg, opts={}):
69-
""" Convenience short-hand for self.debugger.intf.msg """
69+
"""Convenience short-hand for self.debugger.intf.msg"""
7070
try:
71-
return(self.debugger.intf[-1].msg(msg))
71+
return self.debugger.intf[-1].msg(msg)
7272
except EOFError:
7373
# FIXME: what do we do here?
7474
pass
7575
return None
7676

7777
def msg_nocr(self, msg, opts={}):
78-
""" Convenience short-hand for self.debugger.intf.msg_nocr """
78+
"""Convenience short-hand for self.debugger.intf.msg_nocr"""
7979
try:
80-
return(self.debugger.intf[-1].msg_nocr(msg))
80+
return self.debugger.intf[-1].msg_nocr(msg)
8181
except EOFError:
8282
# FIXME: what do we do here?
8383
pass
8484
return None
8585

8686
def run(self, args):
87-
""" The method that implements the debugger command.
87+
"""The method that implements the debugger command.
8888
Help on the command comes from the docstring of this method.
8989
"""
9090
raise NotImplementedError(NotImplementedMessage)
9191

9292
pass
9393

94-
if __name__ == '__main__':
94+
95+
if __name__ == "__main__":
9596
from trepan.bwprocessor.command import mock
97+
9698
d, cp = mock.dbg_setup()
9799
dd = DebuggerCommand(cp)
98100
dd.msg("hi")

0 commit comments

Comments
 (0)