






"""simple docstring"""



import json
import os
from pathlib import Path

import pytest

from datasets.download.download_config import DownloadConfig
from datasets.download.download_manager import DownloadManager
from datasets.utils.file_utils import hash_url_to_filename


_UpperCamelCase		:  List[Any]						=		'http://www.mocksite.com/file1.txt'
_UpperCamelCase		:  Optional[int]						=		'"text": ["foo", "foo"]'
_UpperCamelCase		:  Tuple						=		'6d8ce9aa78a471c7477201efbeabd3bb01ac2e7d100a6dc024ba1608361f90a8'

class        a     :
    UpperCAmelCase_ :     Optional[Any]	     =200
    UpperCAmelCase_ :     str	     ={"Content-Length": "100"}
    UpperCAmelCase_ :     Any	     ={}







    def 			UpperCamelCase_      (			self							,		**_lowerCamelCase       ):
      return [bytes(_lowerCamelCase							,		'utf-8'       )]


def 						_SCREAMING_SNAKE_CASE (    *__snake_case			:  List[Any]		,					**__snake_case			:  List[str]    ):





  '''simple docstring'''





  return MockResponse()
@pytest.mark.parametrize('urls_type'		,					[str, list, dict]    )
def 						_SCREAMING_SNAKE_CASE (    __snake_case			:  Optional[Any]		,					__snake_case			:  Union[str, Any]		,					__snake_case			:  Tuple    ):





  '''simple docstring'''





  import requests

  monkeypatch.setattr(__snake_case		,					'request'		,					__snake_case    )

  lowercase							    =       URL
  if issubclass(__snake_case		,					__snake_case    ):
    lowercase							    =       url
  elif issubclass(__snake_case		,					__snake_case    ):
    lowercase							    =       [url]
  elif issubclass(__snake_case		,					__snake_case    ):
    lowercase							    =       {'train': url}
  lowercase							    =       'dummy'
  lowercase							    =       'downloads'
  lowercase							    =       tmp_path
  lowercase							    =       DownloadConfig(
      cache_dir=os.path.join(__snake_case		,					__snake_case    )		,					use_etag=__snake_case		,					)
  lowercase							    =       DownloadManager(dataset_name=__snake_case		,					download_config=__snake_case    )
  lowercase							    =       dl_manager.download(__snake_case    )
  lowercase							    =       urls
  for downloaded_paths in [downloaded_paths]:
    if isinstance(__snake_case		,					__snake_case    ):
      lowercase							    =       [downloaded_paths]
      lowercase							    =       [urls]
    elif isinstance(__snake_case		,					__snake_case    ):
      assert "train" in downloaded_paths.keys()
      lowercase							    =       downloaded_paths.values()
      lowercase							    =       urls.values()
    assert downloaded_paths
    for downloaded_path, input_url in zip(__snake_case		,					__snake_case    ):
      assert downloaded_path == dl_manager.downloaded_paths[input_url]
      lowercase							    =       Path(__snake_case    )
      lowercase							    =       downloaded_path.parts
      assert parts[-1] == HASH
      assert parts[-2] == cache_subdir
      assert downloaded_path.exists()
      lowercase							    =       downloaded_path.read_text()
      assert content == CONTENT
      lowercase							    =       downloaded_path.with_suffix('.json'    )
      assert metadata_downloaded_path.exists()
      lowercase							    =       json.loads(metadata_downloaded_path.read_text()    )
      assert metadata_content == {"url": URL, "etag": None}
