ó
ÎÆPTc           @   sz  d  d l  Z  d  d l Z d  d l Z d  d l Z y d  d l m Z Wn e k
 r` d „  Z n Xe Z e j	 j
 d „ Z e j	 j
 d „ Z e j	 e j j d ƒ k r¯ e Z n e Z d „  Z y d  d l m Z Wn= e k
 rd	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ n Xd e  j f d „  ƒ  YZ e j d  d k  rJe e  _ n  e j d  d k rme j d ƒ n	 d „  Z d S(   iÿÿÿÿN(   t   wrapsc         C   s   d „  } | S(   Nc         S   s   |  S(   N(    (   t   func(    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   _wraps   s    (    (   t   _R   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyR       s    	c   	      C   s–  |  s t  d ƒ ‚ n  t j j | ƒ j t j j ƒ } t j j |  ƒ j t j j ƒ } | d j ƒ  | d j ƒ  k r÷ t j j |  ƒ \ } } t j j | ƒ \ } } t | ƒ t | ƒ ArÖ t  d |  | f ƒ ‚ q÷ t  d | d | d f ƒ ‚ n  xW t	 t
 t | ƒ t | ƒ ƒ ƒ D]* } | | j ƒ  | | j ƒ  k rPqqW| d 7} t j j g t | ƒ | | | } | s†t j j St j j | Œ  S(   s#   Return a relative version of a paths   no path specifiedi    s,   Cannot mix UNC and non-UNC paths (%s and %s)s&   path is on drive %s, start on drive %si   (   t
   ValueErrort   ost   patht   abspatht   splitt   sept   lowert   splitunct   boolt   ranget   mint   lent   pardirt   curdirt   join(	   R   t   startt
   start_listt	   path_listt   unc_patht   restt	   unc_startt   it   rel_list(    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   _relpath_nt   s(    !! ( 
%
c         C   sº   |  s t  d ƒ ‚ n  t j j | ƒ j t j j ƒ } t j j |  ƒ j t j j ƒ } t t j j | | g ƒ ƒ } t j j g t | ƒ | | | } | sª t j j	 St j j
 | Œ  S(   s#   Return a relative version of a paths   no path specified(   R   R   R   R   R   R	   R   t   commonprefixR   R   R   (   R   R   R   R   R   R   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   _relpath_posix/   s    !!%
t   ntpathc         O   s[   |  j  ƒ  y | | | Ž  Wn& |  j t j ƒ  Œ  s< ‚  qW d Sn X|  j d d d ƒ d S(   sk   
    Execute a callable utilizing a context object
    in the same way that the 'with' statement would
    N(   t	   __enter__t   __exit__t   syst   exc_infot   None(   t   contextt   callableobjt   argst   kwargs(    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   with_contextF   s    
(   t   catch_warningsR)   c           B   s2   e  Z e d d  „ Z d „  Z d „  Z d „  Z RS(   c         C   s&   | |  _  t j d |  _ t |  _ d  S(   Nt   warnings(   t   _recordR!   t   modulest   _modulet   Falset   _entered(   t   selft   recordt   module(    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   __init__\   s    	c         C   sE   g  } |  j  r | j d ƒ n  t |  ƒ j } d | d j | ƒ f S(   Ns   record=Trues   %s(%s)s   , (   R+   t   appendt   typet   __name__R   (   R0   R&   t   name(    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   __repr__a   s
    	c            s‰   |  j  r t d |  ƒ ‚ n  t |  _  |  j j |  _ |  j |  j _ |  j j |  _ |  j r g  ‰  ‡  f d †  } | |  j _ ˆ  Sd  Sd  S(   Ns   Cannot enter %r twicec             s   ˆ  j  t |  | Ž  ƒ d  S(   N(   R4   t   WarningMessage(   R&   R'   (   t   log(    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   showwarningq   s    (
   R/   t   RuntimeErrort   TrueR-   t   filterst   _filtersR;   t   _showwarningR+   R#   (   R0   R;   (    (   R:   s6   lib/python2.7/site-packages/unittest2/compatibility.pyR   h   s    			c         G   s>   |  j  s t d |  ƒ ‚ n  |  j |  j _ |  j |  j _ d  S(   Ns%   Cannot exit %r without entering first(   R/   R<   R?   R-   R>   R@   R;   (   R0   R"   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyR    x   s    	N(   R6   t
   __module__R.   R#   R3   R8   R   R    (    (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyR)   [   s   		R9   c           B   s   e  Z d Z d d d „ Z RS(	   t   messaget   categoryt   filenamet   linenot   filet   linec   	      C   sV   t  ƒ  } x% |  j D] } t |  | | | ƒ q Wd  |  _ | j rR | j |  _ n  d  S(   N(   t   localst   _WARNING_DETAILSt   setattrR#   t   _category_nameR6   (	   R0   RB   RC   RD   RE   RF   RG   t   local_valuest   attr(    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyR3      s    			(   RB   RC   RD   RE   RF   RG   N(   R6   RA   RI   R#   R3   (    (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyR9   ~   s    t   ChainMapc           B   sò   e  Z d  Z d „  Z d „  Z d „  Z d d „ Z d „  Z d „  Z	 d „  Z
 d „  Z e e d	 d ƒ r e j ƒ  d
 „  ƒ Z n	 d „  Z e d „  ƒ Z d „  Z e Z d d „ Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s±   A ChainMap groups multiple dicts (or other mappings) together
    to create a single, updateable view.

    The underlying mappings are stored in a list.  That list is public and can
    accessed or updated using the *maps* attribute.  There is no other state.

    Lookups search the underlying mappings successively until a key is found.
    In contrast, writes, updates, and deletions only operate on the first
    mapping.

    c         G   s   t  | ƒ p i  g |  _ d S(   s   Initialize a ChainMap by setting *maps* to the given mappings.
        If no mappings are provided, a single empty dictionary is used.

        N(   t   listt   maps(   R0   RP   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyR3   œ   s    c         C   s   t  | ƒ ‚ d  S(   N(   t   KeyError(   R0   t   key(    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   __missing__£   s    c         C   sA   x1 |  j  D]& } y | | SWq
 t k
 r/ q
 Xq
 W|  j | ƒ S(   N(   RP   RQ   RS   (   R0   RR   t   mapping(    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   __getitem__¦   s    c         C   s   | |  k r |  | S| S(   N(    (   R0   RR   t   default(    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   get®   s    c         C   s   t  t ƒ  j |  j Œ  ƒ S(   N(   R   t   sett   unionRP   (   R0   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   __len__±   s    c         C   s   t  t ƒ  j |  j Œ  ƒ S(   N(   t   iterRX   RY   RP   (   R0   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   __iter__´   s    c            s   t  ‡  f d †  |  j Dƒ ƒ S(   Nc         3   s   |  ] } ˆ  | k Vq d  S(   N(    (   t   .0t   m(   RR   (    s6   lib/python2.7/site-packages/unittest2/compatibility.pys	   <genexpr>¸   s    (   t   anyRP   (   R0   RR   (    (   RR   s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   __contains__·   s    c         C   s   t  |  j ƒ S(   N(   R_   RP   (   R0   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   __bool__º   s    t   _recursive_reprc         C   s%   d j  |  d j t t |  j ƒ ƒ ƒ S(   Ns   {0.__class__.__name__}({1})s   , (   t   formatR   t   mapt   reprRP   (   R0   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyR8   ¾   s    c         C   s%   d j  |  d j t t |  j ƒ ƒ ƒ S(   Ns   {0.__class__.__name__}({1})s   , (   Rc   R   Rd   Re   RP   (   R0   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyR8   Ã   s    c         G   s   |  t  j | | Œ ƒ S(   s?   Create a ChainMap with a single dict created from the iterable.(   t   dictt   fromkeys(   t   clst   iterableR&   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyRg   Ç   s    c         C   s$   |  j  |  j d j ƒ  |  j d Œ S(   sH   New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]i    i   (   t	   __class__RP   t   copy(   R0   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyRk   Ì   s    c         C   s(   | d k r i  } n  |  j | |  j Œ S(   s‚   
        New ChainMap with a new map followed by all previous maps. If no
        map is provided, an empty dict is used.
        N(   R#   Rj   RP   (   R0   R^   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt	   new_childÒ   s    	c         C   s   |  j  |  j d Œ  S(   s   New ChainMap from maps[1:].i   (   Rj   RP   (   R0   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   parentsÛ   s    c         C   s   | |  j  d | <d  S(   Ni    (   RP   (   R0   RR   t   value(    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   __setitem__à   s    c         C   s?   y |  j  d | =Wn& t k
 r: t d j | ƒ ƒ ‚ n Xd  S(   Ni    s(   Key not found in the first mapping: {!r}(   RP   RQ   Rc   (   R0   RR   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   __delitem__ã   s    c         C   s9   y |  j  d j ƒ  SWn t k
 r4 t d ƒ ‚ n Xd S(   sP   Remove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.i    s#   No keys found in the first mapping.N(   RP   t   popitemRQ   (   R0   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyRq   é   s    c         G   sH   y |  j  d j | | Œ SWn& t k
 rC t d j | ƒ ƒ ‚ n Xd S(   sW   Remove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].i    s(   Key not found in the first mapping: {!r}N(   RP   t   popRQ   Rc   (   R0   RR   R&   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyRr   ð   s    c         C   s   |  j  d j ƒ  d S(   s'   Clear maps[0], leaving maps[1:] intact.i    N(   RP   t   clear(   R0   (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyRs   ÷   s    N(   R6   RA   t   __doc__R3   RS   RU   R#   RW   RZ   R\   R`   Ra   t   getattrt   collectionsRb   R8   t   classmethodRg   Rk   t   __copy__Rl   t   propertyRm   Ro   Rp   Rq   Rr   Rs   (    (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyRN      s,   														i   i   i   sC   def raise_from(value, from_value):
    raise value from from_value
c         C   s
   |  ‚ d  S(   N(    (   Rn   t
   from_value(    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt
   raise_from  s    (   i   i   (   i   i   (   Rv   R   R!   t   sixt	   functoolsR    t   ImportErrorR=   t
   __unittestR   R   R   R   R,   RW   t   relpathR(   R*   R)   t   objectR9   t   MutableMappingRN   t   version_infot   exec_R{   (    (    (    s6   lib/python2.7/site-packages/unittest2/compatibility.pyt   <module>   s4   		#l
