PDB with BPython support.
| 25 | |
| 26 | |
| 27 | class BPdb(pdb.Pdb): |
| 28 | """PDB with BPython support.""" |
| 29 | |
| 30 | def __init__(self, *args, **kwargs) -> None: |
| 31 | super().__init__(*args, **kwargs) |
| 32 | self.prompt = "(BPdb) " |
| 33 | self.intro = 'Use "B" to enter bpython, Ctrl-d to exit it.' |
| 34 | |
| 35 | def postloop(self) -> None: |
| 36 | # We only want to show the intro message once. |
| 37 | self.intro = None |
| 38 | super().postloop() |
| 39 | |
| 40 | # cmd.Cmd commands |
| 41 | |
| 42 | def do_Bpython(self, arg: str) -> None: |
| 43 | locals_ = self.curframe.f_globals.copy() |
| 44 | locals_.update(self.curframe.f_locals) |
| 45 | bpython.embed(locals_, ["-i"]) |
| 46 | |
| 47 | def help_Bpython(self) -> None: |
| 48 | print("B(python)") |
| 49 | print("") |
| 50 | print( |
| 51 | "Invoke the bpython interpreter for this stack frame. To exit " |
| 52 | "bpython and return to a standard pdb press Ctrl-d" |
| 53 | ) |
| 54 | |
| 55 | # shortcuts |
| 56 | do_B = do_Bpython |
| 57 | help_B = help_Bpython |
no outgoing calls
no test coverage detected