Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/site-packages/ftputil/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/site-packages/ftputil/__pycache__/stat.cpython-38.pyc
U

O��gU��@s�dZddlZddlZddlZddlZddlZddlZddddgZdZ	dZ
dZGd	d�de�Z
Gd
d�d�ZGdd�de�ZGdd�de�ZGd
d�d�ZdS)zE
ftputil.stat - stat result, parsers, and FTP stat'ing for `ftputil`
�N�
StatResult�Parser�
UnixParser�MSParser�<i�Qc
@sFeZdZdZdddddddd	d
ddd
d�Zdd�Zdd�Zdd�ZdS)rzP
    Support class resembling a tuple like that returned from `os.(l)stat`.
    r���������	�
�)�st_mode�st_ino�st_dev�st_nlink�st_uid�st_gid�st_size�st_atime�st_mtime�st_ctime�_st_name�
_st_targetcCsd|_d|_t|_dS)N�)rr�UNKNOWN_PRECISION�_st_mtime_precision)�self�sequence�r#�9/opt/cppython/lib/python3.8/site-packages/ftputil/stat.py�__init__0s	zStatResult.__init__cCs*||jkr||j|Std�|���dS)Nz)'StatResult' object has no attribute '{}')�_index_mapping�AttributeError�format)r!�	attr_namer#r#r$�__getattr__=s

�zStatResult.__getattr__cCs\tdd�|j��D��}g}t|�D]\}}|�d�|||��q$d�t|�jd�|��S)Ncss|]\}}||fVqdS)Nr#)�.0�k�vr#r#r$�	<genexpr>Hsz&StatResult.__repr__.<locals>.<genexpr>z{}={!r}z{}({})z, )	�dictr&�items�	enumerate�appendr(�type�__name__�join)r!Z
index_to_name�argument_strings�index�itemr#r#r$�__repr__Es
zStatResult.__repr__N)r4�
__module__�__qualname__�__doc__r&r%r*r9r#r#r#r$rs"�
c
@szeZdZdZdddddddd	d
ddd
d�Ze�d�Zdd�Zd!dd�Z	dd�Z
dd�Zedd��Z
d"dd�Zd#dd�Zd S)$rzu
    Represent a parser for directory lines. Parsers for specific directory
    formats inherit from this class.
    rrr	r
rrr
rrrr�)�jan�feb�mar�apr�may�jun�jul�aug�sep�oct�nov�decz^total\s+\d+cCs |��sdS|j�|�}t|�S)aR
        Return a true value if the line should be ignored, i. e. is assumed to
        _not_ contain actual directory/file/link data. A typical example are
        summary lines like "total 23" which are emitted by some FTP servers.

        If the line should be used to extract stat data from it, return a false
        value.
        T)�strip�_total_regex�search�bool)r!�line�matchr#r#r$�ignores_linejs
zParser.ignores_line�cCstd��dS)a�
        Return a `StatResult` object as derived from the string `line`. The
        parser code to use depends on the directory format the FTP server
        delivers (also see examples at end of file).

        If the given text line can't be parsed, raise a `ParserError`.

        For the definition of `time_shift` see the docstring of
        `FTPHost.set_time_shift` in `ftputil.py`. Not all parsers use the
        `time_shift` parameter.
        zmust be defined by subclassN)�NotImplementedError)r!rN�
time_shiftr#r#r$�
parse_line{szParser.parse_linec	Cs�t|�dkrtj�d�|���d}|dd�D]}|dk}|d>|}q.|ddkr^|tjB}|ddkrt|tjB}tjtj	tj
tjtjtj
tjdd	�}|d}||kr�|||B}ntj�d
�|���|S)a
        Return an integer from the `mode_string`, compatible with the `st_mode`
        value in stat results. Such a mode string may look like "drwxr-xr-x".

        If the mode string can't be parsed, raise an
        `ftputil.error.ParserError`.
        rzinvalid mode string '{}'rr�-r	�sr)�b�c�d�l�prVrU�?z unknown file type character '{}')�len�ftputil�error�ParserErrorr(�stat�S_ISUID�S_ISGID�S_IFBLK�S_IFCHR�S_IFDIR�S_IFLNK�S_IFIFO�S_IFSOCK�S_IFREG)r!�mode_stringr�bitZfile_type_to_mode�	file_typer#r#r$�parse_unix_mode�s8
�

��zParser.parse_unix_modec	Cs8z
t|�WStk
r2tj�d�||���YnXdS)a
        Return `int_string` converted to an integer.

        If it can't be converted, raise a `ParserError`, using
        `int_description` in the error message. For example, if the integer
        value is a day, pass "day" for `int_description`.
        znon-integer {} value {!r}N)�int�
