Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcd01afd

Browse files
thomasballingersebastinas
authored andcommitted
Restore original save behavior for cli and urwid
1 parentd632b51 commitcd01afd

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

‎bpython/curtsiesfrontend/repl.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,8 @@ def push(self, line, insert_into_history=True):
11641164
11651165
If the interpreter successfully runs the code, clear the buffer
11661166
"""
1167+
# Note that push() overrides its parent without calling it, unlike
1168+
# urwid and cli which implement custom behavior and call repl.Repl.push
11671169
ifself.paste_mode:
11681170
self.saved_indent=0
11691171
else:

‎bpython/repl.py‎

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -832,15 +832,31 @@ def get_session_formatted_for_file(self):
832832
i.e. without >>> and ... at input lines and with "# OUT: " prepended to
833833
output lines and "### " prepended to current line"""
834834

835-
defprocess():
836-
forline,lineTypeinself.all_logical_lines:
837-
iflineType==LineTypeTranslator.INPUT:
838-
yieldline
839-
elifline.rstrip():
840-
yield"# OUT: %s"%line
841-
yield"### %s"%self.current_line
842-
843-
return"\n".join(process())
835+
ifhasattr(self,'all_logical_lines'):
836+
# Curtsies
837+
838+
defprocess():
839+
forline,lineTypeinself.all_logical_lines:
840+
iflineType==LineTypeTranslator.INPUT:
841+
yieldline
842+
elifline.rstrip():
843+
yield"# OUT: %s"%line
844+
yield"### %s"%self.current_line
845+
846+
return"\n".join(process())
847+
848+
else:# cli and Urwid
849+
session_output=self.getstdout()
850+
851+
defprocess():
852+
forlineinsession_output.split("\n"):
853+
ifline.startswith(self.ps1):
854+
yieldline[len(self.ps1) :]
855+
elifline.startswith(self.ps2):
856+
yieldline[len(self.ps2) :]
857+
elifline.rstrip():
858+
yield"# OUT: %s"% (line,)
859+
return'\n'.join(process())
844860

845861
defwrite2file(self):
846862
"""Prompt for a filename and write the current contents of the stdout
@@ -952,6 +968,7 @@ def do_pastebin(self, s):
952968
defpush(self,s,insert_into_history=True):
953969
"""Push a line of code onto the buffer so it can process it all
954970
at once when a code block ends"""
971+
# This push method is used by cli and urwid, but not curtsies
955972
s=s.rstrip("\n")
956973
self.buffer.append(s)
957974

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp