o
    DD©i<  ã                   @   sP   d dl mZ d dlmZmZmZmZ d dlZd dl	m
Z
 G dd„ de
e ƒZdS )é    )ÚPath)ÚAnyÚListÚMappingÚOptionalN)ÚBatchableMetadataProviderc                       sl   e Zd ZdZededee dede	eef fdd„ƒZ
dedd	f‡ fd
d„Zdejdee fdd„Z‡  ZS )ÚFilePathProvideraÔ  
    Provides the path to the current file on disk as metadata for the root
    :class:`~libcst.Module` node. Requires a :class:`~libcst.metadata.FullRepoManager`.
    The returned path will always be resolved to an absolute path using
    :func:`pathlib.Path.resolve`.

    Example usage:

    .. code:: python

        class CustomVisitor(CSTVisitor):
            METADATA_DEPENDENCIES = [FilePathProvider]

            path: pathlib.Path

            def visit_Module(self, node: libcst.Module) -> None:
                self.path = self.get_metadata(FilePathProvider, node)

    .. code::

        >>> mgr = FullRepoManager(".", {"libcst/_types.py"}, {FilePathProvider})
        >>> wrapper = mgr.get_metadata_wrapper_for_path("libcst/_types.py")
        >>> fqnames = wrapper.resolve(FilePathProvider)
        >>> {type(k): v for k, v in wrapper.resolve(FilePathProvider).items()}
        {<class 'libcst._nodes.module.Module'>: PosixPath('/home/user/libcst/_types.py')}

    Ú	root_pathÚpathsÚkwargsÚreturnc                    s   ‡ fdd„|D ƒ}|S )Nc                    s   i | ]	}|ˆ |   ¡ “qS © )Úresolve)Ú.0Úpath©r	   r   ú[/var/www/Datamplify/venv/lib/python3.10/site-packages/libcst/metadata/file_path_provider.pyÚ
<dictcomp>.   s    z.FilePathProvider.gen_cache.<locals>.<dictcomp>r   )Úclsr	   r
   r   Úcacher   r   r   Ú	gen_cache*   s   zFilePathProvider.gen_cacher   Nc                    s   t ƒ  |¡ || _d S )N)ÚsuperÚ__init__r   )Úselfr   ©Ú	__class__r   r   r   1   s   
zFilePathProvider.__init__Únodec                 C   s   |   || j¡ dS )NF)Úset_metadatar   )r   r   r   r   r   Úvisit_Module5   s   zFilePathProvider.visit_Module)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úclassmethodr   r   Ústrr   r   r   r   ÚcstÚModuler   Úboolr   Ú__classcell__r   r   r   r   r      s    ÿÿÿ
þ r   )Úpathlibr   Útypingr   r   r   r   Úlibcstr%   Úlibcst.metadata.base_providerr   r   r   r   r   r   Ú<module>   s
   