ValueErrorr^r_r`r()r!Z
int_stringZint_descriptionr#r#r$�_as_int�s

�zParser._as_intcCs|ztj||||||tjjd�WStk
rv|d�d|d�d|d�d|d�d|d�d|d��}tj�d�|���YnXdS)	z�
        Return UTC `datetime.datetime` object for the given year, month, day,
        hour, minute and second.

        If there are invalid values, for example minute > 59, raise a
        `ParserError`.
        )�tzinfoZ04drU�02d� �:zinvalid datetime {0!r}N)�datetime�timezone�utcrpr^r_r`r()�year�month�day�hour�minute�secondZinvalid_datetimer#r#r$�	_datetime�s 	�0��zParser._datetimeFcCsHz|j|��}Wn&tk
r8tj�d�|���YnX|�|d�}d|k}|rpt}|�|d�dd}	}
}n�t	}|�
d�\}
}d|�|
d�|�|d�}}
}tj�tj
j�tj|d	�}
|
j}	|�|	|||
|d�|
jdd
�tjdd	�kr�|	d8}	|�|	|||
|d�tj|d	�}|��}|d
k�r2t}d
}|�r@||fS|SdS)a�
        Return a floating point number, like from `time.mktime`, by parsing the
        string arguments `month_abbreviation`, `day` and `year_or_time`. The
        parameter `time_shift` is the difference "time on server" - "time on
        client" and is available as the `time_shift` parameter in the
        `parse_line` interface.

        If `with_precision` is true return a two-element tuple consisting of
        the floating point number as described in the previous paragraph and
        the precision of the time in seconds. The default is `False` for
        backward compatibility with custom parsers.

        The precision value takes into account that, for example, a time string
        like "May 26  2005" has only a precision of one day. This information
        is important for the `upload_if_newer` and `download_if_newer` methods
        in the `FTPHost` class.

        Times in Unix-style directory listings typically have one of these
        formats:

        - "Nov 23 02:33" (month name, day of month, time)

        - "May 26  2005" (month name, day of month, year)

        If this method can't make sense of the given arguments, it raises an
        `ftputil.error.ParserError`.
        z invalid month abbreviation {0!r}r{ruryrNr|r}��seconds)r~�xrrQ)�_month_numbers�lower�KeyErrorr^r_r`r(rq�
DAY_PRECISION�MINUTE_PRECISION�splitrv�nowrwrx�	timedeltaryr�replace�	timestampr)r!Zmonth_abbreviationr{�year_or_timerS�with_precisionrzZ
year_is_known�st_mtime_precisionZserver_yearr|r}�_yearZ
server_nowZserver_utc_datetimerr#r#r$�parse_unix_time�sf�


�
�
����
�
zParser.parse_unix_timecs2�fdd�|�d�D�\}}}|dkr(n|dkr:d|}nd|}z(|dd	�|d
d�|d}}	}
Wn&tk
r�tj�d�|���YnX��|d
���|	d�}}	|dkr�|
dkr�d}|dkr�|
dkr�|d7}��|||||	d�}|tj	|d�}|�
�}
|
dk�rt}d}
nt}|�r*|
|fS|
SdS)am
        Return a floating point number, like from `time.mktime`, by parsing the
        string arguments `date` and `time_`. The parameter `time_shift` is the
        difference

            "time on server" - "time on client"

        and can be set as the `time_shift` parameter in the `parse_line`
        interface.

        If `with_precision` is true return a two-element tuple consisting of
        the floating point number as described in the previous paragraph and
        the precision of the time in seconds. The default is `False` for
        backward compatibility with custom parsers.

        The precision value takes into account that, for example, a time string
        like "10-23-2001 03:25PM" has only a precision of one minute. This
        information is important for the `upload_if_newer` and
        `download_if_newer` methods in the `FTPHost` class.

        Usually, the returned precision is `MINUTE_PRECISION`, except when the
        date is before the epoch, in which case the returned `st_mtime` value
        is set to 0.0 and the precision to `UNKNOWN_PRECISION`.

        Times in MS-style directory listings typically have the format
        "10-23-01 03:25PM" (month-day_of_month-two_digit_year, hour:minute,
        am/pm).

        If this method can't make sense of the given arguments, it raises an
        `ftputil.error.ParserError`.
        csg|]}��|d��qS)zyear/month/day)rq)r+�part�r!r#r$�
<listcomp>nsz(Parser.parse_ms_time.<locals>.<listcomp>rUi��Fili�rrr	rzinvalid time string '{}'r|r}r=�A�Pr�rQN)
r��
IndexErrorr^r_r`r(rqrrvr�r�rr�)r!�date�time_rSr�rzr{ryr|r}Zam_pmZserver_datetimeZclient_datetimerr�r#r�r$�
parse_ms_timeCs6+
�
(
zParser.parse_ms_timeN)rQ)F)F)r4r:r;r<r��re�compilerKrPrTrnrq�staticmethodrr�r�r#r#r#r$rRs0�

