;ò
ÎÑAHc           @   s}   d  Z  d k l Z d e i d Z e i Z d k Z d k l	 Z	 e i
 d ƒ Z d „  Z d „  Z d	 „  Z e ƒ  d
 GHd S(   s  Modified input prompt for entering text with >>> or ... at the start.

We define a special input line filter to allow typing lines which begin with
'>>> ' or '... '. These two strings, if present at the start of the input
line, are stripped. This allows for direct pasting of code from examples such
as those available in the standard Python tutorial.

Normally pasting such code is one chunk is impossible because of the
extraneous >>> and ..., requiring one to do a line by line paste with careful
removal of those characters. This module allows pasting that kind of
multi-line examples in one pass.

Here is an 'screenshot' of a section of the tutorial pasted into IPython with
this feature enabled:

In [1]: >>> def fib2(n): # return Fibonacci series up to n
   ...: ...     '''Return a list containing the Fibonacci series up to n.'''
   ...: ...     result = []
   ...: ...     a, b = 0, 1
   ...: ...     while b < n:
   ...: ...         result.append(b)    # see below
   ...: ...         a, b = b, a+b
   ...: ...     return result
   ...:

In [2]: fib2(10)
Out[2]: [1, 1, 2, 3, 5, 8]

The >>> and ... are stripped from the input so that the python interpreter
only sees the real part of the code.

All other input is processed normally.

Notes
=====

* You can even paste code that has extra initial spaces, such as is common in
doctests:

In [3]:     >>> a = ['Mary', 'had', 'a', 'little', 'lamb']

In [4]:     >>> for i in range(len(a)):
   ...:         ...     print i, a[i]
   ...:     ...
0 Mary
1 had
2 a
3 little
4 lamb
(   s   Releases   %s <%s>s   FernandoN(   s   InteractiveShells   (^[ \t]*>>> |^[ \t]*\.\.\. )c         C   s   | o d Sn t i | ƒ } | o' |  i | t | i d ƒ ƒ | ƒ SnM | i	 ƒ  d j o |  i d | ƒ Sn& | i
 ƒ  o d Sn |  i | | ƒ Sd S(   sF   Alternate prefilter for input of pasted code from an interpreter.
    s    i    s   ...N(   s   lines	   PROMPT_REs   matchs   ms   selfs
   _prefilters   lens   groups   continuations   strips   isspace(   s   selfs   lines   continuations   m(    (    sY   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/Extensions/InterpreterPasteInput.pys   prefilter_pasteZ   s     'c           C   s   t  t _ d S(   s?   Rebind the input-pasting filter to be the new IPython prefilterN(   s   prefilter_pastes   InteractiveShells	   prefilter(    (    (    sY   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/Extensions/InterpreterPasteInput.pys   activate_prefilterp   s     c           C   s   t  i t  _ d S(   s   Reset the filter.N(   s   InteractiveShells
   _prefilters	   prefilter(    (    (    sY   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/Extensions/InterpreterPasteInput.pys   deactivate_prefiltert   s     s9   *** Pasting of code with ">>>" or "..." has been enabled.(   s   __doc__s   IPythons   Releases   authorss
   __author__s   licenses   __license__s   res   IPython.iplibs   InteractiveShells   compiles	   PROMPT_REs   prefilter_pastes   activate_prefilters   deactivate_prefilter(	   s   deactivate_prefilters   __license__s	   PROMPT_REs   InteractiveShells   activate_prefilters
   __author__s   res   Releases   prefilter_paste(    (    sY   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/Extensions/InterpreterPasteInput.pys   ?3   s   						