66from typing import TYPE_CHECKING
77
88from gitingest .config import MAX_DIRECTORY_DEPTH , MAX_FILES , MAX_TOTAL_SIZE_BYTES
9- from gitingest .output_formatter import format_node
10- from gitingest .schemas import FileSystemNode , FileSystemNodeType , FileSystemStats , Context
9+ from gitingest .output_formatter import DefaultFormatter
10+ from gitingest .schemas import FileSystemNode , FileSystemStats , Context
11+ from gitingest .schemas .filesystem import FileSystemDirectory , FileSystemFile , FileSystemSymlink
1112from gitingest .utils .ingestion_utils import _should_exclude , _should_include
1213from gitingest .utils .logging_config import get_logger
1314
@@ -69,11 +70,16 @@ def ingest_query(query: IngestionQuery) -> Context:
6970
7071 relative_path = path .relative_to (query .local_path )
7172
72- file_node = FileSystemNode (
73+ # file_node = FileSystemNode(
74+ # name=path.name,
75+ # type=FileSystemNodeType.FILE,
76+ # size=path.stat().st_size,
77+ # file_count=1,
78+ # path_str=str(relative_path),
79+ # path=path,
80+ # )
81+ file_node = FileSystemFile (
7382 name = path .name ,
74- type = FileSystemNodeType .FILE ,
75- size = path .stat ().st_size ,
76- file_count = 1 ,
7783 path_str = str (relative_path ),
7884 path = path ,
7985 )
@@ -90,13 +96,15 @@ def ingest_query(query: IngestionQuery) -> Context:
9096 "file_size" : file_node .size ,
9197 },
9298 )
93- return Context ([file_node ])
9499
95- logger .info ("Processing directory" , extra = {"directory_path" : str (path )})
96-
97- root_node = FileSystemNode (
100+ # root_node = FileSystemNode(
101+ # name=path.name,
102+ # type=FileSystemNodeType.DIRECTORY,
103+ # path_str=str(path.relative_to(query.local_path)),
104+ # path=path,
105+ # )
106+ root_node = FileSystemDirectory (
98107 name = path .name ,
99- type = FileSystemNodeType .DIRECTORY ,
100108 path_str = str (path .relative_to (query .local_path )),
101109 path = path ,
102110 )
@@ -116,7 +124,7 @@ def ingest_query(query: IngestionQuery) -> Context:
116124 },
117125 )
118126
119- return Context ([root_node ])
127+ return Context ([root_node ], DefaultFormatter (), query )
120128
121129
122130def _process_node (node : FileSystemNode , query : IngestionQuery , stats : FileSystemStats ) -> None :
@@ -160,9 +168,8 @@ def _process_node(node: FileSystemNode, query: IngestionQuery, stats: FileSystem
160168 continue
161169 _process_file (path = sub_path , parent_node = node , stats = stats , local_path = query .local_path )
162170 elif sub_path .is_dir ():
163- child_directory_node = FileSystemNode (
171+ child_directory_node = FileSystemDirectory (
164172 name = sub_path .name ,
165- type = FileSystemNodeType .DIRECTORY ,
166173 path_str = str (sub_path .relative_to (query .local_path )),
167174 path = sub_path ,
168175 depth = node .depth + 1 ,
@@ -200,9 +207,8 @@ def _process_symlink(path: Path, parent_node: FileSystemNode, stats: FileSystemS
200207 The base path of the repository or directory being processed.
201208
202209 """
203- child = FileSystemNode (
210+ child = FileSystemSymlink (
204211 name = path .name ,
205- type = FileSystemNodeType .SYMLINK ,
206212 path_str = str (path .relative_to (local_path )),
207213 path = path ,
208214 depth = parent_node .depth + 1 ,
@@ -212,7 +218,7 @@ def _process_symlink(path: Path, parent_node: FileSystemNode, stats: FileSystemS
212218 parent_node .file_count += 1
213219
214220
215- def _process_file (path : Path , parent_node : FileSystemNode , stats : FileSystemStats , local_path : Path ) -> None :
221+ def _process_file (path : Path , parent_node : FileSystemDirectory , stats : FileSystemStats , local_path : Path ) -> None :
216222 """Process a file in the file system.
217223
218224 This function checks the file's size, increments the statistics, and reads its content.
@@ -222,7 +228,7 @@ def _process_file(path: Path, parent_node: FileSystemNode, stats: FileSystemStat
222228 ----------
223229 path : Path
224230 The full path of the file.
225- parent_node : FileSystemNode
231+ parent_node : FileSystemDirectory
226232 The dictionary to accumulate the results.
227233 stats : FileSystemStats
228234 Statistics tracking object for the total file count and size.
@@ -257,11 +263,8 @@ def _process_file(path: Path, parent_node: FileSystemNode, stats: FileSystemStat
257263 stats .total_files += 1
258264 stats .total_size += file_size
259265
260- child = FileSystemNode (
266+ child = FileSystemFile (
261267 name = path .name ,
262- type = FileSystemNodeType .FILE ,
263- size = file_size ,
264- file_count = 1 ,
265268 path_str = str (path .relative_to (local_path )),
266269 path = path ,
267270 depth = parent_node .depth + 1 ,
0 commit comments