Skip to content

Commit 360f243

Browse files
committed
Add "show sustitute" command
1 parent befd7f7 commit 360f243

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (C) 2023 Rocky Bernstein
3+
#
4+
# This program is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU General Public License as published by
6+
# the Free Software Foundation, either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
# Our local modules
18+
from pyficache import file2file_remap
19+
20+
from trepan.processor.command import base_subcmd as Mbase_subcmd
21+
22+
23+
class ShowSubstitute(Mbase_subcmd.DebuggerSubcommand):
24+
"""**show substitute** [*from-name1* *from_name2* ... ]
25+
If no *from-name* is given, then show all substitute commands
26+
27+
Examples:
28+
---------
29+
30+
show substitute importlib._bootstrap /usr/lib/python3.10/importlib/_bootstrap.py
31+
show substitute
32+
"""
33+
34+
in_list = True
35+
min_abbrev = len("sub")
36+
37+
short_help = "Set filename substitution"
38+
39+
def run(self, args):
40+
if len(args) == 0:
41+
args = file2file_remap.keys()
42+
43+
if len(args) == 0:
44+
self.msg("No file remappings in effect.")
45+
for from_path in args:
46+
self.msg(f"{from_path}:\t{file2file_remap.get(from_path, from_path)}")
47+
48+
49+
if __name__ == "__main__":
50+
from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
51+
52+
Mhelper.demo_run(ShowSubstitute)
53+
pass

0 commit comments

Comments
 (0)