


"""simple docstring"""
import os
from pathlib import Path
from unittest.mock import patch

import pytest
import zstandard as zstd

from datasets.download.download_config import DownloadConfig
from datasets.utils.file_utils import (
    OfflineModeIsEnabled,
    cached_path,
    fsspec_get,
    fsspec_head,
    ftp_get,
    ftp_head,
    get_from_cache,
    http_get,
    http_head,
)


__SCREAMING_SNAKE_CASE							:    Optional[Any]		=    '\\n    Text data.\n    Second line of data.'

__SCREAMING_SNAKE_CASE							:    List[str]		=    'file'







@pytest.fixture(scope="""session"""				)
def 						_a				(      _SCREAMING_SNAKE_CASE				)    ->				List[str]:
							snake_case_           =		tmp_path_factory.mktemp("""data"""				) / (FILE_PATH + """.zstd""")
							snake_case_           =		bytes(_SCREAMING_SNAKE_CASE				, """utf-8"""				)
							with zstd.open(_SCREAMING_SNAKE_CASE				, """wb"""				) as f:
														f.write(_SCREAMING_SNAKE_CASE				)
							return path







@pytest.fixture
def 						_a				(      _SCREAMING_SNAKE_CASE				)    ->				Union[str, Any]:
							with open(os.path.join(tmpfs.local_root_dir				, _SCREAMING_SNAKE_CASE				)				, """w"""				) as f:
														f.write(_SCREAMING_SNAKE_CASE				)
							return FILE_PATH







@pytest.mark.parametrize("""compression_format"""				, ["""gzip""", """xz""", """zstd"""]				)
def 						_a				(      _SCREAMING_SNAKE_CASE				, _SCREAMING_SNAKE_CASE				, _SCREAMING_SNAKE_CASE				, _SCREAMING_SNAKE_CASE				, _SCREAMING_SNAKE_CASE				, _SCREAMING_SNAKE_CASE				)    ->				Optional[int]:
							snake_case_           =		{"""gzip""": gz_file, """xz""": xz_file, """zstd""": zstd_path}
							snake_case_           =		input_paths[compression_format]
							snake_case_           =		tmp_path / """cache"""
							snake_case_           =		DownloadConfig(cache_dir=_SCREAMING_SNAKE_CASE				, extract_compressed_file=_SCREAMING_SNAKE_CASE				)
							snake_case_           =		cached_path(_SCREAMING_SNAKE_CASE				, download_config=_SCREAMING_SNAKE_CASE				)
							with open(_SCREAMING_SNAKE_CASE				) as f:
														snake_case_           =		f.read()
							with open(_SCREAMING_SNAKE_CASE				) as f:
														snake_case_           =		f.read()
							assert extracted_file_content == expected_file_content







@pytest.mark.parametrize("""default_extracted"""				, [True, False]				)
@pytest.mark.parametrize("""default_cache_dir"""				, [True, False]				)
def 						_a				(      _SCREAMING_SNAKE_CASE				, _SCREAMING_SNAKE_CASE				, _SCREAMING_SNAKE_CASE				, _SCREAMING_SNAKE_CASE				, _SCREAMING_SNAKE_CASE				)    ->				int:
							snake_case_           =		"""custom_cache"""
							snake_case_           =		"""custom_extracted_dir"""
							snake_case_           =		tmp_path / """custom_extracted_path"""
							if default_extracted:
														snake_case_           =		("""downloads""" if default_cache_dir else custom_cache_dir, """extracted""")
							else:
														monkeypatch.setattr("""datasets.config.EXTRACTED_DATASETS_DIR"""				, _SCREAMING_SNAKE_CASE				)
														monkeypatch.setattr("""datasets.config.EXTRACTED_DATASETS_PATH"""				, str(_SCREAMING_SNAKE_CASE				)				)
														snake_case_           =		custom_extracted_path.parts[-2:] if default_cache_dir else (custom_cache_dir, custom_extracted_dir)

							snake_case_           =		xz_file
							snake_case_           =		(
							    DownloadConfig(extract_compressed_file=_SCREAMING_SNAKE_CASE				)
							    if default_cache_dir
							    else DownloadConfig(cache_dir=tmp_path / custom_cache_dir				, extract_compressed_file=_SCREAMING_SNAKE_CASE				)
							)
							snake_case_           =		cached_path(_SCREAMING_SNAKE_CASE				, download_config=_SCREAMING_SNAKE_CASE				)
							assert Path(_SCREAMING_SNAKE_CASE				).parent.parts[-2:] == expected







