Spaces:
Running
Running
File size: 760 Bytes
5301c48 |
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 |
import os
class BaseParser:
def __init__(self):
"""Initialize the base parser."""
pass
def parse(self, file_path: str) -> str:
raise NotImplementedError("Subclasses must implement parse method")
async def parse_async(self, file_path: str) -> str:
"""Asynchronously parse the file content.
Args:
file_path: Path to the file to parse
Returns:
str: Parsed content
"""
raise NotImplementedError("Subclasses must implement parse_async method")
def save(self, content: str, output_path: str) -> None:
os.makedirs(os.path.dirname(output_path), exist_ok=True)
with open(output_path, "w", encoding="utf-8") as f:
f.write(content)
|