Skip to content

Commit 533c92b

Browse files
committed
Upgrade more modules
1 parent c58a36c commit 533c92b

File tree

16 files changed

+317
-319
lines changed

16 files changed

+317
-319
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ install:
6464

6565
# Upgrade to the latest version of pip to avoid it displaying warnings
6666
# about it being out of date.
67-
- "pip install --disable-pip-version-check --user --upgrade pip"
67+
- "%CMD_IN_ENV% pip install --disable-pip-version-check --user --upgrade pip"
6868

6969
# Install the build dependencies of the project. If some dependencies contain
7070
# compiled extensions and are not provided as pre-built wheel packages,
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (C) 2008-2009, 2013-2015, 2018, 2020 Rocky Bernstein <rocky@gnu.org>
12
# This program is free software: you can redistribute it and/or modify
23
# it under the terms of the GNU General Public License as published by
34
# the Free Software Foundation, either version 3 of the License, or
@@ -10,25 +11,27 @@
1011
#
1112
# You should have received a copy of the GNU General Public License
1213
# along with this program. If not, see <http://www.gnu.org/licenses/>.
13-
# """ Copyright (C) 2008-2009, 2013-2015, 2018 Rocky Bernstein <rocky@gnu.org> """
1414

1515
import glob, os
16+
import os.path as osp
1617

1718
# FIXME: Is it really helpful to "privatize" variable names below?
1819
# The below names are not part of the standard pre-defined names like
1920
# __name__ or __file__ are.
2021

2122
# Get the name of our directory.
22-
__command_dir__ = os.path.dirname(__file__)
23+
__command_dir__ = osp.dirname(__file__)
2324

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

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

trepan/processor/command/backtrace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ def run(self, args):
123123

124124
if __name__ == "__main__":
125125
from trepan.processor import cmdproc
126-
from trepan import debugger
126+
from trepan.debugger import Trepan
127127

128-
d = debugger.Debugger()
128+
d = Trepan()
129129
cp = d.core.processor
130130
command = BacktraceCommand(cp)
131131
command.run(["backtrace", "wrong", "number", "of", "args"])
Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2009-2010, 2012-2013, 2015-2016 Rocky Bernstein
2+
# Copyright (C) 2009-2010, 2012-2013, 2015-2016, 2020 Rocky Bernstein
33
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
@@ -32,17 +32,17 @@ class DebuggerSubcommand:
3232
"""Base Class for Debugger subcommands. We pull in some helper
3333
functions for command from module cmdfns."""
3434

35-
in_list = True # Show item in help list of commands
35+
in_list = True # Show item in help list of commands
3636

3737
# Run subcommand for those subcommands like "show"
3838
# which append current settings to list output.
39-
run_cmd = True
39+
run_cmd = True
4040

4141
run_in_help = True # Run to get value in 'show' command?
42-
min_abbrev = 1
43-
min_args = 0
44-
max_args = None
45-
need_stack = False
42+
min_abbrev = 1
43+
min_args = 0
44+
max_args = None
45+
need_stack = False
4646

4747
def __init__(self, cmd):
4848
"""cmd contains the command object that this
@@ -55,15 +55,15 @@ def __init__(self, cmd):
5555
# errmsg(), msg(), and msg_nocr() might. (See the note below
5656
# on these latter 3 methods.)
5757
#
58-
self.proc = cmd.proc
59-
self.core = cmd.core
58+
self.proc = cmd.proc
59+
self.core = cmd.core
6060
self.debugger = cmd.debugger
6161
self.settings = cmd.debugger.settings
6262

63-
if not hasattr(self, 'short_help'):
63+
if not hasattr(self, "short_help"):
6464
help = self.__doc__.split("\n")
6565
if len(help) > 0:
66-
if help[0][0] == '*' and len(help) > 2:
66+
if help[0][0] == "*" and len(help) > 2:
6767
self.short_help = help[2]
6868
else:
6969
self.short_help = help[0]
@@ -75,20 +75,19 @@ def __init__(self, cmd):
7575
# that -- perhaps one may want to put several subcommands into
7676
# a single file. So in those cases, one will have to set self.name
7777
# accordingly by other means.
78-
self.name = self.__module__.split('.')[-1]
78+
self.name = self.__module__.split(".")[-1]
7979

8080
return
8181

8282
def columnize_commands(self, commands):
8383
"""List commands arranged in an aligned columns"""
8484
commands.sort()
85-
width = self.debugger.settings['width']
86-
return columnize.columnize(commands, displaywidth=width,
87-
lineprefix=' ')
85+
width = self.debugger.settings["width"]
86+
return columnize.columnize(commands, displaywidth=width, lineprefix=" ")
8887

8988
def confirm(self, msg, default=False):
9089
""" Convenience short-hand for self.debugger.intf.confirm """
91-
return(self.debugger.intf[-1].confirm(msg, default))
90+
return self.debugger.intf[-1].confirm(msg, default)
9291

9392
# Note for errmsg, msg, and msg_nocr we don't want to simply make
9493
# an assignment of method names like self.msg = self.debugger.intf.msg,
@@ -98,22 +97,22 @@ def confirm(self, msg, default=False):
9897
# we wouldn't pick up that change in our self.msg
9998
def errmsg(self, msg):
10099
""" Convenience short-hand for self.debugger.intf[-1].errmsg """
101-
return(self.debugger.intf[-1].errmsg(msg))
100+
return self.debugger.intf[-1].errmsg(msg)
102101

103102
def msg(self, msg):
104103
""" Convenience short-hand for self.debugger.intf[-1].msg """
105-
return(self.debugger.intf[-1].msg(msg))
104+
return self.debugger.intf[-1].msg(msg)
106105

107106
def msg_nocr(self, msg):
108107
""" Convenience short-hand for self.debugger.intf[-1].msg_nocr """
109-
return(self.debugger.intf[-1].msg_nocr(msg))
108+
return self.debugger.intf[-1].msg_nocr(msg)
110109

111110
aliases = ()
112-
name = 'YourCommandName'
111+
name = "YourCommandName"
113112

114113
def rst_msg(self, text):
115114
"""Convenience short-hand for self.proc.rst_msg(text)"""
116-
return(self.proc.rst_msg(text))
115+
return self.proc.rst_msg(text)
117116

118117
def run(self):
119118
""" The method that implements the debugger command.
@@ -122,54 +121,58 @@ def run(self):
122121
raise NotImplementedError(NotImplementedMessage)
123122

