U q` @sLddlZddlZddlmZmZmZmZddlmZm Z Gddde Z dS)N) x80000000o700o70 xffffffff)longbc@seZdZdZdZdZdZdZeZ ddZ e dd d Z d d Z e dd dZddZddZddZedddZddZddZdS)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)_flagsst_sizest_uidst_gidst_modest_atimest_mtimeattrselfr9/tmp/pip-target-nv4zd3e_/lib/python/paramiko/sftp_attr.py__init__2szSFTPAttributes.__init__NcCsH|}|j|_|j|_|j|_|j|_|j|_|j|_|dk rD||_|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)rrrrrrfilename)clsobjrrrrr from_stat?s zSFTPAttributes.from_statcCsd|S)Nz)format _debug_strrrrr__repr__TszSFTPAttributes.__repr__cCs0|}|||dk r||_|dk r,||_|SN)_unpackrlongname)rmsgrr#rrrr _from_msgXs zSFTPAttributes._from_msgcCs||_|j|j@r ||_|j|j@r@||_||_|j|j@rV||_ |j|j @rv||_ ||_ |j|j @r|}t|D]}||j|<qdSr!)Zget_intr FLAG_SIZEZ get_int64r FLAG_UIDGIDrrFLAG_PERMISSIONSr FLAG_AMTIMErr FLAG_EXTENDEDrangeZ get_stringr)rr$countirrrr"bs             zSFTPAttributes._unpackcCs|d|_|jdk r |j|jO_|jdk rD|jdk rD|j|jO_|jdk r^|j|jO_|jdk r|j dk r|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)r rr&rrr'rr(rrr)lenrr*Zadd_intZ add_int64ritemsZ add_string)rr$keyvalrrr_packss8          zSFTPAttributes._packcCsd}|jdk r|d|j7}|jdk rF|jdk rF|d|j|j7}|jdk rf|dt|jd7}|jdk r|jdk r|d|j|j7}|j D]\}}|dt ||7}q|d7}|S) Nz[ zsize={} zuid={} gid={} zmode= zatime={} mtime={} z "{}"={!r} ]) rrrrroctrrrr/str)routkvrrrrs  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)nZsuidZstickyr7rrr_rwxszSFTPAttributes._rwxcCs|jdk rt|j}|tjkr&d}nd|tjkr6d}nT|tjkrFd}nD|tjkrVd}n4|tjkrfd}n$|tjkrvd}n|tj krd}nd }|| |jt @d ?|jtj @7}|| |jt @d ?|jtj@7}|| |jd @|jtj@d 7}nd}|jdks |jtkrd}nBtt|jdkr@tdt|j}ntdt|j}t|dd }|j}|j}|j}|dkrd}|dkrd}|dkrd}d||||||fS)z=create a unix-style long description of the file (like ls -l)Npcdr-ls?Tz ?---------z(unknown date)iNz%d %b %Yz %d %b %H:%Mrrz%s 1 %-8d %-8d %8d %-12s %s)rstatS_IFMTS_IFIFOS_IFCHRS_IFDIRS_IFBLKS_IFREGS_IFLNKS_IFSOCKr;rS_ISUIDrS_ISGIDS_ISVTXrrabstimestrftime localtimegetattrrrr)rkindksZdatestrruidgidsizerrr__str__sx                  zSFTPAttributes.__str__cCs tt|Sr!)rr6rrrrasbytesszSFTPAttributes.asbytes)N)NN)F)__name__ __module__ __qualname____doc__r&r'r(r)rr*r classmethodrr r%r"r2r staticmethodr;r\r]rrrrrs&    Fr) rFrSZparamiko.commonrrrrZparamiko.py3compatrrobjectrrrrrs