27 lines
608 B
Python
27 lines
608 B
Python
from __future__ import annotations
|
|
|
|
from typing import Iterable
|
|
|
|
from .base import CSVParserBase
|
|
from .idemitsu import IdemitsuParser
|
|
|
|
|
|
PARSERS: list[CSVParserBase] = [
|
|
IdemitsuParser(),
|
|
]
|
|
|
|
|
|
def detect_parser(lines: Iterable[str]) -> CSVParserBase | None:
|
|
for line in lines:
|
|
for parser in PARSERS:
|
|
if parser.detect(line):
|
|
return parser
|
|
return None
|
|
|
|
|
|
def get_parser(lines: Iterable[str]) -> CSVParserBase:
|
|
parser = detect_parser(lines)
|
|
if parser is None:
|
|
raise ValueError('CSVブランドを判定できませんでした。')
|
|
return parser
|