Current File : //lib/python2.7/site-packages/paramiko/sftp_attr.pyc
�
=OXc@sjddlZddlZddlmZmZmZmZddlmZm	Z	de
fd��YZdS(i����N(t	x80000000to700to70t	xffffffff(tlongtbtSFTPAttributescBs�eZdZdZdZdZdZeZd�Z	e
dd��Zd�Z
e
ddd��Zd	�Zd
�Zd�Zeed��Zd
�Zd�ZRS(sh
    Representation of the attributes of a file (or proxied file) for SFTP in
    client or server mode.  It attemps to mirror the object returned by
    `os.stat` as closely as possible, so it may have the following fields,
    with the same meanings as those returned by an `os.stat` object:

        - ``st_size``
        - ``st_uid``
        - ``st_gid``
        - ``st_mode``
        - ``st_atime``
        - ``st_mtime``

    Because SFTP allows flags to have other arbitrary named attributes, these
    are stored in a dict named ``attr``.  Occasionally, the filename is also
    stored, in ``filename``.
    iiiicCsLd|_d|_d|_d|_d|_d|_d|_i|_dS(sX
        Create a new (empty) SFTPAttributes object.  All fields will be empty.
        iN(	t_flagstNonetst_sizetst_uidtst_gidtst_modetst_atimetst_mtimetattr(tself((s6/usr/lib/python2.7/site-packages/paramiko/sftp_attr.pyt__init__2s							cCsm|�}|j|_|j|_|j|_|j|_|j|_|j|_|dk	ri||_n|S(s`
        Create an `.SFTPAttributes` object from an existing ``stat`` object (an
        object returned by `os.stat`).

        :param object obj: an object returned by `os.stat` (or equivalent).
        :param str filename: the filename associated with this file.
        :return: new `.SFTPAttributes` object with the same attribute fields.
        N(R	R
RRR
RRtfilename(tclstobjRR((s6/usr/lib/python2.7/site-packages/paramiko/sftp_attr.pyt	from_stat?s
	cCsd|j�S(Ns<SFTPAttributes: %s>(t
_debug_str(R((s6/usr/lib/python2.7/site-packages/paramiko/sftp_attr.pyt__repr__TscCsJ|�}|j|�|dk	r.||_n|dk	rF||_n|S(N(t_unpackRRtlongname(RtmsgRRR((s6/usr/lib/python2.7/site-packages/paramiko/sftp_attr.pyt	_from_msgXs	
cCs|j�|_|j|j@r1|j�|_n|j|j@rb|j�|_|j�|_n|j|j@r�|j�|_	n|j|j
@r�|j�|_|j�|_n|j|j
@r|j�}x0t|�D]}|j�|j|j�<q�WndS(N(tget_intRt	FLAG_SIZEt	get_int64R	tFLAG_UIDGIDR
RtFLAG_PERMISSIONSRtFLAG_AMTIMER
Rt
FLAG_EXTENDEDtranget
get_stringR(RRtcountti((s6/usr/lib/python2.7/site-packages/paramiko/sftp_attr.pyRbscCsd|_|jdk	r-|j|jO_n|jdk	r`|jdk	r`|j|jO_n|jdk	r�|j|jO_n|j	dk	r�|j
dk	r�|j|jO_nt|j
�dkr�|j|jO_n|j|j�|j|j@r|j|j�n|j|j@rG|j|j�|j|j�n|j|j@rj|j|j�n|j|j@r�|jt|j	��|jt|j
��n|j|j@r|jt|j
��x:|j
j�D]&\}}|j|�|j|�q�WndS(Ni(RR	RRR
RRRR R
RR!tlenRR"tadd_intt	add_int64Rtitemst
add_string(RRtkeytval((s6/usr/lib/python2.7/site-packages/paramiko/sftp_attr.pyt_packss8	
cCsd}|jdk	r)|d|j7}n|jdk	rd|jdk	rd|d|j|jf7}n|jdk	r�|dt|j�d7}n|jdk	r�|jdk	r�|d|j|jf7}nx7|jj	�D]&\}}|dt
|�|f7}q�W|d7}|S(	Ns[ ssize=%d suid=%d gid=%d smode=t satime=%d mtime=%d s"%s"=%r t](R	RR
RRtoctR
RRR*tstr(Rtouttktv((s6/usr/lib/python2.7/site-packages/paramiko/sftp_attr.pyR�s
cCsf|rd}nd|d?d|d?d@}|rL|d||d@7}n|d||d@7}|S(Nis-rs-wis-xTts-xSs((tntsuidtstickyR3((s6/usr/lib/python2.7/site-packages/paramiko/sftp_attr.pyt_rwx�s	cCsc|jdk	rRtj|j�}|tjkr9d}n�|tjkrQd}n~|tjkrid}nf|tjkr�d}nN|tjkr�d}n6|tj	kr�d}n|tj
kr�d}nd}||j|jt@d	?|jtj
@�7}||j|jt@d
?|jtj@�7}||j|jd@|jtj@t�7}nd}|jdksv|jtkrd
}n^ttj�|j�dkr�tjdtj|j��}ntjdtj|j��}t|dd�}|j}|j}|j}|dkrd}n|dkr4d}n|dkrId}nd||||||fS(s=create a unix-style long description of the file (like ls -l)tptctdRt-tltst?iiis
?---------s(unknown date)iN�s%d %b %Ys%d %b %H:%MRis%s   1 %-8d %-8d %8d %-12s %sN(RRtstattS_IFMTtS_IFIFOtS_IFCHRtS_IFDIRtS_IFBLKtS_IFREGtS_IFLNKtS_IFSOCKR9RtS_ISUIDRtS_ISGIDtS_ISVTXtTrueRRtabsttimetstrftimet	localtimetgetattrR
RR	(RtkindtkstdatestrRtuidtgidtsize((s6/usr/lib/python2.7/site-packages/paramiko/sftp_attr.pyt__str__�sJ							++-	!						cCstt|��S(N(RR2(R((s6/usr/lib/python2.7/site-packages/paramiko/sftp_attr.pytasbytes�sN(t__name__t
__module__t__doc__RRR R!RR"RtclassmethodRRRRRR.RtstaticmethodtFalseR9RYRZ(((s6/usr/lib/python2.7/site-packages/paramiko/sftp_attr.pyRs&	
					
	2(RAROtparamiko.commonRRRRtparamiko.py3compatRRtobjectR(((s6/usr/lib/python2.7/site-packages/paramiko/sftp_attr.pyt<module>s"