
    dh                     N    S SK r S SKJrJrJr  S SKJr  S SKJr   " S S\5      r	g)    N)CallableIteratorOptional)Document)
BaseLoaderc                   n    \ rS rSrSr   SS\S\\   S\\   S\\\/\4      4S jjr	S	\
\   4S
 jrSrg)	GitLoader	   a  Load `Git` repository files.

The Repository can be local on disk available at `repo_path`,
or remote at `clone_url` that will be cloned to `repo_path`.
Currently, supports only text files.

Each document represents one file in the repository. The `path` points to
the local Git repository, and the `branch` specifies the branch to load
files from. By default, it loads from the `main` branch.
N	repo_path	clone_urlbranchfile_filterc                 4    Xl         X l        X0l        X@l        g)aO  

Args:
    repo_path: The path to the Git repository.
    clone_url: Optional. The URL to clone the repository from.
    branch: Optional. The branch to load files from. Defaults to `main`.
    file_filter: Optional. A function that takes a file path and returns
      a boolean indicating whether to load the file. Defaults to None.
N)r   r   r   r   )selfr   r   r   r   s        `/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/document_loaders/git.py__init__GitLoader.__init__   s      #"&    returnc              #     #     SSK JnJn  [        R
                  R                  U R                  5      (       d&  U R                  c  [        SU R                   S35      eU R                  (       a  [        R
                  R                  [        R
                  R                  U R                  S5      5      (       aL  U" U R                  5      nUR                  R                  R                  U R                  :w  a  [        S5      eO&UR                  U R                  U R                  5      nUR                   R!                  U R"                  5        O7U" U R                  5      nUR                   R!                  U R"                  5        UR%                  5       R'                  5        GH@  n[)        XQ5      (       d  M  [        R
                  R                  U R                  UR
                  5      nUR+                  U/5      n[-        U5      (       a  Mn  U R.                  (       a  U R/                  U5      (       d  M  [        R
                  R1                  X`R                  5      n [3        US5       n	U	R5                  5       n
[        R
                  R7                  UR8                  5      S	   n U
R;                  S
5      nUUUR8                  US.n[?        XS9v   S S S 5        GMC     g ! [         a  n[        S5      UeS nAff = f! [<         a     S S S 5        GMz  f = f! , (       d  f       GM  = f! [@         a  n[C        SU SU 35         S nAGM  S nAff = f7f)Nr   )BlobRepozTCould not import git python package. Please install it with `pip install GitPython`.zPath z does not existz.gitz6A different repository is already cloned at this path.rb   zutf-8)source	file_path	file_name	file_type)page_contentmetadatazError reading file z: )"gitr   r   ImportErrorospathexistsr   r   
ValueErrorisdirjoinremotesoriginurl
clone_fromcheckoutr   treetraverse
isinstanceignoredlenr   relpathopenreadsplitextnamedecodeUnicodeDecodeErrorr   	Exceptionprint)r   r   r   exrepoitemr   ignored_filesrel_file_pathfcontentr   text_contentr    es                  r   	lazy_loadGitLoader.lazy_load*   s    	& ww~~dnn--$..2HuT^^$4ODEE^^ ww}}RWW\\$..&ABBDNN+ <<&&**dnn<$P  =
 t~~t~~FHHdkk*'DHHdkk*IIK((*Dd))T^^TYY?I LL)5M=!! (8(8(C(CGGOOI~~FM>)T*affhG " 0 0 ;A >I!'.~~g'>
 #0%2%)YY%.	 H #PP! +*! +5  	B 	b . !  +*! +*"  >+I;b<==>s   M%K0 IM%+L;7=L(5LL("L;*M%0
L:LLM%
L%L(L;!M%$L%%L((
L8	2L;5M%8L;;
M"MM%M""M%)r   r   r   r   )NmainN)__name__
__module____qualname____firstlineno____doc__strr   r   boolr   r   r   rE   __static_attributes__ r   r   r	   r	   	   sf    	 $( &7;'' C=' 	'
 hud{34'*?>8H- ?>r   r	   )
r#   typingr   r   r   langchain_core.documentsr   )langchain_community.document_loaders.baser   r	   rP   r   r   <module>rT      s"    	 / / - @`>
 `>r   