ó
æNXc           @   s[   d  Z  d d l Z d d l m Z d d l m Z e j d ƒ Z d e f d „  ƒ  YZ	 d S(   s)   Support for interactive macros in IPythoniÿÿÿÿN(   t	   py3compat(   t   DEFAULT_ENCODINGs   #\s*coding[:=]\s*([-\w.]+)t   Macroc           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s‘   Simple class to store the value of macros as strings.

    Macro is just a callable that executes a string of IPython
    input when called.
    c         C   sž   g  } d } xH | j ƒ  D]: } t j | ƒ } | rF | j d ƒ } q | j | ƒ q Wd j | ƒ } t | t ƒ r | j	 | p„ t
 ƒ } n  | d |  _ d S(   s?   store the macro value, as a single string which can be executedi   s   
N(   t   Nonet
   splitlinest   coding_declarationt   matcht   groupt   appendt   joint
   isinstancet   bytest   decodeR   t   value(   t   selft   codet   linest   enct   linet   coding_match(    (    sJ   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/macro.pyt   __init__   s    c         C   s   t  j |  j ƒ S(   N(   R    t   unicode_to_strR   (   R   (    (    sJ   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/macro.pyt   __str__'   s    c         C   s   |  j  S(   N(   R   (   R   (    (    sJ   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/macro.pyt   __unicode__*   s    c         C   s   d t  |  j ƒ S(   Ns   IPython.macro.Macro(%s)(   t   reprR   (   R   (    (    sJ   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/macro.pyt   __repr__-   s    c         C   s   i |  j  d 6S(   s%    needed for safe pickling via %store R   (   R   (   R   (    (    sJ   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/macro.pyt   __getstate__0   s    c         C   sP   t  | t ƒ r# t |  j | j ƒ St  | t j ƒ rF t |  j | ƒ St ‚ d  S(   N(   R
   R   R   R    t   string_typest	   TypeError(   R   t   other(    (    sJ   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/macro.pyt   __add__4   s
    (	   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   (    (    (    sJ   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/macro.pyR      s   					(
   R!   t   ret   IPython.utilsR    t   IPython.utils.encodingR   t   compileR   t   objectR   (    (    (    sJ   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/macro.pyt   <module>   s
   	