Skip to content

Commit 4c08efe

Browse files
shanahanjrssebastinas
authored andcommitted
Modified repl.py to conform to follow more PEP standards including 8 and 263
[Sebastian Ramacher]: Squashed 204bc17 and 9a0aeda and rebased on current master.
1 parent 7c8cef6 commit 4c08efe

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

bpython/repl.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959

6060

6161
class RuntimeTimer(object):
62+
"""Calculate running time"""
6263
def __init__(self):
6364
self.reset_timer()
6465
self.time = time.monotonic if hasattr(time, 'monotonic') else time.time
@@ -224,7 +225,7 @@ def showtraceback(self):
224225
tblist[i] = (fname, lineno, module, something)
225226
# Set the right lineno (encoding header adds an extra line)
226227
if fname == '<input>' and not py3:
227-
tblist[i] = (fname, lineno - 2, module, something)
228+
tblist[i] = (fname, lineno - 2, module, something)
228229

229230
l = traceback.format_list(tblist)
230231
if l:
@@ -787,13 +788,13 @@ def line_is_empty(line):
787788
indentation = 0
788789
return indentation
789790

790-
def formatforfile(self, s):
791+
def formatforfile(self, session_ouput):
791792
"""Format the stdout buffer to something suitable for writing to disk,
792793
i.e. without >>> and ... at input lines and with "# OUT: " prepended to
793794
output lines."""
794795

795796
def process():
796-
for line in s.split('\n'):
797+
for line in session_ouput.split('\n'):
797798
if line.startswith(self.ps1):
798799
yield line[len(self.ps1):]
799800
elif line.startswith(self.ps2):
@@ -834,11 +835,11 @@ def write2file(self):
834835
self.interact.notify(_('Save cancelled.'))
835836
return
836837

837-
s = self.formatforfile(self.getstdout())
838+
session_test = self.formatforfile(self.getstdout())
838839

839840
try:
840841
with open(fn, mode) as f:
841-
f.write(s)
842+
f.write(stdout_text)
842843
except IOError as e:
843844
self.interact.notify(_("Error writing file '%s': %s") % (fn, e))
844845
else:
@@ -876,8 +877,8 @@ def do_pastebin(self, s):
876877
if s == self.prev_pastebin_content:
877878
self.interact.notify(_('Duplicate pastebin. Previous URL: %s. '
878879
'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)
881882
return self.prev_pastebin_url
882883

883884
self.interact.notify(_('Posting data to pastebin...'))
@@ -1088,7 +1089,7 @@ def clear_current_line(self):
10881089
"""This is used as the exception callback for the Interpreter instance.
10891090
It prevents autoindentation from occurring after a traceback."""
10901091

1091-
def send_to_external_editor(self, text, filename=None):
1092+
def send_to_external_editor(self, text):
10921093
"""Returns modified text from an editor, or the original text if editor
10931094
exited with non-zero"""
10941095

@@ -1117,15 +1118,14 @@ def open_in_external_editor(self, filename):
11171118
return subprocess.call(args) == 0
11181119

11191120
def edit_config(self):
1120-
if not (os.path.isfile(self.config.config_path)):
1121+
if not os.path.isfile(self.config.config_path):
11211122
if self.interact.confirm(_("Config file does not exist - create "
11221123
"new from default? (y/N)")):
11231124
try:
11241125
default_config = pkgutil.get_data('bpython',
11251126
'sample-config')
11261127
if py3: # py3 files need unicode
11271128
default_config = default_config.decode('ascii')
1128-
bpython_dir, script_name = os.path.split(__file__)
11291129
containing_dir = os.path.dirname(
11301130
os.path.abspath(self.config.config_path))
11311131
if not os.path.exists(containing_dir):
@@ -1159,10 +1159,10 @@ def next_indentation(line, tab_length):
11591159
return indentation
11601160

11611161

1162-
def next_token_inside_string(s, inside_string):
1162+
def next_token_inside_string(code_string, inside_string):
11631163
"""Given a code string s and an initial state inside_string, return
11641164
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):
11661166
if token is Token.String:
11671167
value = value.lstrip('bBrRuU')
11681168
if value in ['"""', "'''", '"', "'"]:

0 commit comments

Comments
 (0)