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

def IPython::iplib::InteractiveShell::_prefilter (   self,
  line,
  continue_prompt 
) [private]

Calls different preprocessors, depending on the form of line.

Definition at line 2384 of file iplib.py.

02384                                                :
        """Calls different preprocessors, depending on the form of line."""

        # All handlers *must* return a value, even if it's blank ('').

        # Lines are NOT logged here. Handlers should process the line as
        # needed, update the cache AND log it (so that the input cache array
        # stays synced).

        #.....................................................................
        # Code begins

        #if line.startswith('%crash'): raise RuntimeError,'Crash now!'  # dbg

        # save the line away in case we crash, so the post-mortem handler can
        # record it
        self._last_input_line = line

        #print '***line: <%s>' % line # dbg

        if not line:
            # Return immediately on purely empty lines, so that if the user
            # previously typed some whitespace that started a continuation
            # prompt, he can break out of that loop with just an empty line.
            # This is how the default python prompt works.

            # Only return if the accumulated input buffer was just whitespace!
            if ''.join(self.buffer).isspace():
                self.buffer[:] = []
            return ''
        
        line_info = prefilter.LineInfo(line, continue_prompt)
        
        # the input history needs to track even empty lines
        stripped = line.strip()
        
        if not stripped:
            if not continue_prompt:
                self.outputcache.prompt_count -= 1
            return self.handle_normal(line_info)

        # print '***cont',continue_prompt  # dbg
        # special handlers are only allowed for single line statements
        if continue_prompt and not self.rc.multi_line_specials:
            return self.handle_normal(line_info)


        # See whether any pre-existing handler can take care of it  
        rewritten = self.hooks.input_prefilter(stripped)
        if rewritten != stripped: # ok, some prefilter did something
            rewritten = line_info.pre + rewritten  # add indentation
            return self.handle_normal(prefilter.LineInfo(rewritten,
                                                         continue_prompt))
            
        #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest)  # dbg
        
        return prefilter.prefilter(line_info, self)


    def _prefilter_dumb(self, line, continue_prompt):


Generated by  Doxygen 1.6.0   Back to index