-
�
ec@s&eZdZdZedd��Zddd�ZdS)	rz<
    `Parser` class for Unix-specific directory format.
    cCs�|��}d}|d}t|�|kr2tj�d�|���zt|d�Wn$tk
rf|�d|d�}Yn"X|�d|d�}d}|�|d�|S)a
        Split a line in metadata, nlink, user, group, size, month, day,
        year_or_time and name and return the result as an nine-element list of
        these values. If the name is a link, it will be encoded as a string
        "link_name -> link_target".
        rr�line '{}' can't be parsedrNr)	r�r]r^r_r`r(rorp�insert)rNZ
line_partsZFIELD_COUNT_WITHOUT_USERIDZFIELD_COUNT_WITH_USERIDZUSER_FIELD_INDEXr#r#r$�_split_line�s
zUnixParser._split_linerQcCsz |�|�\	}}}}}}}	}
}Wn2tk
rR}ztj�t|���W5d}~XYnX|�|�}
d}d}t|�}|}|}t|�}d}|j||	|
|dd�\}}d}|�	d�dkr�tj�d�
|���n(|�	d�dkr�|�d�\}}n
|d}}t|
|||||||||f
�}||_
||_||_|S)a
        Return a `StatResult` instance corresponding to the given text line.
        The `time_shift` value is needed to determine to which year a datetime
        without an explicit year belongs.

        If the line can't be parsed, raise a `ParserError`.
        NT�r�z -> rz%name '{}' contains more than one "->")r�rpr^r_r`�strrnror��countr(r�rr rr)r!rNrSrkZnlink�user�group�sizerzr{r��name�excrrrrrrrrrr�r�st_nameZ	st_target�stat_resultr#r#r$rT�sn
��"
�
�
��zUnixParser.parse_lineN)rQ)r4r:r;r<r�r�rTr#r#r#r$r�s
c@seZdZdZddd�ZdS)rz:
    `Parser` class for MS-specific directory format.
    rQcCsz|�dd�\}}}}Wn&tk
r>tj�d�|���YnXd}|dkrX|tjB}n
|tjB}d}d}	d}
d}d}|dkr�zt	|�}
Wq�tk
r�tj�d�|���Yq�Xnd}
d}|j
|||dd�\}}d}t|||	|
|||
|||f
�}||_d|_
||_|S)	aY
        Return a `StatResult` instance corresponding to the given text line
        from a FTP server which emits "Microsoft format" (see end of file).

        If the line can't be parsed, raise a `ParserError`.

        The parameter `time_shift` isn't used in this method but is listed for
        compatibility with the base class.
        Nr	r��z<DIR>zinvalid size {}Tr�)r�rpr^r_r`r(rarfrjror�rrrr )r!rNrSr�r�Zdir_or_sizer�rrrrrrrrrr�rr�r#r#r$rTsX
�
��zMSParser.parse_lineN)rQ)r4r:r;r<rTr#r#r#r$r�sc@sheZdZdZdd�Zdd�Zdd�Zdd	�Zddd�Zdd
d�Z	dd�Z
dd�Zddd�Zddd�Z
dS)�_StatzD
    Methods for stat'ing directories, links and regular files.
    cCs,||_|j|_t�|_d|_tj��|_	dS)NT)
�_host�path�_pathr�_parser�_allow_parser_switchingr^Z
stat_cacheZ	StatCache�_lstat_cache)r!�hostr#r#r$r%Us
z_Stat.__init__cCs|j�|�S)zm
        Return a list of lines, as fetched by FTP's `LIST` command, when
        applied to `path`.
        )r�Z_dir�r!r�r#r#r$�	_host_dir`sz_Stat._host_dirccs�|�|�}|j}|jrFt|�|jjkrFtt�dt|���}|�	|�|D]\}|j
