ó zfc@sfdZddlZejdedƒdd d„ƒYZddd„Zd „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 i˙˙˙˙NsIThe posixfile module is deprecated; fcntl.lockf() provides better lockingit _posixfile_cBsheZdZddgZd„Zddd„Zd„Zd„Zd „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 tri˙˙˙˙cCs(ddl}|j|j|||ƒƒS(Ni˙˙˙˙(t __builtin__tfileopenR(R RRtbufsizeR ((s!/usr/lib64/python2.7/posixfile.pyRLs cCsšddl}tt|ƒƒdkr0td‚n||_xZt|ƒD]L}|jdƒsFt||ƒ}t||j ƒr’t |||ƒq’qFqFW|S(Ni˙˙˙˙s 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|dƒs'td‚n|j|j|jjƒƒ|jjƒS(Ni˙˙˙˙tfdopensdup() method unavailable(tposixthasattrtAttributeErrorRtdupRtfilenoR(R R((s!/usr/lib64/python2.7/posixfile.pyR!cs  cCsVddl}t|dƒs'td‚n|j|jjƒ|ƒ|j||jjƒS(Ni˙˙˙˙Rsdup() method unavailable(RRR tdup2RR"RR(R tfdR((s!/usr/lib64/python2.7/posixfile.pyR#ks   cGsddl}ddl}|rIt|ƒdkr<td‚n|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 dƒd@rÓ|d }n|j|@rí|d}n|j|@r|d}n|SdS( Ni˙˙˙˙isToo 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 td‚d|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||jkrüd| ||| fSd| ||| fSqndS(#Ni˙˙˙˙twR 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.pytlock™sj               $*'$( t__name__t __module__t__doc__RR RRR R!R#R;Rh(((s!/usr/lib64/python2.7/posixfile.pyR;s      %R cCstƒj|||ƒS(s4Public routine to open a file as a posixfile object.(RR(RRR((s!/usr/lib64/python2.7/posixfile.pyRÜscCstƒj|ƒS(sCPublic routine to get a posixfile object from a Python file object.(RR(R ((s!/usr/lib64/python2.7/posixfile.pyRŕsii(( RktwarningstwarntDeprecationWarningRRRtSEEK_SETtSEEK_CURtSEEK_END(((s!/usr/lib64/python2.7/posixfile.pyt6s   Ą