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/pysftp/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


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

P��g)�@s�dZddlmZddlZddlZddlZddlmZmZm	Z	dd�Z
dd�ZGd	d
�d
e�Z
ejfdd�Zejfd
d�Zdd�Zddd�Zeddd��ZdS)z8functions and classes that support the Connection object�)�contextmanagerN)�S_IMODE�S_ISDIR�S_ISREGcCstj�tj�ddd��S)z:return a proper path to ssh's known_host file for the user�~z.ssh�known_hosts)�os�path�
expanduser�join�rr�;/opt/cppython/lib/python3.8/site-packages/pysftp/helpers.pyr
srcCstttt|���dd��S)aySFTAttributes st_mode returns an stat type that shows more than what
    can be set.  Trim off those bits and convert to an int representation.
    if you want an object that was `chmod 711` to return a value of 711, use
    this function

    :param int val: the value of an st_mode attr returned by SFTPAttributes

    :returns int: integer representation of octal mode

    ���N)�int�str�octr)�valrrr
�st_mode_to_intsrc@s~eZdZdZdd�Zdd�Zdd�Zdd	�Zed
d��Z	e	j
dd��Z	ed
d��Zej
dd��Zedd��Zej
dd��ZdS)�WTCallbacksz1an object to house the callbacks, used internallycCsg|_g|_g|_dS)zset instance varsN)�_flist�_dlist�_ulist��selfrrr
�__init__szWTCallbacks.__init__cCs|j�|�dS)zecalled for regular files, appends pathname to .flist

        :param str pathname: file path
        N)r�append�r�pathnamerrr
�file_cb%szWTCallbacks.file_cbcCs|j�|�dS)zhcalled for directories, appends pathname to .dlist

        :param str pathname: directory path
        N)rrrrrr
�dir_cb,szWTCallbacks.dir_cbcCs|j�|�dS)ztcalled for unknown file types, appends pathname to .ulist

        :param str pathname: unknown entity path
        N)rrrrrr
�unk_cb3szWTCallbacks.unk_cbcCs
t|j�S)z�return a sorted list of files currently traversed

        :getter: returns the list
        :setter: sets the list
        :type: list
        )�sortedrrrrr
�flist:szWTCallbacks.flistcCs
||_dS)zsetter for _flist N)r�rrrrr
r"DscCs
t|j�S)z�return a sorted list of directories currently traversed

        :getter: returns the list
        :setter: sets the list
        :type: list
        )r!rrrrr
�dlistIszWTCallbacks.dlistcCs
||_dS)zsetter for _dlist N)rr#rrr
r$SscCs
t|j�S)z�return a sorted list of unknown entities currently traversed

        :getter: returns the list
        :setter: sets the list
        :type: list
        )r!rrrrr
�ulistXszWTCallbacks.ulistcCs
||_dS)zsetter for _ulist N)rr#rrr
r%bsN)
�__name__�
__module__�__qualname__�__doc__rrrr �propertyr"�setterr$r%rrrr
rs"
	

	

	rccsvd}|d|kr|}d}|�|�}|rP|dr@||d|d<n||d|d<|D]}tj�||�}|rT|VqTdS)z�generator to iterate over a file path forwards

    :param str thepath: the path to navigate forwards
    :param str sep: *Default: os.sep* - the path separator to use

    :returns: (iter)able of strings

    �r�N��splitrr	r)�thepath�sep�preZcurpath�parts�partrrr
�path_advancehs

r5ccsVd}|d|kr|}|�|�}|rRtjj|�rDd|tjj|�fV|dd�}qdS)z�generator to iterate over a file path in reverse

    :param str thepath: the path to retreat over
    :param str sep: *Default: os.sep* - the path separator to use

    :returns: (iter)able of strings

    r,rz%s%sN���r.)r0r1r2r3rrr
�path_retreat�s	
r7cCs*|dtjtjfkrd|}tj�||�S)awhen copying or moving a directory structure, you need to re-parent the
    oldpath.  When using os.path.join to calculate this new path, the
    appearance of a / root path at the beginning of oldpath, supplants the
    newparent and we don't want this to happen, so we need to make the oldpath
    root appear as a child of the newparent.

    :param: str newparent: the new parent location for oldpath (target)
    :param str oldpath: the path being adopted by newparent (source)

    :returns: (str) resulting adoptive path
    r�.)�	posixpathr1�ntpathrr	r)Z	newparentZoldpathrrr
�reparent�s
r;TcCslt�|�D]\}tj�||�}t�|�j}t|�rL||�|rft||||�q
t|�r^||�q
||�q
dS)aon the local file system, recursively descend, depth first, the
    directory tree rooted at localpath, calling discreet callback functions
    for each regular file, directory and unknown file type.

    :param str localpath:
        root of remote directory to descend, use '.' to start at
        :attr:`.pwd`
    :param callable fcallback:
        callback function to invoke for a regular file.
        (form: ``func(str)``)
    :param callable dcallback:
        callback function to invoke for a directory. (form: ``func(str)``)
    :param callable ucallback:
        callback function to invoke for an unknown file type.
        (form: ``func(str)``)
    :param bool recurse: *Default: True* -  should it recurse

    :returns: None

    :raises: OSError, if localpath doesn't exist

    N)	r�listdirr	r�stat�st_moder�walktreer)�	localpathZ	fcallbackZ	dcallbackZ	ucallbackZrecurse�entryr�moderrr
r?�s
r?c	cs6z$t��}|dk	rt�|�dVW5t�|�XdS)a(context manager that can change to a optionally specified local
    directory and restores the old pwd on exit.

    :param str|None localpath: *Default: None* -
        local path to temporarily make the current directory
    :returns: None
    :raises: OSError, if local path doesn't exist
    N)r�chdir�getcwd)r@Z
original_pathrrr
�cd�s


rE)T)N)r)�
contextlibrr:r9rr=rrrrr�objectrr1r5r7r;r?rErrrr
�<module>sK
)

F1le Man4ger