
    3fit
                         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y)	    N)AnyDictIteratorType)BaseBlobParser
BaseLoader)beta)Document)Blobc                   r     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      y)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/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_community/document_loaders/parsers/documentloader_adapter.pyr   zDocumentLoaderAsParser.__init__   so    , 	#8 &,# !**+@+I+IJn777(112 30 0  8    blobc              #      K    | j                   dd|j                  i| j                  }|j                         D ]+  }|j                  j                  |j                         | - yw)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:   sk      .T-- 
ii
#'#>#>

 #,,. 	H$$T]]3N	s   A(A*)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_classic.document_loaders.baser   r   langchain_core._apir	   langchain_core.documentsr
   langchain_core.documents.baser   r   r%   r"   r!   <module>r8      s7     , , N $ - . 8^ 8 8r"   