a °…bè ã@sPddlZddlZddlmZmZmZmZddlmZm Z m Z Gdd„de ƒZ dS)éN)Ú x80000000Úo700Úo70Ú xffffffff)ÚlongÚPY2Ústrftimec@s˜eZdZdZdZdZdZdZeZ dd„Z e dd d „ƒZ d d „Z e dd d„ƒZdd„Zdd„Zdd„Zeddd„ƒZdd„Zdd„ZereZeZneZdS)ÚSFTPAttributesah 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``. éééécCs4d|_d|_d|_d|_d|_d|_d|_i|_dS)zX Create a new (empty) SFTPAttributes object. All fields will be empty. rN)Ú_flagsÚst_sizeÚst_uidÚst_gidÚst_modeÚst_atimeÚst_mtimeÚattr©Úself©rú9/tmp/pip-target-98j97qn4/lib/python/paramiko/sftp_attr.pyÚ__init__2szSFTPAttributes.__init__NcCsH|ƒ}|j|_|j|_|j|_|j|_|j|_|j|_|durD||_|S)a` 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)rrrrrrÚfilename)ÚclsÚobjrrrrrÚ from_stat?s zSFTPAttributes.from_statcCsd | ¡¡S)Nz)ÚformatÚ _debug_strrrrrÚ__repr__TszSFTPAttributes.__repr__cCs0|ƒ}| |¡|dur||_|dur,||_|S©N)Ú_unpackrÚlongname)rÚmsgrr$rrrrÚ _from_msgXs zSFTPAttributes._from_msgcCs®| ¡|_|j|j@r | ¡|_|j|j@r@| ¡|_| ¡|_|j|j@rV| ¡|_ |j|j @rv| ¡|_ | ¡|_ |j|j @rª| ¡}t|ƒD]}| ¡|j| ¡<q’dSr")Zget_intrÚ FLAG_SIZEZ get_int64rÚ FLAG_UIDGIDrrÚFLAG_PERMISSIONSrÚ FLAG_AMTIMErrÚ FLAG_EXTENDEDÚrangeZ get_stringr)rr%ÚcountÚirrrr#bs             zSFTPAttributes._unpackcCs|d|_|jdur |j|jO_|jdurD|jdurD|j|jO_|jdur^|j|jO_|jdur‚|j dur‚|j|j O_t |j ƒdkr |j|j O_| |j¡|j|j@rÄ| |j¡|j|j@rè| |j¡| |j¡|j|j@r| |j¡|j|j @r0| t|jƒ¡| t|j ƒ¡|j|j @rx| t |j ƒ¡|j  ¡D]\}}| |¡| |¡qXdS)Nr)rrr'rrr(rr)rrr*Úlenrr+Zadd_intZ add_int64rÚitemsZ add_string)rr%ÚkeyÚvalrrrÚ_packss8          zSFTPAttributes._packcCsÂd}|jdur|d |j¡7}|jdurF|jdurF|d |j|j¡7}|jdurf|dt|jƒd7}|jdurŽ|jdurŽ|d |j|j¡7}|j  ¡D]\}}|d t |ƒ|¡7}q˜|d7}|S) Nz[ zsize={} zuid={} gid={} zmode=ú zatime={} mtime={} z "{}"={!r} ú]) rrrrrÚoctrrrr0Ústr)rÚoutÚkÚvrrrr ’s  zSFTPAttributes._debug_strFcCsV|rd}d|d?d|d?d@}|r>|d||d@7}n|d||d@7}|S)Nr z-rz-wr z-xTtz-xSsr)ÚnZsuidZstickyr8rrrÚ_rwx¡szSFTPAttributes._rwxc Cs¨|jdurðt |j¡}|tjkr&d}nd|tjkr6d}nT|tjkrFd}nD|tjkrVd}n4|tjkrfd}n$|tjkrvd}n|tj kr†d}nd }||  |jt @d ?|jtj @¡7}||  |jt @d ?|jtj@¡7}||  |jd @|jtj@d ¡7}nd}|jdus |jtkrd}n:t |j¡}tt ¡|jƒdkrBtd|ƒ}n td|ƒ}t|dd ƒ}|j}|j}|j}|durxd}|dur†d}|dur”d}d||||||fS)z=create a unix-style long description of the file (like ls -l)NÚpÚcÚdÚbú-ÚlÚsú?éééTz ?---------z(unknown date)iNíz%d %b %Yz %d %b %H:%Mrrz%s 1 %-8d %-8d %8d %-12s %s)rÚstatÚS_IFMTÚS_IFIFOÚS_IFCHRÚS_IFDIRÚS_IFBLKÚS_IFREGÚS_IFLNKÚS_IFSOCKr<rÚS_ISUIDrÚS_ISGIDÚS_ISVTXrrÚtimeÚ localtimeÚabsrÚgetattrrrr) rÚkindÚksZdatestrZ time_tuplerÚuidÚgidÚsizerrrÚ_as_text¬sf         ÿÿÿ       úzSFTPAttributes._as_textcCs| ¡ d¡S)Nzutf-8)r]ÚencoderrrrÚasbytesïszSFTPAttributes.asbytes)N)NN)F)Ú__name__Ú __module__Ú __qualname__Ú__doc__r'r(r)r*rr+rÚ classmethodrr!r&r#r3r Ú staticmethodr<r]r_rÚ __unicode__Ú__str__rrrrr s.    Cr ) rHrTZparamiko.commonrrrrZparamiko.py3compatrrrÚobjectr rrrrÚs