Skip to content

Commit d9d6175

Browse files
committed
Add "set patsub" for docker (and other) mounts
1 parent 19e0759 commit d9d6175

4 files changed

Lines changed: 96 additions & 8 deletions

File tree

__pkginfo__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@
7171
install_requires = [
7272
"columnize >= 0.3.10",
7373
"nose>=1.0.0, <= 1.3.7",
74-
"pyficache >= 2.2.0",
75-
"xdis >= 5.0.3",
74+
"pyficache >= 2.2.1",
75+
"xdis >= 5.0.4",
7676
"pygments %s" % pygments_version,
7777
"spark_parser >= 1.8.9, <1.9.0",
7878
"tracer >= 0.3.2",
79-
"uncompyle6 >= 3.7.2",
79+
"uncompyle6 >= 3.7.4",
8080
]
8181
license = "GPL3"
8282
mailing_list = "python-debugger@googlegroups.com"

docs/commands/set/patsub.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.. index:: set; patsub
2+
.. _set_patsub:
3+
4+
Set Substition Pattern
5+
----------------------
6+
7+
**set patsub** *from-re* *replace-string*
8+
9+
Add a substitution pattern rule replacing *patsub* with
10+
*replace-string* anywhere it is found in source file names. If a
11+
substitution rule was previously set for *from-re*, the old rule is
12+
replaced by the new one.
13+
14+
In the following example, suppose in a docker container /mnt/project is
15+
the mount-point for /home/rocky/project. You are running the code
16+
from the docker container, but debugging this from outside of that.
17+
18+
19+
Example:
20+
++++++++
21+
22+
::
23+
24+
set patsub ^/mmt/project /home/rocky/project
25+
26+
.. seealso::
27+
28+
:ref:`set substitute <set_substitute>`
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (C) 2020 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 trepan.processor.command import base_subcmd as Mbase_subcmd
19+
20+
21+
class SetPatSub(Mbase_subcmd.DebuggerSubcommand):
22+
"""**set patsub** *from-re* *replace-string*
23+
24+
Add a substitution pattern rule replacing *patsub* with
25+
*replace-string* anywhere it is found in source file names. If a
26+
substitution rule was previously set for *from-re*, the old rule is
27+
replaced by the new one.
28+
29+
In the following example, suppose in a docker container /mnt/project is
30+
the mount-point for /home/rocky/project. You are running the code
31+
from the docker container, but debugging this from outside of that.
32+
33+
Example:
34+
--------
35+
36+
set patsub ^/mmt/project /home/rocky/project
37+
38+
"""
39+
40+
in_list = True
41+
min_abbrev = len("pats")
42+
short_help = "Set pattern substitution rule"
43+
44+
def run(self, args):
45+
if len(args) != 2:
46+
self.errmsg("Expecting two arguments; got %d." % len(args))
47+
return
48+
self.proc.add_remap_pat(args[0], args[1])
49+
50+
pass
51+
52+
53+
if __name__ == "__main__":
54+
from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
55+
56+
Mhelper.demo_run(SetPatSub)
57+
pass

trepan/processor/command/set_subcmd/substitute.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2015, 2016 Rocky Bernstein
2+
# Copyright (C) 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
@@ -40,15 +40,18 @@ class SetSubstitute(Mbase_subcmd.DebuggerSubcommand):
4040
4141
"""
4242

43-
in_list = True
44-
min_abbrev = len('sub')
45-
short_help = 'Set filename substitution'
43+
in_list = True
44+
min_abbrev = len("sub")
45+
short_help = "Set filename substitution"
4646

4747
def run(self, args):
4848
pyficache.remap_file(args[1], args[0])
49+
4950
pass
5051

51-
if __name__ == '__main__':
52+
53+
if __name__ == "__main__":
5254
from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper
55+
5356
Mhelper.demo_run(SetSubstitute)
5457
pass

0 commit comments

Comments
 (0)