From 3aadda9a890e9249acd70a4224db03d45bcbc179 Mon Sep 17 00:00:00 2001 From: lxobr Date: Mon, 18 Nov 2024 10:05:38 +0100 Subject: [PATCH] feat: Add argparse for testing purposes --- .../local_script_dependencies.py | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/cognee/tasks/repo_processor/local_script_dependencies.py b/cognee/tasks/repo_processor/local_script_dependencies.py index 17120a32a..47839f8cf 100644 --- a/cognee/tasks/repo_processor/local_script_dependencies.py +++ b/cognee/tasks/repo_processor/local_script_dependencies.py @@ -1,14 +1,15 @@ -from contextlib import contextmanager -from typing import List, Dict, Optional +import argparse import asyncio +import sys +from contextlib import contextmanager +from pathlib import Path +from typing import List, Dict, Optional + import aiofiles import jedi import parso -import sys -from pathlib import Path from parso.tree import BaseNode - @contextmanager def add_sys_path(path): original_sys_path = sys.path.copy() @@ -91,13 +92,23 @@ async def get_local_script_dependencies(script_path: str, repo_path: Optional[st dependencies = await _extract_dependencies(script_path) return dependencies + if __name__ == "__main__": - # Simple execution example, use absolute paths - script_path = ".../cognee/examples/python/simple_example.py" - repo_path = ".../cognee" + parser = argparse.ArgumentParser(description="Get local script dependencies.") + + # Suggested path: .../cognee/examples/python/simple_example.py + parser.add_argument("script_path", type=str, help="Absolute path to the Python script file") + + # Suggested path: .../cognee + parser.add_argument("repo_path", type=str, help="Absolute path to the repository root") + + args = parser.parse_args() + + script_path = args.script_path + repo_path = args.repo_path dependencies = asyncio.run(get_local_script_dependencies(script_path, repo_path)) print("Dependencies:") for dependency in dependencies: - print(dependency) \ No newline at end of file + print(dependency)