
    7gB                      H    d dl Z d dlZd dlmZmZmZmZ  G d d          ZdS )    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dS )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                 v    d| _         d| _        d| _        d| _        d| _        d| _        d| _        i | _        dS )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    L/var/www/html/syslog/venv/lib/python3.11/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>   sW     suu{jj{$DMr   c                 P    d                     |                                           S )Nz<SFTPAttributes: {}>)format
_debug_strr   s    r   __repr__zSFTPAttributes.__repr__S   s     %,,T__->->???r   c                 h     |             }|                     |           |||_        |||_        |S N)_unpackr   longname)r   msgr   r'   r   s        r   	_from_msgzSFTPAttributes._from_msgW   s>    suuS$DM$DMr   c                    |                                 | _        | j        | j        z  r|                                | _        | j        | j        z  r2|                                 | _        |                                 | _        | j        | j        z  r|                                 | _	        | j        | j
        z  r2|                                 | _        |                                 | _        | j        | j        z  rT|                                 }t          |          D ]2}|                                | j        |                                <   1d S d S 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   kkmm;' 	+==??DL;)) 	(++--DK++--DK;.. 	);;==DL;)) 	*KKMMDMKKMMDM;++ 	?KKMME5\\ ? ?.1nn.>.>	#..**++	? 	?? ?r   c                    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k    r| xj         | j        z  c_         |                    | j                    | j         | j        z  r|                    | j                   | j         | j        z  r4|                    | j                   |                    | j                   | j         | j        z  r|                    | j                   | j         | j
        z  rN|                    t!          | j                             |                    t!          | j	                             | j         | j        z  rp|                    t          | j                             | j                                        D ]/\  }}|                    |           |                    |           0d S )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>)KKK#$+*AKK4++KK<#KK400KKM%DM,EKK4++KKty>>AKK4--KKDK   ;' 	(MM$,''';)) 	%KK$$$KK$$$;.. 	&KK%%%;)) 	,KKDM**+++KKDM**+++;++ 	$KKDI''' IOO-- $ $Ss###s####r   c                    d}| j         |d                    | j                   z  }| j        *| j        #|d                    | j        | j                  z  }| j        |dt          | j                  z   dz   z  }| j        *| j        #|d                    | j        | j                  z  }| j        	                                D ]+\  }}|d                    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22CK#$+*A#**4;DDDC<#7S...44CM%DM,E'..t}dmLLLCIOO%% 	2 	2DAq<&&s1vvq111CCs

r   Fc                     |rd}d| dz	           d| dz	  dz           z   }|r|d|| dz  z            z  }n|d|| dz  z            z  }|S )Nr
   z-rz-wr	   z-xTtz-xSs )nsuidstickyrE   s       r   _rwxzSFTPAttributes._rwx   sk     	D16lT16Q,// 	*6$!a%.))CC6$!a%.))C
r   c                 :   | j         Kt          j        | j                   }|t          j        k    rd}nt|t          j        k    rd}na|t          j        k    rd}nN|t          j        k    rd}n;|t          j        k    rd}n(|t          j        k    rd}n|t          j	        k    rd}nd	}|| 
                    | j         t          z  d
z	  | j         t          j        z            z  }|| 
                    | j         t          z  dz	  | j         t          j        z            z  }|| 
                    | j         dz  | j         t          j        z  d          z  }nd}| j        | j        t"          k    rd}npt%          j        | j                  }t)          t%          j                    | j        z
            dk    rt%          j        d|          }nt%          j        d|          }t-          | dd	          }| j        }| j        }| j        }|d}|d}|d}d||||||fz  S )z=create a unix-style long description of the file (like ls -l)N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|##%%%%%%%%%%&&$))$*DL4<,G  B $))#)4<$,+F  B $))q $,"=t  BB BM!t}	'A'A&GG66J49;;.//*<<-
J??-zBB4S11 kk|;C;C<D
 /2
 
 	
r   c                 D    t          |                                           S r%   )rD   encoder   s    r   asbyteszSFTPAttributes.asbytes   s    4yy!!!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
 A
 A
F" " " " "r   r   )rZ   rf   paramiko.commonr   r   r   r   r   rI   r   r   <module>r}      sy   &   ; ; ; ; ; ; ; ; ; ; ; ;W" W" W" W" W" W" W" W" W" W"r   