Ticket #1733: sage-1733.patch

File sage-1733.patch, 2.0 KB (added by was, 13 years ago)
  • sage/server/notebook/worksheet.py

    # HG changeset patch
    # User William Stein <wstein@gmail.com>
    # Date 1210460148 25200
    # Node ID 86cd4f04b3fda1c297f73c57d807ee03cdd83662
    # Parent  efd67c0fc8f8a907697eb7e4d9bc5015254970ee
    # Trac 1733 -- %foo cells in the notebook
         1. Fixed the problem where %foobar with no input in the cell didn't give an error -- now it does, about foobar not being defined.
    
         2. While I was at it I improved how %foo modes in the notebook work, so that they can have everything
    on one line, e.g.,
       %magma Factorization(9038049823)
    on a single line works in the notebook.
    
         3. NOTE that the actual patch replaces a bunch of crappy hard to understand code with like 3 simple lines that fix all of the above.
    
    diff -r efd67c0fc8f8 -r 86cd4f04b3fd sage/server/notebook/worksheet.py
    a b class Worksheet: 
    21862186            s = t
    21872187        if s.startswith("%cython") or s.startswith("%pyrex") or s.startswith("%sagex"):  # a block of Cython code.
    21882188            return True, self.cython_import(after_first_word(s).lstrip(), C)
    2189            
    2190         i = s.find('\n')
    2191         if i == -1:
    2192             # nothing to evaluate
    2193             return True, ''
    2194         j = s.find(' ')
    2195         if j == -1:
    2196             j = i
    2197         else:
    2198             j = min(i,j)
    2199         sys = s[1:j]
    2200         s = s[i+1:]
    2201         cmd = self._eval_cmd(sys, s, os.path.abspath(C.directory()))
    2202         if sys == 'html':
     2189
     2190        # Determine system = the system doing the computation, e.g., %magma, and
     2191        #           code_to_eval = the code to feed to the system via .eval.
     2192        system = first_word(s)[1:]     # get rid of the percent sign.
     2193        code_to_eval = after_first_word(s)
     2194        cmd = self._eval_cmd(system, code_to_eval, os.path.abspath(C.directory()))
     2195        if system == 'html':
    22032196            C.set_is_html(True)
    22042197        return True, cmd
    22052198