
    ohB                      @    d dl Z d dlZd dlmZmZmZmZ  G d d      Zy)    N)	x80000000o700o70	xffffffffc                       e Zd ZdZdZdZdZdZeZ	d Z
edd       Zd	 Zedd
       Zd Zd Zd Zedd       Zd Zd Zy)SFTPAttributesai  
    Representation of the attributes of a file (or proxied file) for SFTP in
    client or server mode.  It attempts 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``.
                c                 t    d| _         d| _        d| _        d| _        d| _        d| _        d| _        i | _        y)zX
        Create a new (empty) SFTPAttributes object.  All fields will be empty.
        r   N)_flagsst_sizest_uidst_gidst_modest_atimest_mtimeattrselfs    d/var/www/pru.catia.catastroantioquia-mas.com/tasa/lib/python3.12/site-packages/paramiko/sftp_attr.py__init__zSFTPAttributes.__init__1   s<     	    Nc                      |        }|j                   |_         |j                  |_        |j                  |_        |j                  |_        |j                  |_        |j
                  |_        |||_        |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.
        )r   r   r   r   r   r   filename)clsobjr   r   s       r   	from_statzSFTPAttributes.from_stat>   s_     u{{jjjj{{$DMr   c                 @    dj                  | j                               S )Nz<SFTPAttributes: {}>)format
_debug_strr   s    r   __repr__zSFTPAttributes.__repr__S   s    %,,T__->??r   c                 Z     |        }|j                  |       |||_        |||_        |S N)_unpackr   longname)r   msgr   r'   r   s        r   	_from_msgzSFTPAttributes._from_msgW   s4    uS$DM$DMr   c                    |j                         | _        | j                  | j                  z  r|j                         | _        | j                  | j
                  z  r*|j                         | _        |j                         | _        | j                  | j                  z  r|j                         | _	        | j                  | j                  z  r*|j                         | _        |j                         | _        | j                  | j                  z  rL|j                         }t        |      D ]-  }|j                         | j                   |j                         <   / y y r%   )get_intr   	FLAG_SIZE	get_int64r   FLAG_UIDGIDr   r   FLAG_PERMISSIONSr   FLAG_AMTIMEr   r   FLAG_EXTENDEDrange
get_stringr   )r   r(   countis       r   r&   zSFTPAttributes._unpacka   s    kkm;;'==?DL;;)))++-DK++-DK;;...;;=DL;;)))KKMDMKKMDM;;+++KKME5\ ?.1nn.>		#..*+? ,r   c                 p   d| _         | j                  | xj                   | j                  z  c_         | j                  +| j                  | xj                   | j
                  z  c_         | j                  | xj                   | j                  z  c_         | j                  +| j                  | xj                   | j                  z  c_         t        | j                        dkD  r| xj                   | j                  z  c_         |j                  | j                          | j                   | j                  z  r|j                  | j                         | j                   | j
                  z  r6|j                  | j                         |j                  | j                         | j                   | j                  z  r|j                  | j                         | j                   | j                  z  rH|j                  t!        | j                               |j                  t!        | j                               | j                   | j                  z  rh|j                  t        | j                               | j                  j#                         D ]'  \  }}|j%                  |       |j%                  |       ) y )Nr   )r   r   r,   r   r   r.   r   r/   r   r   r0   lenr   r1   add_int	add_int64intitems
add_string)r   r(   keyvals       r   _packzSFTPAttributes._packr   s   <<#KK4>>)KKK#$++*AKK4+++K<<#KK4000KMM%DMM,EKK4+++Ktyy>AKK4---KDKK ;;'MM$,,';;)))KK$KK$;;...KK%;;)))KKDMM*+KKDMM*+;;+++KKDII' IIOO- $Ss#s#$ 	r   c                 @   d}| j                   |dj                  | j                         z  }| j                  5| j                  )|dj                  | j                  | j                        z  }| j                  |dt        | j                        z   dz   z  }| j                  5| j                  )|dj                  | j                  | j                        z  }| j                  j                         D ]#  \  }}|dj                  t        |      |      z  }% |dz  }|S )	Nz[ zsize={} zuid={} gid={} zmode= zatime={} mtime={} z
"{}"={!r} ])r   r!   r   r   r   octr   r   r   r;   str)r   outkvs       r   r"   zSFTPAttributes._debug_str   s    <<#:$$T\\22CKK#$++*A#**4;;DDC<<#7S..44CMM%DMM,E'..t}}dmmLLCIIOO% 	2DAq<&&s1vq11C	2s

r   c                 v    |rd}d| dz	     d| dz	  dz     z   }|r|d|| dz  z      z  }|S |d|| dz  z      z  }|S )Nr
   z-rz-wr	   z-xTtz-xSs )nsuidstickyrE   s       r   _rwxzSFTPAttributes._rwx   sh    D16lT16Q,//6$!a%.))C 
 6$!a%.))C
r   c                    | j                   t        j                  | j                         }|t        j                  k(  rd}n|t        j                  k(  rd}np|t        j
                  k(  rd}nZ|t        j                  k(  rd}nD|t        j                  k(  rd}n.|t        j                  k(  rd}n|t        j                  k(  rd}nd}|| j                  | j                   t        z  d	z	  | j                   t        j                  z        z  }|| j                  | j                   t        z  d
z	  | j                   t        j                  z        z  }|| j                  | j                   dz  | j                   t        j                  z  d      z  }nd}| j                   | j                   t"        k(  rd}nyt%        j&                  | j                         }t)        t%        j$                         | j                   z
        dkD  rt%        j*                  d|      }nt%        j*                  d|      }t-        | dd      }| j.                  }| j0                  }| j2                  }|d}|d}|d}d||||||fz  S )z=create a unix-style long description of the file (like ls -l)pcdb-ls?         Tz
?---------z(unknown date)i N z%d %b %Yz%d %b %H:%Mr   r   z%s   1 %-8d %-8d %8d %-12s %s)r   statS_IFMTS_IFIFOS_IFCHRS_IFDIRS_IFBLKS_IFREGS_IFLNKS_IFSOCKrM   r   S_ISUIDr   S_ISGIDS_ISVTXr   r   time	localtimeabsstrftimegetattrr   r   r   )	r   kindksdatestr
time_tupler   uidgidsizes	            r   __str__zSFTPAttributes.__str__   s   <<#;;t||,Dt||#%%%%%&$))$*DLL4<<,G B $))#)4<<$,,+F B $))q $,,"=t B BMM!t}}	'A&G6J499;./*<--
J?--zB4S1 kkkk||;C;C<D
 /2
 
 	
r   c                 4    t        |       j                         S r%   )rD   encoder   s    r   asbyteszSFTPAttributes.asbytes   s    4y!!r   r%   )NN)F)__name__
__module____qualname____doc__r,   r.   r/   r0   r   r1   r   classmethodr   r#   r)   r&   r?   r"   staticmethodrM   rr   ru   rI   r   r   r   r      s    $ IKKM  (@  ?">  A
F"r   r   )rZ   rf   paramiko.commonr   r   r   r   r   rI   r   r   <module>r}      s   &   ; ;W" W"r   