
    IiB                      @    S SK r S SKrS SKJrJrJrJr   " S S5      rg)    N)	x80000000o700o70	xffffffffc                       \ rS rSrSrSrSrSrSr\	r
S r\SS	 j5       rS
 r\SS j5       rS rS rS r\SS j5       rS rS rSrg)SFTPAttributes   a1  
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    SU l         SU l        SU l        SU l        SU l        SU l        SU l        0 U l        g)zH
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    8/venv/lib/python3.13/site-packages/paramiko/sftp_attr.py__init__SFTPAttributes.__init__1   s<     	    Nc                     U " 5       nUR                   Ul         UR                  Ul        UR                  Ul        UR                  Ul        UR                  Ul        UR
                  Ul        Ub  X#l        U$ )a0  
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_statSFTPAttributes.from_stat>   s]     u{{jjjj{{$Mr   c                 @    SR                  U R                  5       5      $ )Nz<SFTPAttributes: {}>)format
_debug_strr   s    r   __repr__SFTPAttributes.__repr__S   s    %,,T__->??r   c                 Z    U " 5       nUR                  U5        Ub  X$l        Ub  X4l        U$ N)_unpackr   longname)r   msgr   r+   r   s        r   	_from_msgSFTPAttributes._from_msgW   s0    uS$M$Mr   c                    UR                  5       U l        U R                  U R                  -  (       a  UR                  5       U l        U R                  U R
                  -  (       a*  UR                  5       U l        UR                  5       U l        U R                  U R                  -  (       a  UR                  5       U l	        U R                  U R                  -  (       a*  UR                  5       U l        UR                  5       U l        U R                  U R                  -  (       aN  UR                  5       n[        U5       H.  nUR                  5       U R                   UR                  5       '   M0     g g 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*   SFTPAttributes._unpacka   s    kkm;;'==?DL;;)))++-DK++-DK;;...;;=DL;;)))KKMDMKKMDM;;+++KKME5\.1nn.>		#..*+ " ,r   c                    SU l         U R                  b  U =R                   U R                  -  sl         U R                  b,  U R                  b  U =R                   U R
                  -  sl         U R                  b  U =R                   U R                  -  sl         U R                  b,  U R                  b  U =R                   U R                  -  sl         [        U R                  5      S:  a  U =R                   U R                  -  sl         UR                  U R                   5        U R                   U R                  -  (       a  UR                  U R                  5        U R                   U R
                  -  (       a6  UR                  U R                  5        UR                  U R                  5        U R                   U R                  -  (       a  UR                  U R                  5        U R                   U R                  -  (       aH  UR                  [!        U R                  5      5        UR                  [!        U R                  5      5        U R                   U R                  -  (       ai  UR                  [        U R                  5      5        U R                  R#                  5        H'  u  p#UR%                  U5        UR%                  U5        M)     g )Nr   )r   r   r1   r   r   r3   r   r4   r   r   r5   lenr   r6   add_int	add_int64intitems
add_string)r   r,   keyvals       r   _pack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# . 	r   c                 N   SnU R                   b  USR                  U R                   5      -  nU R                  b6  U R                  b)  USR                  U R                  U R                  5      -  nU R                  b  US[        U R                  5      -   S-   -  nU R                  b6  U R                  b)  USR                  U R                  U R                  5      -  nU R                  R                  5        H#  u  p#USR                  [        U5      U5      -  nM%     US-  nU$ )	Nz[ zsize={} zuid={} gid={} zmode= zatime={} mtime={} z
"{}"={!r} ])r   r$   r   r   r   octr   r   r   rA   str)r   outkvs       r   r%   SFTPAttributes._debug_str   s    <<#:$$T\\22CKK#$++*A#**4;;DDC<<#7S..44CMM%DMM,E'..t}}dmmLLCIIOO%DA<&&s1vq11C &s

r   c                     U(       a  SnSU S-	     SU S-	  S-     -   nU(       a  USXS-  -      -  nU$ USXS-  -      -  nU$ )Nr   z-rz-wr
   z-xTtz-xSs )nsuidstickyrL   s       r   _rwxSFTPAttributes._rwx   sd    D16lT16Q,//6$a%.))C 
 6$a%.))C
r   c                 
   U R                   Gb  [        R                  " U R                   5      nU[        R                  :X  a  SnOU[        R                  :X  a  SnOuU[        R
                  :X  a  SnO^U[        R                  :X  a  SnOGU[        R                  :X  a  SnO0U[        R                  :X  a  SnOU[        R                  :X  a  SnOSnX R                  U R                   [        -  S	-	  U R                   [        R                  -  5      -  nX R                  U R                   [        -  S
-	  U R                   [        R                  -  5      -  nX R                  U R                   S-  U R                   [        R                  -  S5      -  nOSnU R                   b  U R                   ["        :X  a  SnO~[$        R&                  " U R                   5      n[)        [$        R$                  " 5       U R                   -
  5      S:  a  [$        R*                  " SU5      nO[$        R*                  " SU5      n[-        U SS5      nU R.                  nU R0                  nU R2                  nUc  SnUc  SnUc  SnSUUUUUU4-  $ )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_IFSOCKrU   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__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    [        U 5      R                  5       $ r)   )rK   encoder   s    r   asbytesSFTPAttributes.asbytes   s    4y!!r   )r   r   r   r   r   r   r   r   r)   )NN)F)__name__
__module____qualname____firstlineno____doc__r1   r3   r4   r5   r   r6   r   classmethodr!   r&   r-   r*   rE   r%   staticmethodrU   r{   r   __static_attributes__rQ   r   r   r   r      s    $ IKKM  (@  ?">  A
F"r   r   )rc   ro   paramiko.commonr   r   r   r   r   rQ   r   r   <module>r      s   &   ; ;W" W"r   