�|�r\qJ|j
�||j
���}|j|j
j|j
jfkr�qJ|j�||j�}|||<|VqJdS)z�
        Yield stat results extracted from the directory listing `path`. Omit
        the special entries for the directory itself and its parent directory.
        g�������?N)r�r�Z_enabledr]�_cacher�ro�math�ceil�resizer�rPrTr�rSr�curdir�pardirr�r5)r!r��lines�cache�new_sizerNr�Z	loop_pathr#r#r$�_stat_results_from_dirgs

z_Stat._stat_results_from_dircCsR|j�|�}|j�|�s*tj�d�|���g}|�|�D]}|j}|�	|�q8|S)a
        Return a list of directories, files etc. in the directory named `path`.

        Like `os.listdir` the returned list elements have the type of the path
        argument.

        If the directory listing from the server can't be parsed, raise a
        `ParserError`.
        z8550 {}: no such directory or wrong directory parser used)
r��abspath�isdirr^r_�PermanentErrorr(r�rr2)r!r��namesr�r�r#r#r$�
_real_listdir�s�z_Stat._real_listdirTcCs�|j�|�}||jkr |j|S|dkr4tj�d��|j�|�\}}|j�|�sX|sXdSd}|�|�D]}|j	|krf|}qf|dk	r�|S|r�tj�
d�|���ndSdS)a#
        Return an object similar to that returned by `os.lstat`.

        If the directory listing from the server can't be parsed, raise a
        `ParserError`. If the directory can be parsed and the `path` is not
        found, raise a `PermanentError`. That means that if the directory
        containing `path` can't be parsed we get a `ParserError`, independent
        on the presence of `path` on the server.

        (`_exception_for_missing_path` is an implementation aid and _not_
        intended for use by ftputil clients.)
        �/z can't stat remote root directoryNz!550 {}: no such file or directory)r�r�r�r^r_ZRootDirErrorr�r�r�rr�r()r!r��_exception_for_missing_path�dirname�basenameZlstat_result_for_pathr�r#r#r$�_real_lstat�s&



�z_Stat._real_lstatcCs�|}t�}|�||�}|dkr"dSt�|j�s2|S|j�|�\}}|j�||j�}|j�	|j�
|��}||kr�tj�
d�|���|�|�q
dS)a�
        Return info from a "stat" call on `path`.

        If the directory containing `path` can't be parsed, raise a
        `ParserError`. If the listing can be parsed but the `path` can't be
        found, raise a `PermanentError`. Also raise a `PermanentError` if
        there's an endless (cyclic) chain of symbolic links "behind" the
        `path`.

        (`_exception_for_missing_path` is an implementation aid and _not_
        intended for use by ftputil clients.)
        Nz6recursive link structure detected for remote path '{}')�setr�ra�S_ISLNKrr�r�r5rr��normpathr^r_ZRecursiveLinksErrorr(�add)r!r�r�Z
original_pathZ
visited_pathsZlstat_resultr��_r#r#r$�
_real_stat�s"��z_Stat._real_statcOsfz$|||�}||jk	r |r d|_|WStjjk
r`|jrZd|_t�|_|||�YS�YnXdS)z�
        Call `method` with the `args` and `kwargs` once. If that results in a
        `ParserError` and only one parser has been used yet, try the other
        parser. If that still fails, propagate the `ParserError`.
        FN)r�r�r^r_r`rr�)r!�method�args�kwargs�resultr#r#r$Z__call_with_parser_retrys	
z_Stat.__call_with_parser_retrycCs|�|j|�S)z�
        Return a list of items in `path`.

        Raise a `PermanentError` if the path doesn't exist, but maybe raise
        other exceptions depending on the state of the server (e. g. timeout).
        )�_Stat__call_with_parser_retryr�r�r#r#r$�_listdir2sz_Stat._listdircCs|�|j||�S)z�
        Return a `StatResult` without following links.

        Raise a `PermanentError` if the path doesn't exist, but maybe raise
        other exceptions depending on the state of the server (e. g. timeout).
        )r�r��r!r�r�r#r#r$�_lstat;s
�z_Stat._lstatcCs|�|j||�S)z�
        Return a `StatResult` with following links.

        Raise a `PermanentError` if the path doesn't exist, but maybe raise
        other exceptions depending on the state of the server (e. g. timeout).
        )r�r�r�r#r#r$�_statFs
�z_Stat._statN)T)T)T)T)r4r:r;r<r%r�r�r�r�r�r�r�r�r�r#r#r#r$r�Ns4
:
*	
r�)r<rvr�r�raZ
ftputil.errorr^Zftputil.stat_cache�__all__r�r�r�tuplerrrrr�r#r#r#r$�<module>s"6?pO

F1le Man4ger