def 						_a				(      _SCREAMING_SNAKE_CASE				)    ->				Any:
							# absolute path
							snake_case_           =		str(Path(_SCREAMING_SNAKE_CASE				).resolve()				)
							assert cached_path(_SCREAMING_SNAKE_CASE				) == text_file
							# relative path
							snake_case_           =		str(Path(_SCREAMING_SNAKE_CASE				).resolve().relative_to(Path(os.getcwd()				)				)				)
							assert cached_path(_SCREAMING_SNAKE_CASE				) == text_file







def 						_a				(      _SCREAMING_SNAKE_CASE				)    ->				List[str]:
							# absolute path
							snake_case_           =		str(tmp_path.resolve() / """__missing_file__.txt"""				)
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														cached_path(_SCREAMING_SNAKE_CASE				)
							# relative path
							snake_case_           =		"""./__missing_file__.txt"""
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														cached_path(_SCREAMING_SNAKE_CASE				)







def 						_a				(      _SCREAMING_SNAKE_CASE				)    ->				str:
							snake_case_           =		get_from_cache(f"""tmp://{tmpfs_file}"""				)
							with open(_SCREAMING_SNAKE_CASE				) as f:
														snake_case_           =		f.read()
							assert output_file_content == FILE_CONTENT







@patch("""datasets.config.HF_DATASETS_OFFLINE"""				, _SCREAMING_SNAKE_CASE				)
def 						_a				(      )    ->				Tuple:
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														cached_path("""https://huggingface.co"""				)







@patch("""datasets.config.HF_DATASETS_OFFLINE"""				, _SCREAMING_SNAKE_CASE				)
def 						_a				(      _SCREAMING_SNAKE_CASE				)    ->				Dict:
							snake_case_           =		tmp_path_factory.mktemp("""data"""				) / """file.html"""
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														http_get("""https://huggingface.co"""				, temp_file=_SCREAMING_SNAKE_CASE				)
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														http_head("""https://huggingface.co"""				)







@patch("""datasets.config.HF_DATASETS_OFFLINE"""				, _SCREAMING_SNAKE_CASE				)
def 						_a				(      _SCREAMING_SNAKE_CASE				)    ->				Dict:
							snake_case_           =		tmp_path_factory.mktemp("""data"""				) / """file.html"""
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														ftp_get("""ftp://huggingface.co"""				, temp_file=_SCREAMING_SNAKE_CASE				)
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														ftp_head("""ftp://huggingface.co"""				)







@patch("""datasets.config.HF_DATASETS_OFFLINE"""				, _SCREAMING_SNAKE_CASE				)
def 						_a				(      _SCREAMING_SNAKE_CASE				)    ->				Tuple:
							snake_case_           =		tmp_path_factory.mktemp("""data"""				) / """file.html"""
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														fsspec_get("""s3://huggingface.co"""				, temp_file=_SCREAMING_SNAKE_CASE				)
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														fsspec_head("""s3://huggingface.co"""				)







"""simple docstring"""
from functools import reduce

__SCREAMING_SNAKE_CASE							:    Tuple		=    (
    '73167176531330624919225119674426574742355349194934'
    '96983520312774506326239578318016984801869478851843'
    '85861560789112949495459501737958331952853208805511'
    '12540698747158523863050715693290963295227443043557'
    '66896648950445244523161731856403098711121722383113'
    '62229893423380308135336276614282806444486645238749'
    '30358907296290491560440772390713810515859307960866'
    '70172427121883998797908792274921901699720888093776'
    '65727333001053367881220235421809751254540594752243'
    '52584907711670556013604839586446706324415722155397'
    '53697817977846174064955149290862569321978468622482'
    '83972241375657056057490261407972968652414535100474'
    '82166370484403199890008895243450658541227588666881'
    '16427171479924442928230863465674813919123162824586'
    '17866458359124566529476545682848912883142607690042'
    '24219022671055626321111109370544217506941658960408'
    '07198403850962455444362981230987879927244284909188'
    '84580156166097919133875499200524063689912560717606'
    '05886116467109405077541002256983155200055935729725'
    '71636269561882670428252483600823257530420752963450'
)







def 						_a				(      _SCREAMING_SNAKE_CASE = N				)    ->				int:
							return max(
							    # mypy cannot properly interpret reduce
							    int(reduce(lambda _SCREAMING_SNAKE_CASE				, _SCREAMING_SNAKE_CASE				: str(int(_SCREAMING_SNAKE_CASE				) * int(_SCREAMING_SNAKE_CASE				)				)				, n[i : i + 13]				)				)
							    for i in range(len(_SCREAMING_SNAKE_CASE				) - 12				)				)


if __name__ == "__main__":
				print(f"""{solution() = }""")



