ó
ŠwÛjc           @   s•   d  d l  Z  d  d l Z d  d l Z d  d l m Z d „  Z d „  Z e d „ Z e	 e  d ƒ rj e  j
 n e j ƒ  d k r‚ e n d Z
 d „  Z d S(	   iÿÿÿÿN(   t   TESTFNc          C   s€   t  t d d  ƒ }  |  d  k	 r" |  St d } y t t | ƒ t } Wn  t t t f k
 re t	 } n Xt
 j | ƒ | t _ | S(   Nt   prev_valt   can_symlink(   t   getattrR   t   NoneR    t   symlinkt   Truet   OSErrort   NotImplementedErrort   AttributeErrort   Falset   ost   removeR   (   R   t   symlink_patht   can(    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/symlink_support.pyR      s    


	c         C   s,   t  ƒ  } d } | r |  St j | ƒ |  ƒ S(   s8   Skip decorator for tests that require functional symlinks*   Requires functional symlink implementation(   R   t   unittestt   skip(   t   testt   okt   msg(    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/symlink_support.pyt   skip_unless_symlink   s    	c            s¤   d d l  ‰  ˆ  j j j } ˆ  j j ˆ  j j ˆ  j j f | _ ˆ  j j | _	 ‡  ‡ f d †  ‰ ‡  ‡ f d †  ‰ | p‡ t
 j j |  ƒ } ˆ | | |  | ƒ ƒ d S(   s‡   
    Ctypes symlink implementation since Python doesn't support
    symlinks in windows yet. Borrowed from jaraco.windows project.
    iÿÿÿÿNc            sµ   d } d } d } d } d } d } | | B} d } |  }	 d }
 ˆ  j j ƒ  } d } d } ˆ  j j j | | |	 |
 ˆ  j | ƒ | | ƒ } ˆ | ƒ | j } ˆ  j j j | ƒ | S(	   sr   
        Call FormatMessage with a system error number to retrieve
        the descriptive error message.
        i   i    i   i   i   i   i    N(	   R   t   wintypest   LPWSTRt   windllt   kernel32t   FormatMessageWt   byreft   valuet	   LocalFree(   t   errnot   ALLOCATE_BUFFERt   ARGUMENT_ARRAYt   FROM_HMODULEt   FROM_STRINGt   FROM_SYSTEMt   IGNORE_INSERTSt   flagst   sourcet
   message_idt   language_idt   result_buffert   buffer_sizet	   argumentst   bytest   message(   t   ctypest   handle_nonzero_success(    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/symlink_support.pyt   format_system_message+   s2    
	
	c            s@   |  d k r< ˆ  j  j j ƒ  } ˆ | ƒ } t | | ƒ ‚ n  d  S(   Ni    (   R   R   t   GetLastErrort   WindowsError(   t   resultR   t   strerror(   R-   R/   (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/symlink_support.pyR.   R   s    (   t   ctypes.wintypesR   R   t   CreateSymbolicLinkWR   R   t   DWORDt   argtypest   BOOLEANt   restypeR   t   patht   isdir(   t   targett   linkt   target_is_directoryt   CreateSymbolicLink(    (   R-   R/   R.   sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/symlink_support.pyt   _symlink_win32   s    		'R   t   Windowsc         C   s6   y t  j |  ƒ Wn t k
 r1 t  j |  ƒ n Xd  S(   N(   R   t   rmdirR   R   (   t   name(    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/symlink_support.pyt   remove_symlink_   s    (   R   R   t   platformt   test.test_supportR    R   R   R
   R@   t   hasattrR   t   systemR   RD   (    (    (    sŠ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/symlink_support.pyt   <module>   s   		>