| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,6 +59,7 @@ | |||
| 59 | 59 | ||
| 60 | 60 | ||
| 61 | 61 | class RuntimeTimer(object): | |
| 62 | + """Calculate running time""" | ||
| 62 | 63 | def __init__(self): | |
| 63 | 64 | self.reset_timer() | |
| 64 | 65 | self.time = time.monotonic if hasattr(time, 'monotonic') else time.time | |
@@ -224,7 +225,7 @@ def showtraceback(self): | |||
| 224 | 225 | tblist[i] = (fname, lineno, module, something) | |
| 225 | 226 | # Set the right lineno (encoding header adds an extra line) | |
| 226 | 227 | if fname == '<input>' and not py3: | |
| 227 | - tblist[i] = (fname, lineno - 2, module, something) | ||
| 228 | + tblist[i] = (fname, lineno - 2, module, something) | ||
| 228 | 229 | ||
| 229 | 230 | l = traceback.format_list(tblist) | |
| 230 | 231 | if l: | |
@@ -787,13 +788,13 @@ def line_is_empty(line): | |||
| 787 | 788 | indentation = 0 | |
| 788 | 789 | return indentation | |
| 789 | 790 | ||
| 790 | - def formatforfile(self, s): | ||
| 791 | + def formatforfile(self, session_ouput): | ||
| 791 | 792 | """Format the stdout buffer to something suitable for writing to disk, | |
| 792 | 793 | i.e. without >>> and ... at input lines and with "# OUT: " prepended to | |
| 793 | 794 | output lines.""" | |
| 794 | 795 | ||
| 795 | 796 | def process(): | |
| 796 | - for line in s.split('\n'): | ||
| 797 | + for line in session_ouput.split('\n'): | ||
| 797 | 798 | if line.startswith(self.ps1): | |
| 798 | 799 | yield line[len(self.ps1):] | |
| 799 | 800 | elif line.startswith(self.ps2): | |
@@ -834,11 +835,11 @@ def write2file(self): | |||
| 834 | 835 | self.interact.notify(_('Save cancelled.')) | |
| 835 | 836 | return | |
| 836 | 837 | ||
| 837 | - s = self.formatforfile(self.getstdout()) | ||
| 838 | + session_test = self.formatforfile(self.getstdout()) | ||
| 838 | 839 | ||
| 839 | 840 | try: | |
| 840 | 841 | with open(fn, mode) as f: | |
| 841 | - f.write(s) | ||
| 842 | + f.write(stdout_text) | ||
| 842 | 843 | except IOError as e: | |
| 843 | 844 | self.interact.notify(_("Error writing file '%s': %s") % (fn, e)) | |
| 844 | 845 | else: | |
@@ -876,8 +877,8 @@ def do_pastebin(self, s): | |||
| 876 | 877 | if s == self.prev_pastebin_content: | |
| 877 | 878 | self.interact.notify(_('Duplicate pastebin. Previous URL: %s. ' | |
| 878 | 879 | 'Removal URL: %s') % | |
| 879 | - (self.prev_pastebin_url, | ||
| 880 | - self.prev_removal_url), 10) | ||
| 880 | + (self.prev_pastebin_url, | ||
| 881 | + self.prev_removal_url), 10) | ||
| 881 | 882 | return self.prev_pastebin_url | |
| 882 | 883 | ||
| 883 | 884 | self.interact.notify(_('Posting data to pastebin...')) | |
@@ -1088,7 +1089,7 @@ def clear_current_line(self): | |||
| 1088 | 1089 | """This is used as the exception callback for the Interpreter instance. | |
| 1089 | 1090 | It prevents autoindentation from occurring after a traceback.""" | |
| 1090 | 1091 | ||
| 1091 | - def send_to_external_editor(self, text, filename=None): | ||
| 1092 | + def send_to_external_editor(self, text): | ||
| 1092 | 1093 | """Returns modified text from an editor, or the original text if editor | |
| 1093 | 1094 | exited with non-zero""" | |
| 1094 | 1095 | ||
@@ -1117,15 +1118,14 @@ def open_in_external_editor(self, filename): | |||
| 1117 | 1118 | return subprocess.call(args) == 0 | |
| 1118 | 1119 | ||
| 1119 | 1120 | def edit_config(self): | |
| 1120 | - if not (os.path.isfile(self.config.config_path)): | ||
| 1121 | + if not os.path.isfile(self.config.config_path): | ||
| 1121 | 1122 | if self.interact.confirm(_("Config file does not exist - create " | |
| 1122 | 1123 | "new from default? (y/N)")): | |
| 1123 | 1124 | try: | |
| 1124 | 1125 | default_config = pkgutil.get_data('bpython', | |
| 1125 | 1126 | 'sample-config') | |
| 1126 | 1127 | if py3: # py3 files need unicode | |
| 1127 | 1128 | default_config = default_config.decode('ascii') | |
| 1128 | - bpython_dir, script_name = os.path.split(__file__) | ||
| 1129 | 1129 | containing_dir = os.path.dirname( | |
| 1130 | 1130 | os.path.abspath(self.config.config_path)) | |
| 1131 | 1131 | if not os.path.exists(containing_dir): | |
@@ -1159,10 +1159,10 @@ def next_indentation(line, tab_length): | |||
| 1159 | 1159 | return indentation | |
| 1160 | 1160 | ||
| 1161 | 1161 | ||
| 1162 | - def next_token_inside_string(s, inside_string): | ||
| 1162 | + def next_token_inside_string(code_string, inside_string): | ||
| 1163 | 1163 | """Given a code string s and an initial state inside_string, return | |
| 1164 | 1164 | whether the next token will be inside a string or not.""" | |
| 1165 | - for token, value in PythonLexer().get_tokens(s): | ||
| 1165 | + for token, value in PythonLexer().get_tokens(code_string): | ||
| 1166 | 1166 | if token is Token.String: | |
| 1167 | 1167 | value = value.lstrip('bBrRuU') | |
| 1168 | 1168 | if value in ['"""', "'''", '"', "'"]: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments