Logo Search packages:      
Sourcecode: ipython version File versions  Download package

def IPython::Magic::Magic::_strip_pasted_lines_for_code (   self,
  raw_lines 
) [private]

Strip non-code parts of a sequence of lines to return a block of
code.

Definition at line 3290 of file Magic.py.

03290                                                      :
        """ Strip non-code parts of a sequence of lines to return a block of
        code.
        """
        # Regular expressions that declare text we strip from the input:
        strip_re =  [r'^\s*In \[\d+\]:', # IPython input prompt
                     r'^\s*(\s?>)+', # Python input prompt
                     r'^\s*\.{3,}', # Continuation prompts
                     r'^\++',
                     ]

        strip_from_start = map(re.compile,strip_re)
        
        lines = []
        for l in raw_lines:
            for pat in strip_from_start: 
                l = pat.sub('',l)
            lines.append(l)
                         
        block = "\n".join(lines) + '\n'
        #print "block:\n",block
        return block

    def _execute_block(self, block, par):


Generated by  Doxygen 1.6.0   Back to index