# HG changeset patch
# User William Stein <wstein@gmail.com>
# Date 1262324176 28800
# Node ID e8fbf41f25bc55738ec8d1c77a62ff12bb7ea918
# Parent d5c94309582791ac3c3585d5edb5102c1bdd42c4
trac 7514 -- (part 3) -- rewrite load/attach
diff --git a/sagenb/notebook/cell.py b/sagenb/notebook/cell.py
a
|
b
|
|
2082 | 2082 | return '' |
2083 | 2083 | images = [] |
2084 | 2084 | files = [] |
| 2085 | |
| 2086 | from worksheet import CODE_PY |
2085 | 2087 | # The question mark trick here is so that images will be reloaded when |
2086 | 2088 | # the async request requests the output text for a computation. |
2087 | 2089 | # This is inspired by http://www.irt.org/script/416.htm/. |
2088 | 2090 | for F in D: |
2089 | | if 'cell://%s'%F in out: |
| 2091 | if os.path.split(F)[-1] == CODE_PY or 'cell://%s'%F in out: |
2090 | 2092 | continue |
2091 | 2093 | url = os.path.join(self.url_to_self(), F) |
2092 | 2094 | if F.endswith('.png') or F.endswith('.bmp') or \ |
diff --git a/sagenb/notebook/worksheet.py b/sagenb/notebook/worksheet.py
a
|
b
|
|
3639 | 3639 | return support.get_rightmost_identifier(s) |
3640 | 3640 | |
3641 | 3641 | def preparse(self, s): |
3642 | | return 'open("%s","w").write(_support_.preparse_worksheet_cell(base64.b64decode("%s"),globals())); execfile(os.path.abspath("%s"))'%(CODE_PY, base64.b64encode(s), CODE_PY) |
| 3642 | """ |
| 3643 | Return preparsed version of input code s, ready to be sent to |
| 3644 | the Sage process for evaluation. The output is a "safe string" |
| 3645 | (no funny characters). |
| 3646 | |
| 3647 | INPUT: |
| 3648 | |
| 3649 | - `s` -- a string |
| 3650 | |
| 3651 | OUTPUT: |
| 3652 | |
| 3653 | - a string |
| 3654 | """ |
| 3655 | # The extra newline below is necessary, since otherwise source |
| 3656 | # code introspection doesn't include the last line. |
| 3657 | return 'open("%s","w").write(_support_.preparse_worksheet_cell(base64.b64decode("%s"),globals())+"\\n"); execfile(os.path.abspath("%s"))'%(CODE_PY, base64.b64encode(s), CODE_PY) |
3643 | 3658 | |
3644 | 3659 | ########################################################## |
3645 | 3660 | # Loading and attaching files |