Spaces:
Sleeping
Sleeping
Update chunk_python_code.py
Browse files- chunk_python_code.py +1 -40
chunk_python_code.py
CHANGED
@@ -278,43 +278,4 @@ def handle_first_level_func(function_node, documents, source_code, imports_dict)
|
|
278 |
"imports": function_imports
|
279 |
}
|
280 |
)
|
281 |
-
documents.append(doc)
|
282 |
-
|
283 |
-
|
284 |
-
# Example usage
|
285 |
-
#file_path = r"C:\Users\Anwender\Downloads\exampleScript.py"
|
286 |
-
|
287 |
-
#with open(file_path, "r", encoding="utf-8") as file:
|
288 |
-
# source_code = file.read()
|
289 |
-
#chunkPythonFiles(source_code, file_path)
|
290 |
-
|
291 |
-
|
292 |
-
import os
|
293 |
-
|
294 |
-
def process_folder(folder_path):
|
295 |
-
# Initialize a counter for the number of Python files
|
296 |
-
python_file_count = 0
|
297 |
-
docsT = []
|
298 |
-
# Walk through all subdirectories and files in the folder
|
299 |
-
for root, _, files in os.walk(folder_path):
|
300 |
-
for file_name in files:
|
301 |
-
# Create the full file path
|
302 |
-
file_path = os.path.join(root, file_name)
|
303 |
-
#print(file_path)
|
304 |
-
|
305 |
-
# Ensure it's a Python file
|
306 |
-
if file_name.endswith(".py"):
|
307 |
-
python_file_count += 1 # Increment the counter
|
308 |
-
with open(file_path, "r", encoding="utf-8") as file:
|
309 |
-
source_code = file.read()
|
310 |
-
print(file_name)
|
311 |
-
|
312 |
-
# Call your function
|
313 |
-
docs = chunkPythonFiles(source_code, file_path)
|
314 |
-
|
315 |
-
print("HWHWHWWHWHWHWH!:" ,len(docs))
|
316 |
-
docsT.extend(docs)
|
317 |
-
# Print the total number of Python files processed
|
318 |
-
print(f"Total Python files processed: {python_file_count}")
|
319 |
-
print(f"Total docs files processed: {len(docsT)}")
|
320 |
-
|
|
|
278 |
"imports": function_imports
|
279 |
}
|
280 |
)
|
281 |
+
documents.append(doc)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|