ó
ÓnäZc           @   sŽ   d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d „  Z d e f d „  ƒ  YZ e	 d k rŠ e j
 e e j d ƒ ƒ n  d S(   s…   These functions are executed via gyp-flock-tool when using the Makefile
generator.  Used on systems that don't have a built-in flock.iÿÿÿÿNc         C   s   t  ƒ  } | j |  ƒ d  S(   N(   t	   FlockToolt   Dispatch(   t   argst   executor(    (    s2   /usr/lib/python2.7/dist-packages/gyp/flock_tool.pyt   main   s    	R    c           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s(   This class emulates the 'flock' command.c         C   sS   t  | ƒ d k  r! t d ƒ ‚ n  d |  j | d ƒ } t |  | ƒ | d Œ  d S(   s(   Dispatches a string command to a method.i   s   Not enough argumentss   Exec%si    N(   t   lent	   Exceptiont   _CommandifyNamet   getattr(   t   selfR   t   method(    (    s2   /usr/lib/python2.7/dist-packages/gyp/flock_tool.pyR      s    c         C   s   | j  ƒ  j d d ƒ S(   s<   Transforms a tool name like copy-info-plist to CopyInfoPlistt   -t    (   t   titlet   replace(   R	   t   name_string(    (    s2   /usr/lib/python2.7/dist-packages/gyp/flock_tool.pyR      s    c      	   G   s¬   t  j | t  j t  j Bt  j Bd ƒ } t j j d ƒ rb t j	 d t
 j d d d d d d ƒ } n' t j	 d t
 j d d d d d d ƒ } t
 j
 | t
 j | ƒ t j | ƒ S(   s5   Emulates the most basic behavior of Linux's flock(1).i¶  t   aixt   hhIllqqi    t   hhllhhl(   t   ost   opent   O_WRONLYt   O_NOCTTYt   O_CREATt   syst   platformt
   startswitht   structt   packt   fcntlt   F_WRLCKt   F_SETLKt
   subprocesst   call(   R	   t   lockfilet   cmd_listt   fdt   op(    (    s2   /usr/lib/python2.7/dist-packages/gyp/flock_tool.pyt	   ExecFlock#   s    &*'(   t   __name__t
   __module__t   __doc__R   R   R&   (    (    (    s2   /usr/lib/python2.7/dist-packages/gyp/flock_tool.pyR       s   		t   __main__i   (   R)   R   R   R   R    R   R   t   objectR    R'   t   exitt   argv(    (    (    s2   /usr/lib/python2.7/dist-packages/gyp/flock_tool.pyt   <module>   s   	 