MCPcopy Create free account
hub / github.com/GitsSaikat/PyGen / load_package_files

Function load_package_files

pygen/code_reviewer.py:5–28  ·  view source on GitHub ↗

Recursively load all relevant files in the package directory into a dictionary. Args: package_dir (str): Path to the root of the Python package. Returns: Dict[str, str]: A dictionary mapping relative file paths to their contents.

(package_dir: str)

Source from the content-addressed store, hash-verified

3from groq import Groq
4
5def load_package_files(package_dir: str) -> Dict[str, str]:
6 """
7 Recursively load all relevant files in the package directory into a dictionary.
8
9 Args:
10 package_dir (str): Path to the root of the Python package.
11
12 Returns:
13 Dict[str, str]: A dictionary mapping relative file paths to their contents.
14 """
15 package_files = {}
16 for root, _, files in os.walk(package_dir):
17 for file in files:
18 if file.endswith(('.py', '.md', '.txt')):
19 file_path = os.path.join(root, file)
20 try:
21 with open(file_path, 'r', encoding='utf-8') as f:
22 content = f.read()
23 # Store relative paths for better context
24 relative_path = os.path.relpath(file_path, package_dir)
25 package_files[relative_path] = content
26 except Exception as e:
27 print(f"Error reading {file_path}: {e}")
28 return package_files
29
30def generate_review_with_groq(client: Groq, model_name: str, package_files: Dict[str, str], package_name: str) -> str:
31 """

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected