B
    b_                 @   s4   d Z dZddlZddlmZ i Zdd Zdd	 ZdS )
zmagic.py is a utility that allows a simple line from the interpreter
be translated from a more bash-like form to a python form.
For instance, 'plot a' is transformed to 'plot(a)'
Special exceptions are made for predefined ls,cd, and pwd functionsz.David N. Mashburn <david.n.mashburn@gmail.com>    N   )testForContinuationsc       	      C   s  | dkr| S |  d}| d dkr&n`| d dkrJd| dd   d } n<| d dkrnd	| dd   d
 } n| dkr| d } n| d d dkr| d d d | dd   d
 } n| d d dkr| dd   d}t|dk rd} n(|d d|dd   }}|t|< d} nj| dd tkr| d}t|dk r^d	t|d   d
 } n*d	t|d   d d|dd   d
 } n|dkr| d}t|dkr|d }|d }d}x0|dkr|d7 }t||krP || }qW |dkr | S |d  s|d dkr|d  s8|d dkrt	|st	|s|
dd
dd r|d | |d d   d } | S )N  r   ?zhelp(r   )!zsx("z"))Zlspwdz()   )zls zcd    z("   zalias _z."'_.()findlstripsplitlenjoin	aliasDictisalphaisalnumkeyword	iskeywordreplace)	commandZfirst_spacecnvZcmdsZwd1Zwd2i r!   *lib/python3.7/site-packages/wx/py/magic.pymagicSingle   sT    
$
,


Pr#   c       	      C   s   t | }t|dkr| S t|dkr0|\}}}}g }d}x|| dD ]n}|r\|t| nR|ddkr|ddkr|ddkr|ddkr|t| n
|| d}qDW d|S )Nr      T
r   F)r   r   r   appendr#   popr   )	r   ZcontinuationsZstringContinuationListZindentationBlockListZlineContinuationListZparentheticalContinuationListZcommandListZ	firstLiner    r!   r!   r"   magicJ   s$    
r(   )__doc__
__author__r   parser   r   r#   r(   r!   r!   r!   r"   <module>
   s   1