zfc@sfdZddlZejdeddd dYZdddZd Zd Zd ZdZ dS( s:Extended file operations available in POSIX. f = posixfile.open(filename, [mode, [bufsize]]) will create a new posixfile object f = posixfile.fileopen(fileobject) will create a posixfile object from a builtin file object f.file() will return the original builtin file object f.dup() will return a new file object based on a new filedescriptor f.dup2(fd) will return a new file object based on the given filedescriptor f.flags(mode) will turn on the associated flag (merge) mode can contain the following characters: (character representing a flag) a append only flag c close on exec flag n no delay flag s synchronization flag (modifiers) ! turn flags 'off' instead of default 'on' = copy flags 'as is' instead of default 'merge' ? return a string in which the characters represent the flags that are set note: - the '!' and '=' modifiers are mutually exclusive. - the '?' modifier will return the status of the flags after they have been changed by other characters in the mode string f.lock(mode [, len [, start [, whence]]]) will (un)lock a region mode can contain the following characters: (character representing type of lock) u unlock r read lock w write lock (modifiers) | wait until the lock can be granted ? return the first lock conflicting with the requested lock or 'None' if there is no conflict. The lock returned is in the format (mode, len, start, whence, pid) where mode is a character representing the type of lock ('r' or 'w') note: - the '?' modifier prevents a region from being locked; it is query only iNsIThe posixfile module is deprecated; fcntl.lockf() provides better lockingit _posixfile_cBsheZdZddgZdZdddZdZdZd Zd Z d Z d Z RS( s;File wrapper class that provides extra POSIX file routines.topentclosedcCs=|j}d|j|j|j|jtt|dfS(Ns$<%s posixfile '%s', mode '%s' at %s>i(t_file_tstatesRtnametmodethextid(tselftfile((s!/usr/lib64/python2.7/posixfile.pyt__repr__Cs tricCs(ddl}|j|j|||S(Ni(t __builtin__tfileopenR(R RRtbufsizeR ((s!/usr/lib64/python2.7/posixfile.pyRLs cCsddl}tt|dkr0tdn||_xZt|D]L}|jdsFt||}t||j rt |||qqFqFW|S(Nis s,posixfile.fileopen() arg must be file objectt_( ttypestreprttypet TypeErrorRtdirt startswithtgetattrt isinstancetBuiltinMethodTypetsetattr(R R Rt maybemethodtattr((s!/usr/lib64/python2.7/posixfile.pyRPs   cCs|jS(N(R(R ((s!/usr/lib64/python2.7/posixfile.pyR `scCsOddl}t|ds'tdn|j|j|jj|jjS(Nitfdopensdup() method unavailable(tposixthasattrtAttributeErrorRtdupRtfilenoR(R R((s!/usr/lib64/python2.7/posixfile.pyR!cs  cCsVddl}t|ds'tdn|j|jj||j||jjS(NiRsdup() method unavailable(RRR tdup2RR"RR(R tfdR((s!/usr/lib64/python2.7/posixfile.pyR#ks   cGsddl}ddl}|rIt|dkr<tdn|d}nd}d}d|krq||jB}nd|kr||jB}nd|kr||jB}n|j}d |kr|j|j|j d}d |kr||@}q||B}n|j|j|j |}d |krZd |k}|j|j|j |}nd|kr d }|j|j|j d}|j|@r|d}n|j|j|j dd@r|d }n|j|@r|d}n|j|@r|d}n|SdS( NiisToo many argumentsit?tntatst=t!tct( tfcntltostlenRtO_NDELAYtO_APPENDtO_SYNCRR"tF_GETFLtF_SETFLtF_SETFDtF_GETFD(R twhichR-R.tl_flagsR tcur_fltarg((s!/usr/lib64/python2.7/posixfile.pytflagstsF           !  "   c Gsddl}ddl}d|kr0|j}n9d|krH|j}n!d|kr`|j}n tdd|kr|j}n!d|kr|j}n |j}d}d}d} t |d kr|d} nct |d kr|\} }nBt |d kr|\} }}nt |d kr6td nddl } ddl } | j dkr|j d|| | j||} nW| j d kr|j d|||| ddd} n!|j d|||| dd} |j|jj|| } d|kr| j d!kr8|jd| \}} } }}n| j d"krq|jd| \}}}} }} }nZ| j dkr|jd| \}}}} } }n$|jd| \}}}} }} ||jkr||jkrd| ||| fSd| ||| fSqndS(#NitwR tusno type of lock specifiedt|R%iiiistoo many argumentstnetbsd1topenbsd2tfreebsd2tfreebsd3tfreebsd4tfreebsd5tfreebsd6tfreebsd7tfreebsd8tbsdos2tbsdos3tbsdos4t lxxxxlxxxxlhhtaix3taix4thhllliithhllhhtlinux2( R?R@RARBRCRDRERFRGRHRIRJ(RLRM( R?R@RARBRCRDRHRIRJ(RLRM(tstructR-tF_WRLCKtF_RDLCKtF_UNLCKRtF_SETLKWtF_GETLKtF_SETLKR/tsysR.tplatformtpacktgetpidRR"tunpack(R thowtargsRQR-tl_typetcmdtl_whencetl_starttl_lenRXR.tflocktl_pidtl_sysidtl_vfs((s!/usr/lib64/python2.7/posixfile.pytlocksj               $*'$( t__name__t __module__t__doc__RR RRR R!R#R;Rh(((s!/usr/lib64/python2.7/posixfile.pyR;s      %R cCstj|||S(s4Public routine to open a file as a posixfile object.(RR(RRR((s!/usr/lib64/python2.7/posixfile.pyRscCstj|S(sCPublic routine to get a posixfile object from a Python file object.(RR(R ((s!/usr/lib64/python2.7/posixfile.pyRsii(( RktwarningstwarntDeprecationWarningRRRtSEEK_SETtSEEK_CURtSEEK_END(((s!/usr/lib64/python2.7/posixfile.pyt6s