






"""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,
)


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

_UpperCamelCase       :					List[str]									=		'file'




@pytest.fixture(scope='session'   )
def     snake_case						(A_   :List[str]   ):







  '''simple docstring'''

  a  :    List[Any]       =     tmp_path_factory.mktemp('data'   ) / (FILE_PATH + '.zstd')
  a  :    Dict       =     bytes(A_			,    'utf-8'   )
  with zstd.open(A_			,    'wb'   ) as f:
    f.write(A_   )
  return path




@pytest.fixture
def     snake_case						(A_   :List[str]   ):







  '''simple docstring'''

  with open(os.path.join(tmpfs.local_root_dir			,    A_   )			,    'w'   ) as f:
    f.write(A_   )
  return FILE_PATH




@pytest.mark.parametrize('compression_format'			,    ['gzip', 'xz', 'zstd']   )
def     snake_case						(A_   :List[Any]			,    A_   :List[str]			,    A_   :List[Any]			,    A_   :List[str]			,    A_   :str			,    A_   :Union[str, Any]   ):







  '''simple docstring'''

  a  :    int       =     {'gzip': gz_file, 'xz': xz_file, 'zstd': zstd_path}
  a  :    Union[str, Any]       =     input_paths[compression_format]
  a  :    Optional[Any]       =     tmp_path / 'cache'
  a  :    Union[str, Any]       =     DownloadConfig(cache_dir=A_			,    extract_compressed_file=A_   )
  a  :    Tuple       =     cached_path(A_			,    download_config=A_   )
  with open(A_   ) as f:
    a  :    Optional[int]       =     f.read()
  with open(A_   ) as f:
    a  :    List[str]       =     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     snake_case						(A_   :Tuple			,    A_   :List[Any]			,    A_   :Optional[int]			,    A_   :Tuple			,    A_   :Dict   ):







  '''simple docstring'''

  a  :    List[Any]       =     'custom_cache'
  a  :    Tuple       =     'custom_extracted_dir'
  a  :    Tuple       =     tmp_path / 'custom_extracted_path'
  if default_extracted:
    a  :    Any       =     ('downloads' if default_cache_dir else custom_cache_dir, 'extracted')
  else:
    monkeypatch.setattr('datasets.config.EXTRACTED_DATASETS_DIR'			,    A_   )
    monkeypatch.setattr('datasets.config.EXTRACTED_DATASETS_PATH'			,    str(A_   )   )
    a  :    Tuple       =     custom_extracted_path.parts[-2:] if default_cache_dir else (custom_cache_dir, custom_extracted_dir)

  a  :    Optional[int]       =     xz_file
  a  :    Tuple       =     (
      DownloadConfig(extract_compressed_file=A_   )
      if default_cache_dir
      else DownloadConfig(cache_dir=tmp_path / custom_cache_dir			,    extract_compressed_file=A_   )
  )
  a  :    Any       =     cached_path(A_			,    download_config=A_   )
  assert Path(A_   ).parent.parts[-2:] == expected




def     snake_case						(A_   :str   ):







  '''simple docstring'''

  a  :    List[Any]       =     str(Path(A_   ).resolve()   )
  assert cached_path(A_   ) == text_file
  # relative path
  a  :    Dict       =     str(Path(A_   ).resolve().relative_to(Path(os.getcwd()   )   )   )
  assert cached_path(A_   ) == text_file




def     snake_case						(A_   :int   ):







  '''simple docstring'''

  a  :    str       =     str(tmp_path.resolve() / '__missing_file__.txt'   )
  with pytest.raises(A_   ):
    cached_path(A_   )
  # relative path
  a  :    Any       =     './__missing_file__.txt'
  with pytest.raises(A_   ):
    cached_path(A_   )




def     snake_case						(A_   :Dict   ):







  '''simple docstring'''

  a  :    Any       =     get_from_cache(f'''tmp://{tmpfs_file}'''   )
  with open(A_   ) as f:
    a  :    Optional[Any]       =     f.read()
  assert output_file_content == FILE_CONTENT




@patch('datasets.config.HF_DATASETS_OFFLINE'			,    A_   )
def     snake_case						():







  '''simple docstring'''

  with pytest.raises(A_   ):
    cached_path('https://huggingface.co'   )




@patch('datasets.config.HF_DATASETS_OFFLINE'			,    A_   )
def     snake_case						(A_   :List[Any]   ):







  '''simple docstring'''

  a  :    List[Any]       =     tmp_path_factory.mktemp('data'   ) / 'file.html'
  with pytest.raises(A_   ):
    http_get('https://huggingface.co'			,    temp_file=A_   )
  with pytest.raises(A_   ):
    http_head('https://huggingface.co'   )




@patch('datasets.config.HF_DATASETS_OFFLINE'			,    A_   )
def     snake_case						(A_   :str   ):







  '''simple docstring'''

  a  :    Optional[int]       =     tmp_path_factory.mktemp('data'   ) / 'file.html'
  with pytest.raises(A_   ):
    ftp_get('ftp://huggingface.co'			,    temp_file=A_   )
  with pytest.raises(A_   ):
    ftp_head('ftp://huggingface.co'   )






@patch('datasets.config.HF_DATASETS_OFFLINE'			,    A_   )
def     snake_case						(A_   :Dict   ):







  '''simple docstring'''

  a  :    str       =     tmp_path_factory.mktemp('data'   ) / 'file.html'
  with pytest.raises(A_   ):
    fsspec_get('s3://huggingface.co'			,    temp_file=A_   )
  with pytest.raises(A_   ):
    fsspec_head('s3://huggingface.co'   )












"""simple docstring"""


def     snake_case						(A_   :int			,    A_   :int   ):







  '''simple docstring'''

  return base * power(A_			,    (exponent - 1)   ) if exponent else 1


if __name__ == "__main__":
   print('Raise base to the power of exponent using recursion...')
   _UpperCamelCase       :					Any									=		int(input('Enter the base: ').strip())
   _UpperCamelCase       :					str									=		int(input('Enter the exponent: ').strip())
   _UpperCamelCase       :					int									=		power(base, abs(exponent))
   if exponent < 0:  # power() does not properly deal w/ negative exponents
      _UpperCamelCase       :					Union[str, Any]									=		1 / result
   print(f'''{base} to the power of {exponent} is {result}''')




