U
    hB                     @   sH   d dl mZ d dlmZmZ d dlmZ d dlmZ G dd deZ	dS )    )Path)ListUnion)Document)
BaseLoaderc                   @   sB   e Zd ZdZddeeef eddddZee	 dd	d
Z
dS )NotionDirectoryLoaderzLoad `Notion directory` dump.zutf-8encodingN)pathr	   returnc                C   s   || _ || _dS )zInitialize with a file path.N)	file_pathr	   )selfr
   r	    r   O/tmp/pip-unpacked-wheel-9gdii04g/langchain_community/document_loaders/notion.py__init__   s    zNotionDirectoryLoader.__init__)r   c              
   C   sf   t t| jd}g }|D ]D}t|| jd}| }W 5 Q R X dt|i}|t	||d q|S )zLoad documents.z**/*.mdr   source)Zpage_contentmetadata)
listr   r   globopenr	   readstrappendr   )r   pathsZdocspftextr   r   r   r   load   s    zNotionDirectoryLoader.load)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r   r   r   r   	   s    r   N)
pathlibr   typingr   r   Zlangchain_core.documentsr   Z)langchain_community.document_loaders.baser   r   r   r   r   r   <module>   s   