³ò
Jé¬Fc           @   s¯  d  Z  d d k Z e i d j oL d d k Z d d k Z d d k Z e i Z d Z e i	 Z
 e i ƒ  Z nH e i d j o+ d d k Z e i Z e i Z e i
 Z
 n e d ƒ ‚ e i d j o d „  Z d „  Z n' e i d j o d	 „  Z d
 „  Z n e d j o d d k l Z l Z l Z d d k Z d d k Z e d d ƒ Z e i e e i ƒ e d e e ƒ  ƒ ƒ Z e i e ƒ d GHe i i ƒ  Z e i ƒ  n d S(   sÚ  Cross-platform (posix/nt) API for flock-style file locking.

Synopsis:

   import portalocker
   file = open("somefile", "r+")
   portalocker.lock(file, portalocker.LOCK_EX)
   file.seek(12)
   file.write("foo")
   file.close()

If you know what you're doing, you may choose to

   portalocker.unlock(file)

before closing the file, but why?

Methods:

   lock( file, flags )
   unlock( file )

Constants:

   LOCK_EX
   LOCK_SH
   LOCK_NB

I learned the win32 technique for locking files from sample code
provided by John Nielsen <nielsenjf@my-deja.com> in the documentation
that accompanies the win32 modules.

Author: Jonathan Feinberg <jdf@pobox.com>
Version: $Id: portalocker.py,v 1.3 2001/05/29 18:47:55 Administrator Exp $
iÿÿÿÿNt   nti    t   posixs3   PortaLocker only defined for nt and posix platformsc         C   s2   t  i |  i ƒ  ƒ } t  i | | d d t ƒ d  S(   Ni    i  ÿÿ(   t	   win32filet   _get_osfhandlet   filenot
   LockFileExt   __overlapped(   t   filet   flagst   hfile(    (    s6   /home/sgala/newcode/venus/planet/vendor/portalocker.pyt   lock?   s    c         C   s/   t  i |  i ƒ  ƒ } t  i | d d t ƒ d  S(   Ni    i  ÿÿ(   R   R   R   t   UnlockFileExR   (   R   R	   (    (    s6   /home/sgala/newcode/venus/planet/vendor/portalocker.pyt   unlockC   s    c         C   s   t  i |  i ƒ  | ƒ d  S(   N(   t   fcntlt   flockR   (   R   R   (    (    s6   /home/sgala/newcode/venus/planet/vendor/portalocker.pyR
   H   s    c         C   s   t  i |  i ƒ  t  i ƒ d  S(   N(   R   R   R   t   LOCK_UN(   R   (    (    s6   /home/sgala/newcode/venus/planet/vendor/portalocker.pyR   K   s    t   __main__(   t   timet   strftimet	   localtimes   log.txts   a+s   %m/%d/%Y %H:%M:%S
s'   Wrote lines. Hit enter to release lock.(   t   __doc__t   ost   namet   win32conR   t
   pywintypest   LOCKFILE_EXCLUSIVE_LOCKt   LOCK_EXt   LOCK_SHt   LOCKFILE_FAIL_IMMEDIATELYt   LOCK_NBt
   OVERLAPPEDR   R   t   RuntimeErrorR
   R   t   __name__R   R   R   t   syst   portalockert   opent   logt	   timestampt   writet   stdint   readlinet   dummyt   close(    (    (    s6   /home/sgala/newcode/venus/planet/vendor/portalocker.pys   <module>)   s@   						
