
    hhl
                         d dl Z d dlmZmZmZmZ d dlmZmZ d dl	m
Z
 d dlmZ d dlmZ  e
             G d de                      ZdS )	    N)AnyDictIteratorType)BaseBlobParser
BaseLoader)beta)Document)Blobc                        e Zd ZU dZee         ed<   eee	f         ed<   dee         de	ddf fdZ
d	edee         fd
Z xZS )DocumentLoaderAsParsera$  A wrapper class that adapts a document loader to function as a parser.

    This class is a work-around that adapts a document loader to function as a parser.
    It is recommended to use a proper parser, if available.

    Requires the document loader to accept a `file_path` parameter.
    DocumentLoaderTypedoc_loader_kwargsdocument_loader_classkwargsreturnNc                     t                                                       || _        || _        t	          j        |j                  }d|j        vrt          |j         d          dS )aW  
        Initializes the DocumentLoaderAsParser with a specific document loader class
        and additional arguments.

        Args:
            document_loader_class (Type[BaseLoader]): The document loader class to adapt
            as a parser.
            **kwargs: Additional arguments passed to the document loader's constructor.

        Raises:
            TypeError: If the specified document loader does not accept a `file_path` parameter,
                       an exception is raised, as only loaders with this parameter can be adapted.

        Example:
            ```
            from langchain_community.document_loaders.excel import UnstructuredExcelLoader

            # Initialize parser adapter with a document loader
            excel_parser = DocumentLoaderAsParser(UnstructuredExcelLoader, mode="elements")
            ```
        	file_pathzj does not accept `file_path`.Only document loaders with `file_path` parametercan be morphed into a parser.N)	super__init__DocumentLoaderClassdocument_loader_kwargsinspect	signature
parameters	TypeError__name__)selfr   r   init_signature	__class__s       /var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/langchain_community/document_loaders/parsers/documentloader_adapter.pyr   zDocumentLoaderAsParser.__init__   s~    , 	#8 &,# !*+@+IJJn777(1 0 0 0   87    blobc              #      K    | j         dd|j        i| j        }|                                D ]%}|j                            |j                   |V  &dS )zI
        Use underlying DocumentLoader to lazily parse the blob.
        r   N )r   pathr   	lazy_loadmetadataupdate)r   r#   
doc_loaderdocuments       r!   
lazy_parsez!DocumentLoaderAsParser.lazy_parse:   s       .T- 
 
i
#'#>
 

 #,,.. 	 	H$$T]333NNNN	 	r"   )r   
__module____qualname____doc__r   r   __annotations__r   strr   r   r   r   r
   r,   __classcell__)r    s   @r!   r   r   
   s           Z((((CH~%%%!d:.> !# !RV ! ! ! ! ! !F	t 	(: 	 	 	 	 	 	 	 	r"   r   )r   typingr   r   r   r   langchain.document_loaders.baser   r   langchain_core._apir	   langchain_core.documentsr
   langchain_core.documents.baser   r   r%   r"   r!   <module>r8      s     , , , , , , , , , , , , F F F F F F F F $ $ $ $ $ $ - - - - - - . . . . . . 8 8 8 8 8^ 8 8 8 8 8r"   