Files
altium-render-engine/backend/app/documents.py
T
2026-11-09 12:34:50 +03:30

17 خطوط
786 B
Python

"""Document parser boundary. Future PCB support adds an adapter, not SchDoc branches."""
from typing import Protocol
from .models.schematic import Document
from .parser.schdoc_parser import parse_schdoc
from .parser.pcb_parser import parse_pcbdoc
from .parser.record_decoder import ParseError
class DocumentParser(Protocol):
def __call__(self, data: bytes, filename: str, identifier: str, **options) -> Document: ...
PARSERS: dict[str, DocumentParser] = {'schematic': parse_schdoc, 'pcb': parse_pcbdoc}
def parse_document(data: bytes, filename: str, identifier: str, document_type='schematic', **options) -> Document:
parser=PARSERS.get(document_type)
if parser is None: raise ParseError('Unsupported document type')
return parser(data,filename,identifier,**options)