# Path: charset_normalizer/api.py
# def from_path(
#     path: PathLike,
#     steps: int = 5,
#     chunk_size: int = 512,
#     threshold: float = 0.20,
#     cp_isolation: List[str] = None,
#     cp_exclusion: List[str] = None,
#     preemptive_behaviour: bool = True,
#     explain: bool = False,
# ) -> CharsetMatches:
#     """
#     Same thing than the function from_bytes but with one extra step. Opening and reading given file path in binary mode.
#     Can raise IOError.
#     """
#     with open(path, "rb") as fp:
#         return from_fp(
#             fp,
#             steps,
#             chunk_size,
#             threshold,
#             cp_isolation,
#             cp_exclusion,
#             preemptive_behaviour,
#             explain,
#         )


from charset_normalizer.api import from_path
import pytest


@pytest.mark.parametrize(
    "input_data_file, expected_charset, expected_language",
    [
        ('sample-arabic-1.txt', 'cp1256', 'Arabic'),
        ('sample-french-1.txt', 'cp1252', 'French'),
        ('sample-arabic.txt', 'utf_8', 'Arabic'),
        ('sample-russian-3.txt', 'utf_8', 'Russian'),
        ('sample-french.txt', 'utf_8', 'French'),
        ('sample-chinese.txt', 'big5', 'Classical Chinese'),
        ('sample-greek.txt', 'cp1253', 'Greek'),
        ('sample-greek-2.txt', 'cp1253', 'Greek'),
        ('sample-hebrew-2.txt', 'cp1255', 'Hebrew'),
        ('sample-hebrew-3.txt', 'cp1255', 'Hebrew'),
        ('sample-bulgarian.txt', 'utf_8', 'Bulgarian'),
        ('sample-english.bom.txt', 'utf_8', 'English'),
        ('sample-spanish.txt', 'utf_8', 'Spanish'),
        ('sample-korean.txt', 'cp949', 'Korean'),
        ('sample-turkish.txt', 'cp1254', 'Turkish'),
        ('sample-russian-2.txt', 'utf_8', 'Russian'),
        ('sample-russian.txt', 'mac_cyrillic', 'Russian'),
    ]
)
def test_elementary_detection(
    input_data_file: str,
    expected_charset: str,
    expected_language: str,
):

# Path: charset_normalizer/api.py
# def from_path(
#     path: PathLike,
#     steps: int = 5,
#     chunk_size: int = 512,
#     threshold: float = 0.20,
#     cp_isolation: List[str] = None,
#     cp_exclusion: List[str] = None,
#     preemptive_behaviour: bool = True,
#     explain: bool = False,
# ) -> CharsetMatches:
#     """
#     Same thing than the function from_bytes but with one extra step. Opening and reading given file path in binary mode.
#     Can raise IOError.
#     """
#     with open(path, "rb") as fp:
#         return from_fp(
#             fp,
#             steps,
#             chunk_size,
#             threshold,
#             cp_isolation,
#             cp_exclusion,
#             preemptive_behaviour,
#             explain,
#         )


# Path: tests/test_full_detection.py
from charset_normalizer.api import from_path
import pytest



@pytest.mark.parametrize(
    "input_data_file, expected_charset, expected_language",
    [
        ('sample-arabic-1.txt', 'cp1256', 'Arabic'),
        ('sample-french-1.txt', 'cp1252', 'French'),
        ('sample-arabic.txt', 'utf_8', 'Arabic'),
        ('sample-russian-3.txt', 'utf_8', 'Russian'),
        ('sample-french.txt', 'utf_8', 'French'),
        ('sample-chinese.txt', 'big5', 'Classical Chinese'),
        ('sample-greek.txt', 'cp1253', 'Greek'),
        ('sample-greek-2.txt', 'cp1253', 'Greek'),
        ('sample-hebrew-2.txt', 'cp1255', 'Hebrew'),
        ('sample-hebrew-3.txt', 'cp1255', 'Hebrew'),
        ('sample-bulgarian.txt', 'utf_8', 'Bulgarian'),
        ('sample-english.bom.txt', 'utf_8', 'English'),
        ('sample-spanish.txt', 'utf_8', 'Spanish'),
        ('sample-korean.txt', 'cp949', 'Korean'),
        ('sample-turkish.txt', 'cp1254', 'Turkish'),
        ('sample-russian-2.txt', 'utf_8', 'Russian'),
        ('sample-russian.txt', 'mac_cyrillic', 'Russian'),
    ]
)
def test_elementary_detection(
    input_data_file: str,
    expected_charset: str,
    expected_language: str,
):

    best_guess = from_path("./data/{}".format(input_data_file)).best()