@pytest.mark.parametrize('paths_type'		,					[str, list, dict]    )
def 						_SCREAMING_SNAKE_CASE (    __snake_case			:  Any		,					__snake_case			:  Any		,					__snake_case			:  Dict    ):





  '''simple docstring'''





  lowercase							    =       str(__snake_case    )
  if issubclass(__snake_case		,					__snake_case    ):
    lowercase							    =       filename
  elif issubclass(__snake_case		,					__snake_case    ):
    lowercase							    =       [filename]
  elif issubclass(__snake_case		,					__snake_case    ):
    lowercase							    =       {'train': filename}
  lowercase							    =       'dummy'
  lowercase							    =       xz_file.parent
  lowercase							    =       'extracted'
  lowercase							    =       DownloadConfig(
      cache_dir=__snake_case		,					use_etag=__snake_case		,					)
  lowercase							    =       DownloadManager(dataset_name=__snake_case		,					download_config=__snake_case    )
  lowercase							    =       dl_manager.extract(__snake_case    )
  lowercase							    =       paths
  for extracted_paths in [extracted_paths]:
    if isinstance(__snake_case		,					__snake_case    ):
      lowercase							    =       [extracted_paths]
      lowercase							    =       [paths]
    elif isinstance(__snake_case		,					__snake_case    ):
      assert "train" in extracted_paths.keys()
      lowercase							    =       extracted_paths.values()
      lowercase							    =       paths.values()
    assert extracted_paths
    for extracted_path, input_path in zip(__snake_case		,					__snake_case    ):
      assert extracted_path == dl_manager.extracted_paths[input_path]
      lowercase							    =       Path(__snake_case    )
      lowercase							    =       extracted_path.parts
      assert parts[-1] == hash_url_to_filename(__snake_case		,					etag=__snake_case    )
      assert parts[-2] == extracted_subdir
      assert extracted_path.exists()
      lowercase							    =       extracted_path.read_text()
      lowercase							    =       text_file.read_text()
      assert extracted_file_content == expected_file_content
def 						_SCREAMING_SNAKE_CASE (    __snake_case			:  List[Any]		,					__snake_case			:  str    ):





  '''simple docstring'''





  assert path.endswith('.jsonl'    )
  for num_items, line in enumerate(__snake_case		,					start=1    ):
    lowercase							    =       json.loads(line.decode('utf-8'    )    )
    assert item.keys() == {"col_1", "col_2", "col_3"}
  assert num_items == 4
@pytest.mark.parametrize('archive_jsonl'		,					['tar_jsonl_path', 'zip_jsonl_path']    )
def 						_SCREAMING_SNAKE_CASE (    __snake_case			:  int		,					__snake_case			:  List[str]    ):





  '''simple docstring'''





  lowercase							    =       request.getfixturevalue(__snake_case    )
  lowercase							    =       DownloadManager()
  for num_jsonl, (path, file) in enumerate(dl_manager.iter_archive(__snake_case    )		,					start=1    ):
    _test_jsonl(__snake_case		,					__snake_case    )
  assert num_jsonl == 2
@pytest.mark.parametrize('archive_nested_jsonl'		,					['tar_nested_jsonl_path', 'zip_nested_jsonl_path']    )
def 						_SCREAMING_SNAKE_CASE (    __snake_case			:  Dict		,					__snake_case			:  Optional[int]    ):





  '''simple docstring'''





  lowercase							    =       request.getfixturevalue(__snake_case    )
  lowercase							    =       DownloadManager()
  for num_tar, (path, file) in enumerate(dl_manager.iter_archive(__snake_case    )		,					start=1    ):
    for num_jsonl, (subpath, subfile) in enumerate(dl_manager.iter_archive(__snake_case    )		,					start=1    ):
      _test_jsonl(__snake_case		,					__snake_case    )
  assert num_tar == 1
  assert num_jsonl == 2



def 						_SCREAMING_SNAKE_CASE (    __snake_case			:  Dict    ):





  '''simple docstring'''





  lowercase							    =       DownloadManager()
  for num_file, file in enumerate(dl_manager.iter_files(__snake_case    )		,					start=1    ):
    assert os.path.basename(__snake_case    ) == ("test.txt" if num_file == 1 else "train.txt")
  assert num_file == 2










"""simple docstring"""



def 						_SCREAMING_SNAKE_CASE (    __snake_case			:  int = 4_00_00_00    ):





  '''simple docstring'''





  lowercase							    =       []
  lowercase    ,     lowercase							    =       0, 1
  while b <= n:
    if b % 2 == 0:
      even_fibs.append(__snake_case    )
    lowercase    ,     lowercase							    =       b, a + b
  return sum(__snake_case    )


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