124123
def section(self, message, opts={}):
125-
if 'plain' != self.settings['highlight']:
126-
message = colorize('bold', message)
124+
if "plain" != self.settings["highlight"]:
125+
message = colorize("bold", message)
127126
else:
128-
message += "\n" + '-' * len(message)
127+
message += "\n" + "-" * len(message)
129128
pass
130129
self.msg(message)
130+
131131
pass
132132

133-
from trepan.processor import cmdfns as Mcmdfns
134-
from trepan.lib import complete as Mcomplete
133+
134+
from trepan.processor.cmdfns import run_set_bool, run_show_bool, run_show_int
135+
from trepan.lib.complete import complete_token
135136

136137

137138
class DebuggerSetBoolSubcommand(DebuggerSubcommand):
138139
max_args = 1
139140

140141
def complete(self, prefix):
141-
result = Mcomplete.complete_token(('on', 'off'), prefix)
142+
result = complete_token(("on", "off"), prefix)
142143
return result
143144

144145
def run(self, args):
145146
# Strip off ReStructuredText tags
146-
doc = re.sub('[*]', '', self.short_help).lstrip()
147+
doc = re.sub("[*]", "", self.short_help).lstrip()
147148
# Take only the first two tokens
148-
i = doc.find(' ')
149+
i = doc.find(" ")
149150
if i > 0:
150-
j = doc.find(' ', i+1)
151-
if j > 0: doc = doc[0:j]
151+
j = doc.find(" ", i + 1)
152+
if j > 0:
153+
doc = doc[0:j]
152154
pass
153-
doc = doc.capitalize().split('\n')[0].rstrip('.')
154-
Mcmdfns.run_set_bool(self, args)
155-
Mcmdfns.run_show_bool(self, doc)
155+
doc = doc.capitalize().split("\n")[0].rstrip(".")
156+
run_set_bool(self, args)
157+
run_show_bool(self, doc)
156158
return
157159

158160
def summary_help(self, subcmd_name, subcmd):
159161
return self.msg_nocr("%-12s: " % self.short_help)
162+
160163
pass
161164

162165

163166
class DebuggerShowIntSubcommand(DebuggerSubcommand):
164167
max_args = 0
165168

166169
def run(self, args):
167-
if hasattr(self, 'short_help'):
170+
if hasattr(self, "short_help"):
168171
short_help = self.short_help
169172
else:
170173
short_help = self.__doc__[5:].capitalize()
171174
pass
172-
Mcmdfns.run_show_int(self, short_help)
175+
run_show_int(self, short_help)
173176
return
174177

175178

@@ -178,12 +181,14 @@ class DebuggerShowBoolSubcommand(DebuggerSubcommand):
178181

179182
def run(self, args):
180183
# Strip off ReStructuredText tags
181-
doc = re.sub('[*]', '', self.short_help)
182-
doc = doc[5:].capitalize().split('\n')[0].rstrip('.')
183-
Mcmdfns.run_show_bool(self, doc)
184+
doc = re.sub("[*]", "", self.short_help)
185+
doc = doc[5:].capitalize().split("\n")[0].rstrip(".")
186+
run_show_bool(self, doc)
184187
return
185188

