feat: Add argparse for testing purposes
This commit is contained in:
parent
4bf2281cd5
commit
3aadda9a89
1 changed files with 20 additions and 9 deletions
|
|
@ -1,14 +1,15 @@
|
||||||
from contextlib import contextmanager
|
import argparse
|
||||||
from typing import List, Dict, Optional
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import sys
|
||||||
|
from contextlib import contextmanager
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import List, Dict, Optional
|
||||||
|
|
||||||
import aiofiles
|
import aiofiles
|
||||||
import jedi
|
import jedi
|
||||||
import parso
|
import parso
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
|
||||||
from parso.tree import BaseNode
|
from parso.tree import BaseNode
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def add_sys_path(path):
|
def add_sys_path(path):
|
||||||
original_sys_path = sys.path.copy()
|
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)
|
dependencies = await _extract_dependencies(script_path)
|
||||||
return dependencies
|
return dependencies
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Simple execution example, use absolute paths
|
parser = argparse.ArgumentParser(description="Get local script dependencies.")
|
||||||
script_path = ".../cognee/examples/python/simple_example.py"
|
|
||||||
repo_path = ".../cognee"
|
# 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))
|
dependencies = asyncio.run(get_local_script_dependencies(script_path, repo_path))
|
||||||
|
|
||||||
print("Dependencies:")
|
print("Dependencies:")
|
||||||
for dependency in dependencies:
|
for dependency in dependencies:
|
||||||
print(dependency)
|
print(dependency)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue