File size: 1,182 Bytes
5ecde30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
import ast

def get_imports(file_path):
    with open(file_path, 'r') as file:
        tree = ast.parse(file.read(), filename=file_path)
    
    imports = []
    for node in ast.walk(tree):
        if isinstance(node, ast.Import):
            for alias in node.names:
                imports.append(alias.name)
        elif isinstance(node, ast.ImportFrom):
            imports.append(node.module)
    
    return imports

def enumerate_imports(file_path, base_dir):
    imports = get_imports(file_path)
    all_imports = {file_path: imports}
    
    for imp in imports:
        imp_path = os.path.join(base_dir, imp.replace('.', '/') + '.py')
        if os.path.exists(imp_path):
            all_imports.update(enumerate_imports(imp_path, base_dir))
    
    return all_imports

# Path to the LLModels.py file
base_dir = 'C:\\Users\\serban.tica\\Documents\\tobi_llm_intent_recognition'
llmodels_path = os.path.join(base_dir, 'LLModels.py')

# Enumerate all imports
all_imports = enumerate_imports(llmodels_path, base_dir)

# Print the results
for file, imports in all_imports.items():
    print(f"File: {file}")
    for imp in imports:
        print(f"  Import: {imp}")