ó
tPc           @   sA   d  d l  Z  d  d l Z d  d l m Z d   Z e d  Z d S(   i˙˙˙˙N(   t   _c   
      C   s  g  } d |  k r< |  j  d  } |  | d } |  |  }  n  t j |  | |  \ } } g  }  x | rë | j d  } | rŰ | d d k rŰ t |  d k rŰ | j d |  t j | | |  \ } }	 | | } |	 } q` |  j |  q` W|  j |  | |  f S(   sş   Parse options mostly like getopt.gnu_getopt.

    This is different from getopt.gnu_getopt in that an argument of - will
    become an argument of - instead of vanishing completely.
    s   --i   i    t   -(   t   indext   getoptt   popt   lent   insertt   appendt   extend(
   t   argst   optionst   longoptionst	   extraargst	   stopindext   optst	   parseargst   argt   toptst   newparseargs(    (    s7   /sys/lib/python2.7/site-packages/mercurial/fancyopts.pyt	   gnugetopt   s"    	(
	c         C   s˝  g  } d } i  } i  } xB| D]:} t  |  d k rO | \ }	 }
 } } } n | \ }	 }
 } } |
 } |
 j d d  }
 |
 | d |	 <| d | <| | |
 <t | t  rş | | |
 <n) t | d t  rŮ d | |
 <n
 | | |
 <| d k p| t k p| t k s0|	 r|	 d 7}	 n  | r0| d 7} q0n  |	 rC| |	 7} n  |
 r | j |  q q W| rlt	 } n	 t
 j
 } | |  | |  \ } }  x)| D]!\ } } | | }
 t | |
  } | t t  k ră| |
 |  | |
 <q| t d	  k r?y t |  | |
 <Wqľt k
 r;t j t d
  | | f   qľXq| t d  k r^| | |
 <q| t g   k r| |
 j |  q| t d  k s¨| t t  k rt | |
 <qqW|  S(   s  
    read args, parse options, and store options in state

    each option is a tuple of:

      short option or ''
      long option
      default value
      description
      option value label(optional)

    option types include:

      boolean or none - option sets variable in state to true
      string - parameter string is stored in state
      list - parameter string is added to a list
      integer - parameter strings is stored as int
      function - call function with parameter

    non-option args are returned
    t    i   R   R    s   --t   __call__t   :t   =i   s,   invalid value %r for option %s, expected intN(   R   t   replacet
   isinstancet   listt   getattrt   Falset   Nonet   TrueR   R   R   t   typet	   fancyoptst   intt
   ValueErrort   utilt   AbortR    (   R	   R
   t   statet   gnut   namelistt	   shortlistt   argmapt   defmapt   optiont   shortt   namet   defaultt   commentt   dummyt   onamet   parseR   t   optt   valt   t(    (    s7   /sys/lib/python2.7/site-packages/mercurial/fancyopts.pyR    %   s`    

$		
$(   R   R#   t   i18nR    R   R   R    (    (    (    s7   /sys/lib/python2.7/site-packages/mercurial/fancyopts.pyt   <module>   s   	