Skip to content

Commit

Permalink
Simplify and ...
Browse files Browse the repository at this point in the history
handle highlight="plain" in getlines()
  • Loading branch information
rocky committed Sep 20, 2024
1 parent 05219d1 commit 9a0a897
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
4 changes: 1 addition & 3 deletions trepan/lib/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
""" Functions for working with Python frames"""

import dis
import inspect
import linecache
import os
Expand Down Expand Up @@ -263,8 +264,6 @@ def is_exec_stmt(frame):
return hasattr(frame, "f_back") and get_call_function_name(frame) == "exec"


import dis

opc = get_opcode(PYTHON_VERSION_TRIPLE, IS_PYPY)


Expand Down Expand Up @@ -477,7 +476,6 @@ def __init__(self):
# debug()
# print_stack_entry(dd.core.processor, 0, "fruity")


# print(format_stack_entry(m, (frame, 10,)))
# print(format_stack_entry(m, (frame, 10,), color="dark"))
# print("frame count: %d" % count_frames(frame))
Expand Down
23 changes: 11 additions & 12 deletions trepan/processor/cmdproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,12 @@ def fn_is_ignored(f):
return stack, i


def run_hooks(obj, hooks, *args):
"""Run each function in `hooks' with args"""
for hook in hooks:
if hook(obj, *args):
return True
pass
return False
def run_hooks(obj, hooks, *args) -> bool:
"""Run each function in `hooks' with args
Returns True if a hook failed and so the caller should
leave its command loop.
"""
return any((hook(obj, *args) for hook in hooks))


def resolve_name(obj, command_name):
Expand Down Expand Up @@ -270,10 +269,9 @@ def print_location(proc_obj):
"output": proc_obj.settings("highlight"),
}

if (
"style" in proc_obj.debugger.settings
and proc_obj.debugger.settings.get("highlight", "plain") != "plain"
):
if proc_obj.debugger.settings.get("highlight", "plain") == "plain":
opts["style"] = "plain"
elif "style" in proc_obj.debugger.settings:
opts["style"] = proc_obj.settings("style")

pyficache.update_cache(filename)
Expand Down Expand Up @@ -796,7 +794,8 @@ def process_commands(self):
break
pass
pass
return run_hooks(self, self.postcmd_hooks)
run_hooks(self, self.postcmd_hooks)
return

def process_command(self):
# process command
Expand Down

0 comments on commit 9a0a897

Please sign in to comment.