| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d632b51 commit cd01afd
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1164,6 +1164,8 @@ def push(self, line, insert_into_history=True): | |||
| 1164 | 1164 | ||
| 1165 | 1165 | If the interpreter successfully runs the code, clear the buffer | |
| 1166 | 1166 | """ | |
| 1167 | + # Note that push() overrides its parent without calling it, unlike | ||
| 1168 | + # urwid and cli which implement custom behavior and call repl.Repl.push | ||
| 1167 | 1169 | if self.paste_mode: | |
| 1168 | 1170 | self.saved_indent = 0 | |
| 1169 | 1171 | else: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -832,15 +832,31 @@ def get_session_formatted_for_file(self): | |||
| 832 | 832 | i.e. without >>> and ... at input lines and with "# OUT: " prepended to | |
| 833 | 833 | output lines and "### " prepended to current line""" | |
| 834 | 834 | ||
| 835 | - def process(): | ||
| 836 | - for line, lineType in self.all_logical_lines: | ||
| 837 | - if lineType == LineTypeTranslator.INPUT: | ||
| 838 | - yield line | ||
| 839 | - elif line.rstrip(): | ||
| 840 | - yield "# OUT: %s" % line | ||
| 841 | - yield "### %s" % self.current_line | ||
| 842 | - | ||
| 843 | - return "\n".join(process()) | ||
| 835 | + if hasattr(self, 'all_logical_lines'): | ||
| 836 | + # Curtsies | ||
| 837 | + | ||
| 838 | + def process(): | ||
| 839 | + for line, lineType in self.all_logical_lines: | ||
| 840 | + if lineType == LineTypeTranslator.INPUT: | ||
| 841 | + yield line | ||
| 842 | + elif line.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 | + def process(): | ||
| 852 | + for line in session_output.split("\n"): | ||
| 853 | + if line.startswith(self.ps1): | ||
| 854 | + yield line[len(self.ps1) :] | ||
| 855 | + elif line.startswith(self.ps2): | ||
| 856 | + yield line[len(self.ps2) :] | ||
| 857 | + elif line.rstrip(): | ||
| 858 | + yield "# OUT: %s" % (line,) | ||
| 859 | + return '\n'.join(process()) | ||
| 844 | 860 | ||
| 845 | 861 | def write2file(self): | |
| 846 | 862 | """Prompt for a filename and write the current contents of the stdout | |
@@ -952,6 +968,7 @@ def do_pastebin(self, s): | |||
| 952 | 968 | def push(self, s, insert_into_history=True): | |
| 953 | 969 | """Push a line of code onto the buffer so it can process it all | |
| 954 | 970 | at once when a code block ends""" | |
| 971 | + # This push method is used by cli and urwid, but not curtsies | ||
| 955 | 972 | s = s.rstrip("\n") | |
| 956 | 973 | self.buffer.append(s) | |
| 957 | 974 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments