Ñò
mÈKc        
   @   s  d  Z  d d k Z d d k Z d d k l Z y d d k l Z Wn# e j
 o d d k l Z n Xd d g Z	 d d d „  ƒ  YZ
 e e d „ Z e d	 j ov e e i ƒ d
 j o e
 ƒ  Z n# e i d
 Z e
 e e ƒ e ƒ Z x. e i ƒ  Z e o d e e ƒ GHqë Pqë n d S(   s8   A lexical analyzer class for simple shell-like syntaxes.iÿÿÿÿN(   t   deque(   t   StringIOt   shlext   splitc           B   sz   e  Z d  Z d d e d „ Z d „  Z d d „ Z d „  Z d „  Z	 d „  Z
 d „  Z d d d „ Z d	 „  Z d
 „  Z RS(   s8   A lexical analyzer class for simple shell-like syntaxes.c         C   sF  t  | t ƒ o t | ƒ } n | d  j	 o | |  _ | |  _ n t i |  _ d  |  _ | |  _ | o d  |  _	 n
 d |  _	 d |  _
 d |  _ |  i o |  i d 7_ n d |  _ t |  _ d |  _ d |  _ d |  _ d	 |  _ t ƒ  |  _ d
 |  _ d |  _ d |  _ t ƒ  |  _ d  |  _ |  i o d |  i |  i f GHn d  S(   Nt    t   #t?   abcdfeghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_s>   ßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞs    	
s   '"s   \t   "t    i   i    s   shlex: reading from %s, line %d(   t
   isinstancet
   basestringR   t   Nonet   instreamt   infilet   syst   stdint   posixt   eoft
   commenterst	   wordcharst
   whitespacet   Falset   whitespace_splitt   quotest   escapet   escapedquotest   stateR    t   pushbackt   linenot   debugt   tokent	   filestackt   source(   t   selfR   R   R   (    (    s   /usr/lib/python2.6/shlex.pyt   __init__   s<    						
										
c         C   s7   |  i  d j o d t | ƒ GHn |  i i | ƒ d S(   s:   Push a token onto the stack popped by the get_token methodi   s   shlex: pushing token N(   R   t   reprR   t
   appendleft(   R!   t   tok(    (    s   /usr/lib/python2.6/shlex.pyt
   push_token;   s    c         C   sž   t  | t ƒ o t | ƒ } n |  i i |  i |  i |  i f ƒ | |  _ | |  _ d |  _ |  i o3 | d j	 o d |  i f GHqš d |  i f GHn d S(   s9   Push an input source onto the lexer's input source stack.i   s   shlex: pushing to file %ss   shlex: pushing to stream %sN(
   R	   R
   R   R   R$   R   R   R   R   R   (   R!   t	   newstreamt   newfile(    (    s   /usr/lib/python2.6/shlex.pyt   push_sourceA   s    "			
c         C   s^   |  i  i ƒ  |  i i ƒ  \ |  _ |  _  |  _ |  i o d |  i  |  i f GHn d |  _ d S(   s   Pop the input source stack.s   shlex: popping to %s, line %dR   N(   R   t   closeR   t   popleftR   R   R   R   (   R!   (    (    s   /usr/lib/python2.6/shlex.pyt
   pop_sourceO   s    !
c         C   sA  |  i  o7 |  i  i ƒ  } |  i d j o d t | ƒ GHn | S|  i ƒ  } |  i d j	 od xa | |  i j oL |  i |  i ƒ  ƒ } | o  | \ } } |  i | | ƒ n |  i	 ƒ  } q` Wn x= | |  i
 j o, |  i p |  i
 S|  i ƒ  |  i	 ƒ  } qÄ W|  i d j o, | |  i
 j o d t | ƒ GHq=d GHn | S(   sB   Get a token from the input stream (or from stack if it's nonempty)i   s   shlex: popping token s   shlex: token=s   shlex: token=EOFN(   R   R+   R   R#   t
   read_tokenR    R   t
   sourcehookR)   t	   get_tokenR   R   R,   (   R!   R%   t   rawt   specR(   R'   (    (    s   /usr/lib/python2.6/shlex.pyR/   X   s2    
  

	c         C   sÕ  t  } d } xTt oL|  i i d ƒ } | d j o |  i d |  _ n |  i d j o$ d Gt |  i ƒ Gd Gt | ƒ GHn |  i d  j o d |  _	 Pq |  i d j om| p d  |  _ Pq^| |  i
 j o@ |  i d j o	 d	 GHn |  i	 p |  i o | o Pqq q^| |  i j o! |  i i ƒ  |  i d |  _ q^|  i o# | |  i j o d
 } | |  _ q^| |  i j o | |  _	 d
 |  _ q^| |  i j o$ |  i p | |  _	 n | |  _ q^|  i o | |  _	 d
 |  _ q^| |  _	 |  i	 p |  i o | o Pq^q q |  i |  i j oÏ t } | p& |  i d j o	 d GHn t d ‚ n | |  i j o5 |  i p |  i	 | |  _	 d |  _ Pqöd
 |  _ q^|  i o9 | |  i j o) |  i |  i j o |  i } | |  _ q^|  i	 | |  _	 q |  i |  i j oŽ | p& |  i d j o	 d GHn t d ‚ n | |  i j o4 | |  i j o$ | | j o |  i	 |  i |  _	 n |  i	 | |  _	 | |  _ q |  i d
 j o³| p d  |  _ Pq^| |  i
 j oI |  i d j o	 d GHn d |  _ |  i	 p |  i o | o PqZq q^| |  i j o[ |  i i ƒ  |  i d |  _ |  i o0 d |  _ |  i	 p |  i o | o Pq€q qZq^|  i o | |  i j o | |  _ q^|  i o# | |  i j o d
 } | |  _ q^| |  i j p | |  i j p
 |  i o |  i	 | |  _	 q^|  i i | ƒ |  i d j o	 d GHn d |  _ |  i	 o Pq^q q q W|  i	 } d |  _	 |  i o | o | d j o
 d  } n |  i d j o# | o d t | ƒ GHqÑd GHn | S(   NR   i   s   
i   s   shlex: in states   I see character:R   i   s+   shlex: I see whitespace in whitespace statet   as    shlex: I see EOF in quotes states   No closing quotations    shlex: I see EOF in escape states   No escaped characters%   shlex: I see whitespace in word states&   shlex: I see punctuation in word states   shlex: raw token=s   shlex: raw token=EOF(   R   t   TrueR   t   readR   R   R#   R   R   R   R   R   R   t   readlineR   R   R   R   t
   ValueErrorR   R   R$   (   R!   t   quotedt   escapedstatet   nextchart   result(    (    s   /usr/lib/python2.6/shlex.pyR-   x   sâ     				

			
						
	 
		
		
	c         C   s„   | d d j o | d d !} n t  |  i t ƒ o< t i i | ƒ o( t i i t i i |  i ƒ | ƒ } n | t | d ƒ f S(   s(   Hook called on a filename to be sourced.i    R   i   iÿÿÿÿt   r(	   R	   R   R
   t   ost   patht   isabst   joint   dirnamet   open(   R!   R(   (    (    s   /usr/lib/python2.6/shlex.pyR.   ø   s
    '(c         C   sB   | d j o |  i } n | d j o |  i } n d | | f S(   s<   Emit a C-compiler-like, Emacs-friendly error-message leader.s   "%s", line %d: N(   R   R   R   (   R!   R   R   (    (    s   /usr/lib/python2.6/shlex.pyt   error_leader  s
    c         C   s   |  S(   N(    (   R!   (    (    s   /usr/lib/python2.6/shlex.pyt   __iter__	  s    c         C   s*   |  i  ƒ  } | |  i j o
 t ‚ n | S(   N(   R/   R   t   StopIteration(   R!   R   (    (    s   /usr/lib/python2.6/shlex.pyt   next  s    
N(   t   __name__t
   __module__t   __doc__R   R   R"   R&   R)   R,   R/   R-   R.   RB   RC   RE   (    (    (    s   /usr/lib/python2.6/shlex.pyR      s   $				 	€			c         C   s9   t  |  d | ƒ} t | _ | p d | _ n t | ƒ S(   NR   R   (   R   R3   R   R   t   list(   t   st   commentsR   t   lex(    (    s   /usr/lib/python2.6/shlex.pyR     s
    	t   __main__i   s   Token: (    (   RH   t   os.pathR<   R   t   collectionsR    t	   cStringIOR   t   ImportErrort   __all__R   R   R3   R   RF   t   lent   argvt   lexert   fileRA   R/   t   ttR#   (    (    (    s   /usr/lib/python2.6/shlex.pyt   <module>   s(   ý