Skip to content

Commit df8de90

Browse files
committed
tConvert red to python 3
1 parent 71f8618 commit df8de90

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

commands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def run(self, execute, prompt, ctx):
7979
<dim>(time travel)</dim> """))
8080

8181
time = prompt(banner)
82-
if not len(time):
82+
if not time:
8383
return
8484

8585
now = int(ctx['loc'].get('time') or 0)
@@ -125,7 +125,7 @@ class Print(Command):
125125

126126
def run(self, execute, prompt, ctx):
127127
var = prompt(vt100.magenta(vt100.dim('(print) ')))
128-
if not len(var):
128+
if not var:
129129
return
130130
output = execute('print ' + var)
131131
return vt100.magenta(output)
@@ -198,7 +198,7 @@ class Custom(Command):
198198

199199
def run(self, execute, prompt, ctx):
200200
command = prompt(vt100.dim('(odb) '))
201-
if not len(command):
201+
if not command:
202202
return
203203
output = execute(command)
204204
return vt100.blue('>> {0}\n'.format(command)) + output

red.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515

1616
debugger_log = open('/tmp/red.log', 'w')
17+
1718
def trace(text):
1819
debugger_log.write(text)
1920
debugger_log.flush()
@@ -116,7 +117,7 @@ def hl(src, breakpoint_lines):
116117
text = re.sub(a_ptrn, vt100.bold('\\1'), text)
117118
text = re.sub(b_ptrn, vt100.bold('\\1'), text)
118119

119-
symbol = u'\u2022' if has_breakpoint else ' '
120+
symbol = '\u2022' if has_breakpoint else ' '
120121

121122
# Can't use red twice, the closing color tag will mess the outputs
122123
if not is_current:
@@ -170,9 +171,10 @@ def main(args):
170171
return 1
171172

172173
dbgr = subprocess.Popen(['ocamldebug', '-emacs'] + command_line,
174+
encoding='utf-8',
173175
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
174176

175-
print(debugger_command(dbgr, '')[0].replace('\tOCaml Debugger version ', vt100.red(u'\u2022 RED') + ' OCamlDebug v'))
177+
print(debugger_command(dbgr, '')[0].replace('\tOCaml Debugger version ', vt100.red('\u2022 RED') + ' OCamlDebug v'))
176178
print(vt100.dim('Press ? for help'))
177179
print(debugger_command(dbgr, 'start')[0])
178180

@@ -215,9 +217,9 @@ def prompt(text):
215217
file_name = loc.get('file')
216218
listing = hl(execute('list'), breakpoint_lines_for_file(breakpoints, file_name))
217219
if listing:
218-
console.print_text((u'\u2500[ %s ]' % loc.get('file')) + u'\u2500' * 300)
220+
console.print_text(('\u2500[ %s ]' % loc.get('file')) + '\u2500' * 300)
219221
console.print_text(listing)
220-
console.print_text(u'\u2500' * 300)
222+
console.print_text('\u2500' * 300)
221223
else:
222224
module = loc.get('module')
223225
if module:

vt100.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def print_text(self, text):
7272
def safe_input(self, prompt=None):
7373
self.lines_printed += 1
7474
try:
75-
return raw_input(prompt)
75+
return input(prompt)
7676
except:
7777
pass
7878

0 commit comments

Comments
 (0)