|
1 | 1 | from ..core.models import CodeBase, CodeFileModel, ImportStatement |
2 | 2 | from ..parsers.base_parser import BaseParser |
| 3 | +from ..core.common import readFile |
3 | 4 |
|
4 | 5 | from concurrent.futures import ThreadPoolExecutor |
5 | 6 | from typing import List, Optional, Union |
@@ -45,17 +46,18 @@ async def parse_file(self, file_path: Union[str, Path], root_path: Optional[Unio |
45 | 46 | # Use aiofiles or run synchronous file IO in executor |
46 | 47 | loop = asyncio.get_running_loop() |
47 | 48 | with ThreadPoolExecutor() as pool: |
48 | | - |
| 49 | + code = await loop.run_in_executor(pool, readFile, file_path, "rb") |
49 | 50 | if root_path is not None: |
50 | 51 | file_path = file_path.relative_to(Path(root_path)) |
51 | 52 |
|
52 | | - codeFile = await loop.run_in_executor(pool, self.parse_code, file_path) |
| 53 | + codeFile = await loop.run_in_executor(pool, self.parse_code, file_path, code) |
53 | 54 |
|
54 | 55 | return codeFile |
55 | 56 |
|
56 | | - def parse_code(self, file_path :Path): |
| 57 | + def parse_code(self, file_path :Path, code :str): |
57 | 58 | codeFile = CodeFileModel( |
58 | | - file_path=str(file_path) |
| 59 | + file_path=str(file_path), |
| 60 | + raw=code |
59 | 61 | ) |
60 | 62 | return codeFile |
61 | 63 |
|
|
0 commit comments