186-
if __name__ == '__main__':
187-
from trepan.processor.command import mock
188-
d, cp = mock.dbg_setup()
189-
dd = DebuggerSubcommand(cp.commands['quit'])
189+
190+
if __name__ == "__main__":
191+
from trepan.processor.command.mock import dbg_setup
192+
193+
d, cp = dbg_setup()
194+
dd = DebuggerSubcommand(cp.commands["quit"])

trepan/processor/command/break.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# Our local modules
1818
from trepan.processor.command.base_cmd import DebuggerCommand
19-
from trepan.processor import cmdbreak as Mcmdbreak
19+
from trepan.processor.cmdbreak import parse_break_cmd, set_break
2020
from trepan.processor.complete import complete_break_linenumber
2121

2222

@@ -73,9 +73,9 @@ class BreakCommand(DebuggerCommand):
7373
def run(self, args):
7474
force = True if args[0][-1] == "!" else False
7575

76-
(func, filename, lineno, condition) = Mcmdbreak.parse_break_cmd(self.proc, args)
76+
(func, filename, lineno, condition) = parse_break_cmd(self.proc, args)
7777
if not (func == None and filename == None):
78-
Mcmdbreak.set_break(
78+
set_break(
7979
self, func, filename, lineno, condition, False, args, force=force
8080
)
8181
return
@@ -85,12 +85,12 @@ def run(self, args):
8585

8686
def doit(cmd, a):
8787
cmd.current_command = " ".join(a)
88-
print(Mcmdbreak.parse_break_cmd(cmd.proc, a))
88+
print(parse_break_cmd(cmd.proc, a))
8989

9090
import sys
91-
from trepan import debugger as Mdebugger
91+
from trepan.debugger import Trepan
9292

93-
d = Mdebugger.Trepan()
93+
d = Trepan()
9494
command = BreakCommand(d.core.processor)
9595
command.proc.frame = sys._getframe()
9696
command.proc.setup()

trepan/processor/command/delete.py

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2009, 2013, 2015, 2017 Rocky Bernstein
2+
# Copyright (C) 2009, 2013, 2015, 2017, 2020 Rocky Bernstein
33
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
@@ -14,14 +14,12 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import os
18-
1917
# Our local modules
20-
from trepan.processor.command import base_cmd as Mbase_cmd
21-
from trepan.processor import complete as Mcomplete
18+
from trepan.processor.command.base_cmd import DebuggerCommand
19+
from trepan.processor.complete import complete_bpnumber
2220

2321

24-
class DeleteCommand(Mbase_cmd.DebuggerCommand):
22+
class DeleteCommand(DebuggerCommand):
2523
"""**delete** [*bpnumber* [*bpnumber*...]]
2624
2725
Delete some breakpoints.
@@ -34,20 +32,18 @@ class DeleteCommand(Mbase_cmd.DebuggerCommand):
3432
---------
3533
`clear`
3634
"""
37-
category = 'breakpoints'
38-
aliases = ('delete!',)
39-
min_args = 0
40-
max_args = None
41-
name = os.path.basename(__file__).split('.')[0]
42-
need_stack = False
43-
short_help = 'Delete some breakpoints or auto-display expressions'
4435

45-
complete = Mcomplete.complete_bpnumber
36+
aliases = ("delete!",)
37+
short_help = "Delete some breakpoints or auto-display expressions"
38+
39+
complete = complete_bpnumber
40+
41+
DebuggerCommand.setup(locals(), category="breakpoints")
4642

4743
def run(self, args):
4844
if len(args) <= 1:
49-
if '!' != args[0][-1]:
50-
confirmed = self.confirm('Delete all breakpoints', False)
45+
if "!" != args[0][-1]:
46+
confirmed = self.confirm("Delete all breakpoints", False)
5147
else:
5248
confirmed = True
5349

@@ -56,22 +52,23 @@ def run(self, args):
5652
return
5753

5854
for arg in args[1:]:
59-
i = self.proc.get_int(arg, min_value=1, default=None,
60-
cmdname='delete')
61-
if i is None: continue
55+
i = self.proc.get_int(arg, min_value=1, default=None, cmdname="delete")
56+
if i is None:
57+
continue
6258

6359
success, msg = self.core.bpmgr.delete_breakpoint_by_number(i)
6460
if not success:
6561
self.errmsg(msg)
6662
else:
67-
self.msg('Deleted breakpoint %d' % i)
63+
self.msg("Deleted breakpoint %d" % i)
6864
pass
6965
pass
7066
return
7167

7268

73-
if __name__ == '__main__':
74-
from trepan import debugger as Mdebugger
75-
d = Mdebugger.Trepan()
69+
if __name__ == "__main__":
70+
from trepan.debugger import Trepan
71+
72+
d = Trepan()
7673
command = DeleteCommand(d.core.processor)
7774
pass

0 commit comments

Comments
 (0)