|
1 | 1 | # -*- coding: utf-8; mode: sage -*-
|
2 | 2 | from __future__ import print_function
|
3 | 3 |
|
4 | | -from sage.repl.rich_output.output_catalog import OutputImagePng |
| 4 | +import sage.misc.latex |
| 5 | +from emacs_sage_shell import read_file_and_run_cell as ss_read_file_and_run_cell |
| 6 | +from emacs_sage_shell import ip |
| 7 | +from sage.repl.rich_output import get_display_manager |
5 | 8 | from sage.repl.rich_output.backend_ipython import BackendIPythonCommandline
|
6 | 9 | from sage.repl.rich_output.output_basic import OutputLatex
|
7 | | -from sage.repl.rich_output import get_display_manager |
| 10 | +from sage.repl.rich_output.output_catalog import OutputImagePng |
8 | 11 | from sage.repl.rich_output.preferences import DisplayPreferences
|
9 | | -import sage.misc.latex |
10 | | -from emacs_sage_shell import ip |
11 | 12 |
|
12 | 13 |
|
13 | 14 | class LastState(object):
|
@@ -67,22 +68,29 @@ def displayhook(self, plain_text, rich_output):
|
67 | 68 | gdm = get_display_manager()
|
68 | 69 |
|
69 | 70 |
|
70 | | -def run_cell_babel(code, filename=None, latex=None, latex_formatter=None): |
| 71 | +def run_cell_babel_base(run_cell_func, |
| 72 | + filename=None, latex=None, latex_formatter=None): |
71 | 73 | last_state.filename = filename
|
72 | 74 | last_state.result = None
|
73 | 75 | last_state.latex = latex
|
74 | 76 | last_state.latex_formatter = latex_formatter
|
75 | 77 |
|
76 | 78 | backend_ob_sage = BackendEmacsBabel(last_state)
|
77 | 79 | with sagebackend(backend_ob_sage):
|
78 | | - res = ip.run_cell(code) |
| 80 | + res = run_cell_func() |
79 | 81 | if res.success:
|
80 | 82 | last_state.result = res.result
|
81 | 83 | print(1)
|
82 | 84 | else:
|
83 | 85 | print(0)
|
84 | 86 |
|
85 | 87 |
|
| 88 | +def read_file_and_run_cell(tmp_file, **kwargs): |
| 89 | + def run_cel_func(): |
| 90 | + return ss_read_file_and_run_cell(tmp_file) |
| 91 | + run_cell_babel_base(run_cel_func, **kwargs) |
| 92 | + |
| 93 | + |
86 | 94 | class WithBackEnd(object):
|
87 | 95 |
|
88 | 96 | def __init__(self, back_end):
|
|
0 commit comments