Load a BCF file. Args: filepath: The path to the BCF file. Returns: The loaded BCF file. Raises: ValueError: If the BCF version is not supported.
(filepath: Path, xml_handler: Optional[AbstractXmlParserSerializer] = None)
| 33 | |
| 34 | |
| 35 | def load(filepath: Path, xml_handler: Optional[AbstractXmlParserSerializer] = None) -> Optional[BcfXml]: |
| 36 | """ |
| 37 | Load a BCF file. |
| 38 | |
| 39 | Args: |
| 40 | filepath: The path to the BCF file. |
| 41 | |
| 42 | Returns: |
| 43 | The loaded BCF file. |
| 44 | |
| 45 | Raises: |
| 46 | ValueError: If the BCF version is not supported. |
| 47 | """ |
| 48 | xml_handler = xml_handler or XmlParserSerializer() |
| 49 | version_id = _get_version(filepath, xml_handler) |
| 50 | if version_id in {"2.1", "2.0"}: |
| 51 | return BcfXml2.load(filepath, xml_handler) |
| 52 | if version_id == "3.0": |
| 53 | return BcfXml3.load(filepath, xml_handler) |
| 54 | raise ValueError(f"Version {version_id} not supported.") |
| 55 | |
| 56 | |
| 57 | def _get_version(filepath: Union[str, Path], xml_handler: Optional[AbstractXmlParserSerializer] = None) -> str: |
no test coverage detected