# HG changeset patch
# User Minh Van Nguyen <nguyenminh2@gmail.com>
# Date 1251778289 25200
# Node ID 5b9a551e7b637aa7620d040fd6ef2e3f5f442abe
# Parent 05a268f0db84d9aaf69843a2356856e463ade619
trac 6840: reviewer patch; typo fixes
diff -r 05a268f0db84 -r 5b9a551e7b63 sage/server/introspect.py
a
|
b
|
|
1 | 1 | """ |
2 | 2 | Sage Notebook Introspection |
3 | 3 | |
4 | | """ |
5 | | |
6 | | """ |
7 | 4 | TODO: - add support for grabbing source code from Pyrex functions |
8 | 5 | (even if not perfect is better than nothing). - PNG or MathML |
9 | 6 | output format for docstring |
diff -r 05a268f0db84 -r 5b9a551e7b63 sage/server/misc.py
a
|
b
|
|
78 | 78 | import socket |
79 | 79 | def find_next_available_port(start, max_tries=100, verbose=False): |
80 | 80 | """ |
81 | | Find for the next available port, that is, a port for which a |
| 81 | Find the next available port, that is, a port for which a |
82 | 82 | current connection attempt returns a 'Connection refused' error |
83 | 83 | message. If no port is found, raise a RuntimError exception. |
84 | 84 | |
85 | 85 | INPUT: |
86 | 86 | |
87 | | - ``start`` - an int; the starting port number for the scan |
| 87 | - ``start`` - an int; the starting port number for the scan |
88 | 88 | |
89 | | - ``max_tries`` - an int (default: 100); how many ports to scan |
| 89 | - ``max_tries`` - an int (default: 100); how many ports to scan |
90 | 90 | |
91 | | - ``verbose`` - a bool (default: True); whether to print information |
92 | | about the scan |
| 91 | - ``verbose`` - a bool (default: True); whether to print information |
| 92 | about the scan |
93 | 93 | |
94 | 94 | OUTPUT: |
95 | 95 | |
diff -r 05a268f0db84 -r 5b9a551e7b63 sage/server/notebook/cell.py
a
|
b
|
|
275 | 275 | |
276 | 276 | def id(self): |
277 | 277 | """ |
278 | | Returns self's id. |
| 278 | Returns self's ID. |
279 | 279 | |
280 | 280 | OUTPUT: |
281 | 281 | |
282 | | - int -- self's id. |
| 282 | - int -- self's ID. |
283 | 283 | |
284 | 284 | EXAMPLES:: |
285 | 285 | |
… |
… |
|
291 | 291 | |
292 | 292 | def is_auto_cell(self): |
293 | 293 | """ |
294 | | Returns true if self is automatically evaluated. |
| 294 | Returns True if self is automatically evaluated. |
295 | 295 | |
296 | 296 | EXAMPLES:: |
297 | 297 | |
… |
… |
|
303 | 303 | |
304 | 304 | def __cmp__(self, right): |
305 | 305 | """ |
306 | | Compares cells by `id`. |
| 306 | Compares cells by ID. |
307 | 307 | |
308 | 308 | EXAMPLES:: |
309 | 309 | |
… |
… |
|
734 | 734 | |
735 | 735 | def __cmp__(self, right): |
736 | 736 | """ |
737 | | Compares cells by their `id`s. |
| 737 | Compares cells by their IDs. |
738 | 738 | |
739 | 739 | EXAMPLES:: |
740 | 740 | |
… |
… |
|
1029 | 1029 | def is_interacting(self): |
1030 | 1030 | r""" |
1031 | 1031 | Returns True if this cell is currently interacting with the user. |
1032 | | |
1033 | 1032 | |
1034 | 1033 | EXAMPLES:: |
1035 | 1034 | |
… |
… |
|
1039 | 1038 | sage: C = W.new_cell_after(0, "@interact\ndef f(a=slider(0,10,1,5):\n print a^2") |
1040 | 1039 | sage: C.is_interacting() |
1041 | 1040 | False |
1042 | | |
1043 | 1041 | """ |
1044 | 1042 | return hasattr(self, 'interact') |
1045 | 1043 | |
… |
… |
|
1047 | 1045 | """ |
1048 | 1046 | Stops interaction with user. |
1049 | 1047 | |
1050 | | TODO: Add doctests for :meth:`stop_interacting`. |
1051 | | |
| 1048 | TODO: Add doctests for :meth:`stop_interacting`. |
1052 | 1049 | """ |
1053 | 1050 | if self.is_interacting(): |
1054 | 1051 | del self.interact |
… |
… |
|
1367 | 1364 | |
1368 | 1365 | def process_cell_urls(self, urls): |
1369 | 1366 | """ |
1370 | | Processes urls of the form 'cell://.*?' by replacing the |
| 1367 | Processes URLs of the form ``'cell://.*?'`` by replacing the |
1371 | 1368 | protocol with the path to self and appending self's version |
1372 | 1369 | number. |
1373 | 1370 | |
… |
… |
|
1396 | 1393 | |
1397 | 1394 | INPUT: |
1398 | 1395 | |
1399 | | - ``ncols`` -- maximum number of columns |
| 1396 | - ``ncols`` -- maximum number of columns |
1400 | 1397 | |
1401 | | - ``html`` -- boolean stating whether to output html |
| 1398 | - ``html`` -- boolean stating whether to output HTML |
1402 | 1399 | |
1403 | | - ``raw`` -- boolean stating whether to output raw text |
1404 | | (takes precedence over html) |
| 1400 | - ``raw`` -- boolean stating whether to output raw text |
| 1401 | (takes precedence over HTML) |
1405 | 1402 | |
1406 | | - ``allow_interact`` -- boolean stating whether to allow interaction |
| 1403 | - ``allow_interact`` -- boolean stating whether to allow interaction |
1407 | 1404 | |
1408 | 1405 | EXAMPLES:: |
1409 | 1406 | |
… |
… |
|
1466 | 1463 | Parse HTML for output. |
1467 | 1464 | |
1468 | 1465 | INPUT: |
1469 | | |
1470 | | |
1471 | | - ``s`` -- the input string containing HTML |
| 1466 | |
| 1467 | - ``s`` -- the input string containing HTML |
1472 | 1468 | |
1473 | | - ``ncols`` -- maximum number of columns |
1474 | | |
| 1469 | - ``ncols`` -- maximum number of columns |
1475 | 1470 | |
1476 | 1471 | EXAMPLES:: |
1477 | 1472 | |
… |
… |
|
1774 | 1769 | |
1775 | 1770 | def introspect_html(self): |
1776 | 1771 | """ |
1777 | | Returns html for introspection. |
| 1772 | Returns HTML for introspection. |
1778 | 1773 | |
1779 | 1774 | EXAMPLES:: |
1780 | 1775 | |
… |
… |
|
1978 | 1973 | |
1979 | 1974 | def html(self, wrap=None, div_wrap=True, do_print=False): |
1980 | 1975 | r""" |
1981 | | Returns the html for self. |
| 1976 | Returns the HTML for self. |
1982 | 1977 | |
1983 | 1978 | INPUT: |
1984 | 1979 | |
1985 | 1980 | - ``wrap`` - a boolean stating whether to wrap lines. Defaults to |
1986 | | configuration if not given, |
| 1981 | configuration if not given. |
1987 | 1982 | |
1988 | 1983 | - ``div_wrap`` - a boolean stating whether to wrap ``div``. |
1989 | 1984 | |
… |
… |
|
2187 | 2182 | |
2188 | 2183 | def files_html(self, out): |
2189 | 2184 | """ |
2190 | | Returns html to display the files in self's directory. |
| 2185 | Returns HTML to display the files in self's directory. |
2191 | 2186 | |
2192 | 2187 | INPUT: |
2193 | 2188 | |
2194 | 2189 | - ``out`` - string to exclude files. |
2195 | | Format: To exclude bar, foo, ...`'cell://bar cell://foo ...'` |
| 2190 | Format: To exclude bar, foo, ... ``'cell://bar cell://foo ...'`` |
2196 | 2191 | |
2197 | 2192 | EXAMPLES:: |
2198 | 2193 | |
… |
… |
|
2280 | 2275 | |
2281 | 2276 | def html_out(self, ncols=0, do_print=False): |
2282 | 2277 | r""" |
2283 | | Returns the html for self's output. |
| 2278 | Returns the HTML for self's output. |
2284 | 2279 | |
2285 | 2280 | INPUT: |
2286 | 2281 | |
2287 | | - ``do_print`` -- a boolean stating whether to output html |
2288 | | for print |
| 2282 | - ``do_print`` -- a boolean stating whether to output HTML |
| 2283 | for print |
2289 | 2284 | |
2290 | | - ``ncols`` -- the number of columns |
| 2285 | - ``ncols`` -- the number of columns |
2291 | 2286 | |
2292 | 2287 | EXAMPLES:: |
2293 | 2288 | |
diff -r 05a268f0db84 -r 5b9a551e7b63 sage/server/notebook/docHTMLProcessor.py
a
|
b
|
|
2 | 2 | Live Documentation in the Notebook |
3 | 3 | |
4 | 4 | Processes Sage documentation into notebook worksheet format with |
5 | | evaluatable examples. |
| 5 | evaluable examples. |
6 | 6 | |
7 | 7 | This takes in any HTML document, i.e., Sage documentation, and returns |
8 | 8 | it in the editable format (like the notebook edit window). It also |
… |
… |
|
15 | 15 | |
16 | 16 | Author: |
17 | 17 | |
18 | | - Dorian Raymer (2006): first version |
| 18 | - Dorian Raymer (2006): first version |
19 | 19 | |
20 | | - William Stein (2007-06-10): rewrite to work with twisted Sage notebook |
| 20 | - William Stein (2007-06-10): rewrite to work with twisted Sage notebook |
21 | 21 | |
22 | | - Mike Hansen (2008-09-27): Rewrite to work with Sphinx HTML documentation |
| 22 | - Mike Hansen (2008-09-27): Rewrite to work with Sphinx HTML documentation |
23 | 23 | """ |
24 | 24 | ############################################################################# |
25 | 25 | # Copyright (C) 2007 William Stein <wstein@gmail.com> and Dorian Raimer |
… |
… |
|
140 | 140 | All divs with CSS class="highlight" contain code examples. |
141 | 141 | They include |
142 | 142 | |
143 | | - Models of how the function works. These begin with, e.g., |
144 | | 'INPUT:' and are re-styled as divs with |
145 | | class="usage_model". |
| 143 | - Models of how the function works. These begin with, e.g., |
| 144 | 'INPUT:' and are re-styled as divs with |
| 145 | class="usage_model". |
146 | 146 | |
147 | | - Actual Sage input and ouput. These begin with 'sage:'. |
148 | | The input and output are separated according to the |
149 | | Notebook edit format. |
| 147 | - Actual Sage input and output. These begin with 'sage:'. |
| 148 | The input and output are separated according to the |
| 149 | Notebook edit format. |
150 | 150 | |
151 | 151 | INPUT: |
152 | 152 | |
diff -r 05a268f0db84 -r 5b9a551e7b63 sage/server/notebook/interact.py
a
|
b
|
|
13 | 13 | |
14 | 14 | AUTHORS: |
15 | 15 | |
16 | | - William Stein (2008-03-02): version 1.0 at Sage/Enthought Days |
17 | | 8 in Texas |
| 16 | - William Stein (2008-03-02): version 1.0 at Sage/Enthought Days |
| 17 | 8 in Texas |
18 | 18 | |
19 | | - Jason Grout (2008-03): discussion and first few prototypes |
| 19 | - Jason Grout (2008-03): discussion and first few prototypes |
20 | 20 | |
21 | | - Jason Grout (2008-05): :class:`input_grid` control |
| 21 | - Jason Grout (2008-05): :class:`input_grid` control |
22 | 22 | """ |
23 | 23 | |
24 | 24 | """ |
… |
… |
|
101 | 101 | [ ] make option for text input that correctly gives something of |
102 | 102 | the same type as the default input. |
103 | 103 | [ ] matrix input control (method of matrix space) -- a spreadsheet like thing |
104 | | [ ] a 2d slider: |
105 | | u = ((xmin,xmax),(ymin,ymax)) 2d slider -- NOT IMPLEMENTED |
106 | | [ ] locator in a 2d graphic |
| 104 | [ ] a 2-D slider: |
| 105 | u = ((xmin,xmax),(ymin,ymax)) 2-D slider -- NOT IMPLEMENTED |
| 106 | [ ] locator in a 2-D graphic |
107 | 107 | [ ] tab_view -- represents an object in which clicking the tab |
108 | 108 | with label lbl[i] displays expr[i] |
109 | 109 | [ ] controls: make them easy to customize as below -- |
… |
… |
|
221 | 221 | |
222 | 222 | INPUT: |
223 | 223 | |
224 | | - ``id`` - a string; the DOM id of the slider (better be unique) |
| 224 | - ``id`` - a string; the DOM ID of the slider (better be unique) |
225 | 225 | |
226 | 226 | - ``values`` - a string; 'null' or JavaScript string containing |
227 | 227 | array of values on slider |
… |
… |
|
230 | 230 | the slider is done moving |
231 | 231 | |
232 | 232 | - ``steps`` - an integer; number of steps from minimum to maximum |
233 | | value. |
| 233 | value |
234 | 234 | |
235 | 235 | - ``default`` - an integer (default: 0); the default position of |
236 | 236 | the slider |
… |
… |
|
282 | 282 | |
283 | 283 | INPUT: |
284 | 284 | |
285 | | - ``id`` - a string; the DOM id of the slider (better be unique) |
| 285 | - ``id`` - a string; the DOM ID of the slider (better be unique) |
286 | 286 | |
287 | 287 | - ``values`` - a string; 'null' or JavaScript string containing |
288 | 288 | array of values on slider |
… |
… |
|
291 | 291 | the slider is done moving |
292 | 292 | |
293 | 293 | - ``steps`` - an integer; number of steps from minimum to maximum |
294 | | value. |
| 294 | value |
295 | 295 | |
296 | 296 | - ``default_l`` - an integer (default: 0); the default position of |
297 | 297 | the left edge of the slider |
… |
… |
|
368 | 368 | |
369 | 369 | INPUT: |
370 | 370 | |
371 | | - ``id`` - an integer; the id of the HTML div element that this |
372 | | selector should have |
| 371 | - ``id`` - an integer; the ID of the HTML div element that this |
| 372 | selector should have. |
373 | 373 | |
374 | 374 | - ``change`` - a string; JavaScript code to execute when the color |
375 | 375 | selector changes. |
376 | 376 | |
377 | 377 | - ``default`` - a string (default: ``'000000'``); default color as |
378 | | a 6-character HTML hex string. |
| 378 | a 6-character HTML hexadecimal string. |
379 | 379 | |
380 | 380 | OUTPUT: |
381 | 381 | |
… |
… |
|
631 | 631 | |
632 | 632 | - ``globs`` - a string:object dictionary; the globals |
633 | 633 | interpreter variables, e.g., :func:`globals`, which is |
634 | | useful for evaling value. |
| 634 | useful for evaluating value. |
635 | 635 | |
636 | 636 | OUTPUT: |
637 | 637 | |
… |
… |
|
701 | 701 | |
702 | 702 | def cell_id(self): |
703 | 703 | """ |
704 | | Return the id of the cell that contains this :func:`interact` control. |
| 704 | Return the ID of the cell that contains this :func:`interact` control. |
705 | 705 | |
706 | 706 | OUTPUT: |
707 | 707 | |
708 | | - an integer - id of cell that this control interacts |
| 708 | - an integer - ID of cell that this control interacts |
709 | 709 | |
710 | 710 | EXAMPLES: |
711 | 711 | |
712 | | The output below should equal the id of the current cell:: |
| 712 | The output below should equal the ID of the current cell:: |
713 | 713 | |
714 | 714 | sage: sage.server.notebook.interact.InteractControl('theta', 1).cell_id() |
715 | 715 | 0 |
… |
… |
|
824 | 824 | def value_js(self, n): |
825 | 825 | """ |
826 | 826 | Return JavaScript that evaluates to value of this control. |
827 | | If ``n`` is 0 return code for evaluation by the actual color |
| 827 | If ``n`` is 0, return code for evaluation by the actual color |
828 | 828 | control. If ``n`` is 1, return code for the text area that |
829 | 829 | displays the current color. |
830 | 830 | |
… |
… |
|
1647 | 1647 | |
1648 | 1648 | - ``controls`` - a list of :class:`InteractControl` instances. |
1649 | 1649 | |
1650 | | - ``id`` - an integer; the id of the cell that contains this |
| 1650 | - ``id`` - an integer; the ID of the cell that contains this |
1651 | 1651 | InteractCanvas. |
1652 | 1652 | |
1653 | 1653 | - ``options`` - any additional keyword arguments (for example, |
… |
… |
|
1708 | 1708 | |
1709 | 1709 | def cell_id(self): |
1710 | 1710 | r""" |
1711 | | Returns the cell id associated to this :class:`InteractCanvas`. |
| 1711 | Returns the cell ID associated to this :class:`InteractCanvas`. |
1712 | 1712 | |
1713 | 1713 | OUTPUT: |
1714 | 1714 | |
… |
… |
|
1731 | 1731 | |
1732 | 1732 | - list of controls |
1733 | 1733 | |
1734 | | .. note:: Returns a reference to a mutable list. |
| 1734 | .. note:: |
| 1735 | |
| 1736 | Returns a reference to a mutable list. |
1735 | 1737 | |
1736 | 1738 | EXAMPLES:: |
1737 | 1739 | |
… |
… |
|
1897 | 1899 | |
1898 | 1900 | INPUT: |
1899 | 1901 | |
1900 | | - ``cell_id`` - an integer; the ambient cell's id |
| 1902 | - ``cell_id`` - an integer; the ambient cell's ID |
1901 | 1903 | |
1902 | 1904 | EXAMPLES:: |
1903 | 1905 | |
… |
… |
|
2003 | 2005 | (see defaults below). |
2004 | 2006 | |
2005 | 2007 | |
2006 | | * ``u = input_box(default=None, label=None, type=None)`` - |
2007 | | input box with given ``default``; use ``type=str`` to get |
2008 | | input as an arbitrary string |
| 2008 | * ``u = input_box(default=None, label=None, type=None)`` - |
| 2009 | input box with given ``default``; use ``type=str`` to get |
| 2010 | input as an arbitrary string |
2009 | 2011 | |
2010 | 2012 | |
2011 | | * ``u = slider(vmin, vmax=None, step_size=1, default=None, |
2012 | | label=None)`` - slider with given list of possible values; |
2013 | | ``vmin`` can be a list |
| 2013 | * ``u = slider(vmin, vmax=None, step_size=1, default=None, |
| 2014 | label=None)`` - slider with given list of possible values; |
| 2015 | ``vmin`` can be a list |
2014 | 2016 | |
2015 | 2017 | |
2016 | | * ``u = range_slider(vmin, vmax=None, step_size=1, |
2017 | | default=None, label=None)`` - range slider with given list |
2018 | | of possible values; ``vmin`` can be a list |
| 2018 | * ``u = range_slider(vmin, vmax=None, step_size=1, |
| 2019 | default=None, label=None)`` - range slider with given list |
| 2020 | of possible values; ``vmin`` can be a list |
2019 | 2021 | |
2020 | 2022 | |
2021 | | * ``u = checkbox(default=True, label=None)`` - a checkbox |
| 2023 | * ``u = checkbox(default=True, label=None)`` - a checkbox |
2022 | 2024 | |
2023 | 2025 | |
2024 | | * ``u = selector(values, label=None, nrows=None, ncols=None, |
2025 | | buttons=False)`` - a dropdown menu or buttons (get buttons |
2026 | | if ``nrows``, ``ncols``, or ``buttons`` is set, otherwise a |
2027 | | dropdown menu) |
| 2026 | * ``u = selector(values, label=None, nrows=None, ncols=None, |
| 2027 | buttons=False)`` - a dropdown menu or buttons (get buttons |
| 2028 | if ``nrows``, ``ncols``, or ``buttons`` is set, otherwise a |
| 2029 | dropdown menu) |
2028 | 2030 | |
2029 | 2031 | |
2030 | | * ``u = input_grid(nrows, ncols, default=None, label=None, |
2031 | | to_value=lambda x:x, width=4)`` - an editable grid of |
2032 | | objects (a matrix or array) |
| 2032 | * ``u = input_grid(nrows, ncols, default=None, label=None, |
| 2033 | to_value=lambda x:x, width=4)`` - an editable grid of |
| 2034 | objects (a matrix or array) |
2033 | 2035 | |
2034 | 2036 | |
2035 | | * ``u = text_control(value='')`` - a block of text |
| 2037 | * ``u = text_control(value='')`` - a block of text |
2036 | 2038 | |
2037 | 2039 | |
2038 | 2040 | You can create a color selector by setting the default value for a |
… |
… |
|
2045 | 2047 | your function. These are all just convenient shortcuts for |
2046 | 2048 | creating the controls listed above. |
2047 | 2049 | |
2048 | | * ``u`` - blank input_box field |
| 2050 | * ``u`` - blank input_box field |
2049 | 2051 | |
2050 | | * ``u = element`` - input_box with ``default=element``, if |
2051 | | element not below. |
| 2052 | * ``u = element`` - input_box with ``default=element``, if |
| 2053 | element not below. |
2052 | 2054 | |
2053 | | * ``u = (umin,umax)`` - continuous slider (really `100` steps) |
| 2055 | * ``u = (umin,umax)`` - continuous slider (really `100` steps) |
2054 | 2056 | |
2055 | | * ``u = (umin,umax,du)`` - slider with step size ``du`` |
| 2057 | * ``u = (umin,umax,du)`` - slider with step size ``du`` |
2056 | 2058 | |
2057 | | * ``u = list`` - buttons if ``len(list)`` at most `5`; |
2058 | | otherwise, drop down |
| 2059 | * ``u = list`` - buttons if ``len(list)`` at most `5`; |
| 2060 | otherwise, drop down |
2059 | 2061 | |
2060 | | * ``u = generator`` - a slider (up to `10000` steps) |
| 2062 | * ``u = generator`` - a slider (up to `10000` steps) |
2061 | 2063 | |
2062 | | * ``u = bool`` - a checkbox |
| 2064 | * ``u = bool`` - a checkbox |
2063 | 2065 | |
2064 | | * ``u = Color('blue')`` - a 2D RGB color selector; returns |
2065 | | ``Color`` object |
| 2066 | * ``u = Color('blue')`` - a 2-D RGB color selector; returns |
| 2067 | ``Color`` object |
2066 | 2068 | |
2067 | | * ``u = (default, v)`` - ``v`` as above, with given |
2068 | | ``default`` value |
| 2069 | * ``u = (default, v)`` - ``v`` as above, with given |
| 2070 | ``default`` value |
2069 | 2071 | |
2070 | | * ``u = (label, v)`` - ``v`` as above, with given ``label`` |
2071 | | (a string) |
| 2072 | * ``u = (label, v)`` - ``v`` as above, with given ``label`` |
| 2073 | (a string) |
2072 | 2074 | |
2073 | | * ``u = matrix`` - an ``input_grid`` with ``to_value`` set to |
2074 | | ``matrix.parent()`` and default values given by the matrix |
| 2075 | * ``u = matrix`` - an ``input_grid`` with ``to_value`` set to |
| 2076 | ``matrix.parent()`` and default values given by the matrix |
2075 | 2077 | |
2076 | 2078 | .. note:: |
2077 | 2079 | |
2078 | | Suppose you would like to make a interactive with a default |
| 2080 | Suppose you would like to make an interactive with a default |
2079 | 2081 | RGB color of ``(1,0,0)``, so the function would have signature |
2080 | 2082 | ``f(color=(1,0,0))``. Unfortunately, the above shortcuts |
2081 | 2083 | reinterpret the ``(1,0,0)`` as a discrete slider with step |
… |
… |
|
2165 | 2167 | ... show(L) |
2166 | 2168 | <html>... |
2167 | 2169 | |
2168 | | You can rotate and zoom into 3D graphics while interacting with a |
| 2170 | You can rotate and zoom into 3-D graphics while interacting with a |
2169 | 2171 | variable:: |
2170 | 2172 | |
2171 | 2173 | sage: @interact |
… |
… |
|
2183 | 2185 | ... show(G, figsize=5, xmin=0, ymin=0) |
2184 | 2186 | <html>... |
2185 | 2187 | |
2186 | | Two "sinks" displayed simultaneously via a contour plot and a 3D |
| 2188 | Two "sinks" displayed simultaneously via a contour plot and a 3-D |
2187 | 2189 | interactive plot:: |
2188 | 2190 | |
2189 | 2191 | sage: @interact |
… |
… |
|
2729 | 2731 | - ``display_value`` - a bool, whether to display the current |
2730 | 2732 | value to the right of the slider |
2731 | 2733 | |
2732 | | EXAMPLES:: |
| 2734 | EXAMPLES: |
2733 | 2735 | |
2734 | 2736 | We specify both ``vmin`` and ``vmax``. We make the default |
2735 | 2737 | `3`, but since `3` isn't one of `3/17`-th spaced values |
… |
… |
|
2850 | 2852 | - ``display_value`` - a bool, whether to display the current |
2851 | 2853 | value below the slider |
2852 | 2854 | |
2853 | | EXAMPLES:: |
| 2855 | EXAMPLES: |
2854 | 2856 | |
2855 | 2857 | We specify both ``vmin`` and ``vmax``. We make the default |
2856 | 2858 | `(3,4)` but since neither is one of `3/17`-th spaced |
… |
… |
|
3290 | 3292 | |
3291 | 3293 | INPUT: |
3292 | 3294 | |
3293 | | - ``cell_id`` - an integer; the id of an :func:`interact` cell |
| 3295 | - ``cell_id`` - an integer; the ID of an :func:`interact` cell |
3294 | 3296 | |
3295 | 3297 | - ``var`` - an object; a variable associated to that cell |
3296 | 3298 | |
diff -r 05a268f0db84 -r 5b9a551e7b63 sage/server/notebook/notebook.py
a
|
b
|
|
161 | 161 | """ |
162 | 162 | try: |
163 | 163 | dir = self.__absdir |
164 | | except AttributeErrro: |
| 164 | except AttributeError: |
165 | 165 | dir = self.__dir |
166 | 166 | import shutil |
167 | 167 | # We ignore_errors because in rare parallel doctesting |
… |
… |
|
330 | 330 | |
331 | 331 | def user_is_admin(self, user): |
332 | 332 | """ |
333 | | Return true if ``user`` is an admin. |
| 333 | Return True if ``user`` is an admin. |
334 | 334 | |
335 | 335 | INPUT: |
336 | 336 | |
… |
… |
|
354 | 354 | |
355 | 355 | def user_is_guest(self, username): |
356 | 356 | """ |
357 | | Return true if ``username`` is a guest. |
| 357 | Return True if ``username`` is a guest. |
358 | 358 | |
359 | 359 | INPUT: |
360 | 360 | |
… |
… |
|
830 | 830 | |
831 | 831 | - a list of strings. |
832 | 832 | |
833 | | EXAMPLES: We make a new notebook with two users and two worksheets, |
| 833 | EXAMPLES: |
| 834 | |
| 835 | We make a new notebook with two users and two worksheets, |
834 | 836 | then list their names:: |
835 | 837 | |
836 | 838 | sage: nb = sage.server.notebook.notebook.Notebook(tmp_dir()) |
… |
… |
|
1061 | 1063 | |
1062 | 1064 | - ``worksheet`` - a newly created Worksheet instance |
1063 | 1065 | |
1064 | | EXAMPLES: We create a notebook and import a plain text worksheet |
| 1066 | EXAMPLES: |
| 1067 | |
| 1068 | We create a notebook and import a plain text worksheet |
1065 | 1069 | into it. |
1066 | 1070 | |
1067 | 1071 | :: |
… |
… |
|
1108 | 1112 | |
1109 | 1113 | - a new instance of Worksheet |
1110 | 1114 | |
1111 | | EXAMPLES: We write a plain text worksheet to a file and import it |
| 1115 | EXAMPLES: |
| 1116 | |
| 1117 | We write a plain text worksheet to a file and import it |
1112 | 1118 | using this function. |
1113 | 1119 | |
1114 | 1120 | :: |
diff -r 05a268f0db84 -r 5b9a551e7b63 sage/server/notebook/template.py
a
|
b
|
|
4 | 4 | |
5 | 5 | AUTHORS: |
6 | 6 | |
7 | | - Bobby Moretti (2007-07-18): initial version |
| 7 | - Bobby Moretti (2007-07-18): initial version |
8 | 8 | |
9 | | - Timothy Clemans and Mike Hansen (2008-10-27): major update |
10 | | |
| 9 | - Timothy Clemans and Mike Hansen (2008-10-27): major update |
11 | 10 | """ |
12 | 11 | ############################################################################# |
13 | 12 | # Copyright (C) 2007 William Stein <wstein@gmail.com> |
… |
… |
|
62 | 61 | INPUT: |
63 | 62 | |
64 | 63 | - ``filename`` - a string; the filename of the template relative |
65 | | to $SAGE_ROOT/devel/sage/sage/server/notebook/templates |
| 64 | to ``SAGE_ROOT/devel/sage/sage/server/notebook/templates`` |
66 | 65 | |
67 | 66 | - ``user_context`` - a dictionary; the context in which to evaluate |
68 | 67 | the file's template variables |
diff -r 05a268f0db84 -r 5b9a551e7b63 sage/server/notebook/worksheet.py
a
|
b
|
|
9 | 9 | worksheet, spawning Sage processes that do all of the actual work |
10 | 10 | and are controlled via pexpect, and reporting on results of |
11 | 11 | calculations. The state of the cells in a worksheet is stored on |
12 | | the filesystem (not in the notebook pickle sobj). |
| 12 | the file system (not in the notebook pickle sobj). |
13 | 13 | |
14 | 14 | AUTHORS: |
15 | 15 | |
… |
… |
|
293 | 293 | |
294 | 294 | |
295 | 295 | - ``-1,0,1`` - comparison is on the underlying |
296 | | filenames. |
| 296 | file names. |
297 | 297 | |
298 | 298 | |
299 | 299 | EXAMPLES:: |
… |
… |
|
738 | 738 | |
739 | 739 | def attached_data_files(self): |
740 | 740 | """ |
741 | | Return a list of the filenames of files in the worksheet data |
| 741 | Return a list of the file names of files in the worksheet data |
742 | 742 | directory. |
743 | 743 | |
744 | 744 | OUTPUT: list of strings |
… |
… |
|
842 | 842 | INPUT: |
843 | 843 | |
844 | 844 | |
845 | | - ``sysem`` - string (default: 'sage') |
| 845 | - ``system`` - string (default: 'sage') |
846 | 846 | |
847 | 847 | |
848 | 848 | EXAMPLES:: |
… |
… |
|
896 | 896 | |
897 | 897 | The reason the input is a string and lower case instead of |
898 | 898 | a Python bool is because this gets called indirectly from |
899 | | javascript. (And, Jason Grout wrote this and didn't realize |
| 899 | JavaScript. (And, Jason Grout wrote this and didn't realize |
900 | 900 | how unpythonic this design is - it should be redone to use |
901 | 901 | True/False.) |
902 | 902 | |
… |
… |
|
1143 | 1143 | |
1144 | 1144 | - ``comment`` - string |
1145 | 1145 | |
1146 | | - ``usename`` - string |
| 1146 | - ``username`` - string |
1147 | 1147 | |
1148 | 1148 | |
1149 | 1149 | EXAMPLES: We create a worksheet and rate it, then look at the |
… |
… |
|
1263 | 1263 | |
1264 | 1264 | def rating(self): |
1265 | 1265 | """ |
1266 | | Return overall aerage rating of self. |
| 1266 | Return overall average rating of self. |
1267 | 1267 | |
1268 | 1268 | OUTPUT: float or the int -1 to mean "not rated" |
1269 | 1269 | |
… |
… |
|
1930 | 1930 | def limit_snapshots(self): |
1931 | 1931 | r""" |
1932 | 1932 | This routine will limit the number of snapshots of a worksheet, |
1933 | | as specified by a hard-cioded value below. |
| 1933 | as specified by a hard-coded value below. |
1934 | 1934 | |
1935 | 1935 | Prior behavior was to allow unlimited numbers of snapshots and |
1936 | 1936 | so this routine will not delete files created prior to this change. |
… |
… |
|
2097 | 2097 | - ``text`` - a string |
2098 | 2098 | |
2099 | 2099 | - ``ignore_ids`` - bool (default: False); if True |
2100 | | ignore all the id's in the {{{}}} code block. |
| 2100 | ignore all the IDs in the {{{}}} code block. |
2101 | 2101 | |
2102 | 2102 | |
2103 | 2103 | EXAMPLES: We create a new test notebook and a worksheet. |
… |
… |
|
2214 | 2214 | confirm_before_leave=False, read_only=False): |
2215 | 2215 | r""" |
2216 | 2216 | INPUT: |
2217 | | |
2218 | 2217 | |
2219 | 2218 | - publish - a boolean stating whether the worksheet is published |
2220 | 2219 | |
2221 | 2220 | - do_print - a boolean |
2222 | 2221 | |
2223 | 2222 | OUTPUT: |
2224 | | |
2225 | | |
2226 | | - string -- the html for the worksheet |
| 2223 | |
| 2224 | - string -- the HTML for the worksheet |
2227 | 2225 | |
2228 | 2226 | EXAMPLES:: |
2229 | 2227 | |
… |
… |
|
2281 | 2279 | r""" |
2282 | 2280 | OUTPUT: |
2283 | 2281 | |
2284 | | - string -- the html for the save, discard, etc. buttons |
| 2282 | - string -- the HTML for the save, discard, etc. buttons |
2285 | 2283 | |
2286 | 2284 | EXAMPLES:: |
2287 | 2285 | |
… |
… |
|
2295 | 2293 | def html_share_publish_buttons(self, select=None, backwards=False): |
2296 | 2294 | r""" |
2297 | 2295 | INPUT: |
2298 | | |
2299 | 2296 | |
2300 | 2297 | - select - a boolean |
2301 | 2298 | |
2302 | 2299 | - backwards - a boolean |
2303 | 2300 | |
2304 | 2301 | OUTPUT: |
2305 | | |
2306 | | |
2307 | | - string -- the html for the share, publish, etc. buttons |
| 2302 | |
| 2303 | - string -- the HTML for the share, publish, etc. buttons |
2308 | 2304 | |
2309 | 2305 | EXAMPLES:: |
2310 | 2306 | |
… |
… |
|
2324 | 2320 | r""" |
2325 | 2321 | OUTPUT: |
2326 | 2322 | |
2327 | | - string -- the html for the menus of the worksheet |
| 2323 | - string -- the HTML for the menus of the worksheet |
2328 | 2324 | |
2329 | 2325 | EXAMPLES:: |
2330 | 2326 | |
… |
… |
|
2344 | 2340 | def html_worksheet_body(self, do_print, publish=False): |
2345 | 2341 | r""" |
2346 | 2342 | INPUT: |
2347 | | |
2348 | 2343 | |
2349 | 2344 | - publish - a boolean stating whether the worksheet is published |
2350 | 2345 | |
2351 | 2346 | - do_print - a boolean |
2352 | 2347 | |
2353 | 2348 | OUTPUT: |
2354 | | |
2355 | | |
2356 | | - string -- the html for the File menu of the worksheet |
| 2349 | |
| 2350 | - string -- the HTML for the File menu of the worksheet |
2357 | 2351 | |
2358 | 2352 | EXAMPLES:: |
2359 | 2353 | |
… |
… |
|
2419 | 2413 | |
2420 | 2414 | INPUT: |
2421 | 2415 | |
2422 | | |
2423 | 2416 | - ``username`` - user who would like to edit this |
2424 | 2417 | file. |
2425 | 2418 | |
… |
… |
|
3162 | 3155 | - ``C`` - a Cell |
3163 | 3156 | |
3164 | 3157 | - ``username`` - the name of the user that is |
3165 | | evaluating this cell (mainly used for loging) |
| 3158 | evaluating this cell (mainly used for login) |
3166 | 3159 | |
3167 | 3160 | |
3168 | 3161 | .. note:: |
diff -r 05a268f0db84 -r 5b9a551e7b63 sage/server/support.py
a
|
b
|
|
243 | 243 | |
244 | 244 | def source_code(s, globs, system='sage'): |
245 | 245 | r""" |
246 | | Format an object's source code to process and display in the the |
| 246 | Format an object's source code to process and display in the |
247 | 247 | Sage notebook. |
248 | 248 | |
249 | 249 | INPUT: |