@@ -0,0 +1,15 @@
|
||||
"""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.record_decoder import ParseError
|
||||
|
||||
class DocumentParser(Protocol):
|
||||
def __call__(self, data: bytes, filename: str, identifier: str) -> Document: ...
|
||||
|
||||
PARSERS: dict[str, DocumentParser] = {'schematic': parse_schdoc}
|
||||
|
||||
def parse_document(data: bytes, filename: str, identifier: str, document_type='schematic') -> Document:
|
||||
parser=PARSERS.get(document_type)
|
||||
if parser is None: raise ParseError('Unsupported document type')
|
||||
return parser(data,filename,identifier)
|
||||
مرجع در شماره جدید
مسدود کردن کاربر