Module: sage.server.notebook.worksheet
A Worksheet.
A worksheet is embedded in a webpage that is served by the Sage server. It is a linearly-ordered collections of numbered cells, where a cell is a single input/output block.
Module-level Functions
| s) |
Return everything after the first whitespace in the string s. Returns the empty string if there is nothing after the first whitespace.
Input:
| t) |
| t) |
| s) |
Input:
| text) |
Input: a block of wiki-like marked up text Output:
| text) |
| text) |
| text) |
Output: Everything in text up to the first {{{.
| s) |
| cell_id, completions) |
| aString) |
Given a string s that defines an input block of code, if the first line begins in "sage:" (or "»>"), strip out all lines that don't begin in either "sage:" (or "»>") or "...", and remove all "sage:" (or "»>") and "..." from the beginning of the remaining lines.
TESTS:
sage: test1 = sage.server.notebook.worksheet.__internal_test1 sage: test1 == sage.server.notebook.worksheet.ignore_prompts_and_output(test1) True
sage: test2 = sage.server.notebook.worksheet.__internal_test2 sage: sage.server.notebook.worksheet.ignore_prompts_and_output(test2) '2 + 2\n'
| server, ulimit) |
| server, ulimit) |
| v) |
Return smallest nonnegative integer not in v.
| server, ulimit) |
| s) |
The point of this function is to allow for searches like this:
"ws 7" foo bar Modular '"the" end'
i.e., where search terms can be in quotes and the different quote types can be mixed.
Input:
| name, owner) |
Class: Worksheet
| self, name, dirname, notebook, system, owner, [docbrowser=False], [pretty_print=False]) |
Functions: add_collaborator,
add_viewer,
append,
append_new_cell,
attach,
attached_data_files,
attached_files,
attached_html,
autosave,
best_completion,
cell_id_list,
cell_list,
cells_directory,
check_cell,
check_comp,
check_for_system_switching,
clear,
clear_queue,
collaborators,
completions_html,
compute_cell_id_list,
compute_process_has_been_started,
computing,
conf,
cython_import,
data_directory,
delete_cell_input_files,
delete_cell_with_id,
delete_cells_directory,
delete_notebook_specific_data,
delete_user,
detach,
DIR,
directory,
do_sage_extensions_preparsing,
docbrowser,
edit_save,
edit_text,
enqueue,
eval_asap_no_output,
everyone_has_deleted_this_worksheet,
filename,
filename_without_owner,
get_cell_with_id,
get_snapshot_text_filename,
has_published_version,
hide_all,
html,
html_data_options_list,
html_file_menu,
html_menu,
html_ratings_info,
html_save_discard_buttons,
html_share_publish_buttons,
html_time_last_edited,
html_time_since_last_edited,
html_title,
html_worksheet_body,
hunt_file,
initialize_sage,
input_text,
interrupt,
is_active,
is_archived,
is_doc_worksheet,
is_last_id_and_previous_is_nonempty,
is_owner,
is_published,
is_publisher,
is_rater,
is_trashed,
javascript_confirm_before_leave,
javascript_for_being_active_worksheet,
javascript_for_jsmath_rendering,
last_compute_walltime,
last_edited,
last_to_edit,
load_any_changed_attached_files,
load_path,
move_out_of_trash,
move_to_archive,
move_to_trash,
name,
new_cell_after,
new_cell_before,
next_block_id,
next_hidden_id,
notebook,
owner,
ping,
plain_text,
postprocess_output,
preparse,
preparse_input,
preparse_introspection_input,
preparse_nonswitched_input,
pretty_print,
published_version,
publisher,
queue,
queue_id_list,
quit,
quit_if_idle,
rate,
rating,
ratings,
record_edit,
reset_interact_state,
restart_sage,
revert_to_last_saved_state,
revert_to_snapshot,
sage,
satisfies_search,
save,
save_snapshot,
set_active,
set_cell_counter,
set_collaborators,
set_filename,
set_filename_without_owner,
set_is_doc_worksheet,
set_name,
set_not_computing,
set_owner,
set_pretty_print,
set_published_version,
set_system,
set_user_view,
set_worksheet_that_was_published,
show_all,
snapshot_data,
snapshot_directory,
start_next_comp,
synchro,
synchronize,
system,
time_idle,
time_since_last_edited,
truncated_name,
uncache_snapshot_data,
user_autosave_interval,
user_is_collaborator,
user_is_only_viewer,
user_is_viewer,
user_view,
user_view_is,
viewers,
warn_about_other_person_editing,
worksheet_command,
worksheet_that_was_published
| self) |
Create and append a new cell to the list of cells.
| self, id) |
Check the status on computation of the cell with given id.
Input:
| self, s, C) |
Check for input cells that start with %foo,
where foo is an object with an eval method.
| self) |
Return True precisely if the compute process has been started, irregardless of whether or not it is currently churning away on a computation.
| self) |
Return whether or not a cell is currently being run in the worksheet Sage process.
| self) |
Delete all the files code_%s.py and code_%s.spyx that are created when evaluating cells. We do this when we first start the notebook to get rid of clutter.
| self, id) |
Remove the cell with given id and return the cell before it.
| self, user) |
Delete a user from having any view or ownership of this worksheet.
Input:
We create a notebook with 2 users and 1 worksheet that both view.
sage: n = sage.server.notebook.notebook.Notebook('notebook-test')
sage: n.add_user('wstein','sage','wstein@sagemath.org',force=True)
sage: n.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = n.new_worksheet_with_title_from_text('Sage', owner='sage')
sage: W.add_viewer('wstein')
sage: W.owner()
'sage'
sage: W.viewers()
['wstein']
We delete the sage user from the worksheet W. This makes wstein the new owner.
sage: W.delete_user('sage')
sage: W.viewers()
['wstein']
sage: W.owner()
'wstein'
Then we delete wstein from W, which makes the owner None:
sage: W.delete_user('wstein')
sage: W.owner() is None
True
sage: W.viewers()
[]
Finally, we clean up.
sage: import shutil; shutil.rmtree('notebook-test')
| self) |
Returns a plain-text version of the worksheet with {{{}}} wiki-formatting, suitable for hand editing.
| self, C, [username=None], [next=False]) |
Queue up the cell C for evaluation in this worksheet.
Input:
NOTE: If C.is_asap() is True, then we put C as close to
the beginning of the queue as possible, but after all asap cells.
Otherwise, C goes at the end of the queue.
| self) |
Return the part of the worksheet filename after the last /, i.e., without any information about the owner of this worksheet.
| self) |
Return text version of the input to the worksheet.
| self) |
Interrupt all currently queued up calculations.
Output:
| self, s) |
Modify s by prepending any necessary load commands corresponding to attached files that have changed.
| self, id, [input=]) |
Insert a new cell into the cell list after the cell with the given integer id.
Input:
| self, id, [input=]) |
Insert a new cell into the cell list before the cell with the given integer id. If the id is not the id of any cell, inserts a new cell at the end of the cell list.
Input:
| self, [prompts=False], [banner=True]) |
Return a plain-text version of the worksheet.
Input:
| self, timeout) |
Quit the worksheet process if it has been ``idle'' for more than timeout seconds, where idle is by definition that the worksheet has not reported back that it is actually computing. I.e., an ignored worksheet process (since the user closed their browser) is also considered idle, even if code is running.
| self) |
Reset the interact state of this worksheet.
| self) |
Restart Sage kernel.
| self) |
Return a started up copy of Sage initialized for computations.
If this is a published worksheet, just return None, since published worksheets must not have any compute functionality.
Output: a Sage interface
| self, search) |
Input: search is a string that describes a search query, i.e., a space-separated collections of words.
Output: True if the search is satisfied by self, i.e., all the words appear in the text version of self.
| self, username, threshold) |
Check to see if another user besides username was the last to edit this worksheet during the last threshold seconds. If so, return True and that user name. If not, return False.
Input:
Special Functions: __cmp__,
__getitem__,
__init__,
__len__,
__repr__,
__setstate__,
_enqueue_auto,
_enqueue_auto_cells,
_eval_cmd,
_get_last_identifier,
_load_file,
_new_cell,
_new_text_cell,
_normalized_filenames,
_process_output,
_record_that_we_are_computing,
_save_objects,
_saved_by_info,
_strip_synchro_from_start_of_output