
'''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


__lowerCAmelCase         =    """http://www.mocksite.com/file1.txt"""
__lowerCAmelCase         =    """\"text\": [\"foo\", \"foo\"]"""
__lowerCAmelCase         =    """6d8ce9aa78a471c7477201efbeabd3bb01ac2e7d100a6dc024ba1608361f90a8"""







class UpperCAmelCase__	:





  """simple docstring"""

  __UpperCAmelCase				:				Optional[Any]   =					200
  __UpperCAmelCase				:				Optional[int]   =					{'''Content-Length''': '''100'''}
  __UpperCAmelCase				:				Tuple   =					{}


  def   __lowercase		(		self      :     List[str]							,**_a      :     Tuple       ):


     '''simple docstring'''






     return [bytes(_a							,'utf-8'       )]





def 					UpperCAmelCase_		(*__a      :    Optional[Any] ,	**__a      :    Any ):






   """simple docstring"""

   return MockResponse()





@pytest.mark.parametrize('urls_type' ,	[str, list, dict] )
def 					UpperCAmelCase_		(__a      :    Optional[Any] ,	__a      :    Tuple ,	__a      :    Any ):






   """simple docstring"""

   import requests

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

   _a				:	List[str]			=   URL
   if issubclass(__a ,	__a ):
      _a				:	Optional[Any]			=   url
   elif issubclass(__a ,	__a ):
      _a				:	Optional[int]			=   [url]
   elif issubclass(__a ,	__a ):
      _a				:	List[str]			=   {'train': url}
   _a				:	Optional[int]			=   'dummy'
   _a				:	Optional[int]			=   'downloads'
   _a				:	Dict			=   tmp_path
   _a				:	Tuple			=   DownloadConfig(
       cache_dir=os.path.join(__a ,	__a ) ,	use_etag=__a ,	)
   _a				:	List[Any]			=   DownloadManager(dataset_name=__a ,	download_config=__a )
   _a				:	Tuple			=   dl_manager.download(__a )
   _a				:	int			=   urls
   for downloaded_paths in [downloaded_paths]:
      if isinstance(__a ,	__a ):
         _a				:	Dict			=   [downloaded_paths]
         _a				:	Tuple			=   [urls]
      elif isinstance(__a ,	__a ):
         assert "train" in downloaded_paths.keys()
         _a				:	Optional[int]			=   downloaded_paths.values()
         _a				:	Any			=   urls.values()
      assert downloaded_paths
      for downloaded_path, input_url in zip(__a ,	__a ):
         assert downloaded_path == dl_manager.downloaded_paths[input_url]
         _a				:	List[str]			=   Path(__a )
         _a				:	Dict			=   downloaded_path.parts
         assert parts[-1] == HASH
         assert parts[-2] == cache_subdir
         assert downloaded_path.exists()
         _a				:	Tuple			=   downloaded_path.read_text()
         assert content == CONTENT
         _a				:	List[str]			=   downloaded_path.with_suffix('.json' )
         assert metadata_downloaded_path.exists()
         _a				:	str			=   json.loads(metadata_downloaded_path.read_text() )
         assert metadata_content == {"url": URL, "etag": None}





@pytest.mark.parametrize('paths_type' ,	[str, list, dict] )
def 					UpperCAmelCase_		(__a      :    Optional[Any] ,	__a      :    List[Any] ,	__a      :    Any ):






   """simple docstring"""

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





def 					UpperCAmelCase_		(__a      :    List[str] ,	__a      :    Dict ):






   """simple docstring"""

   assert path.endswith('.jsonl' )
   for num_items, line in enumerate(__a ,	start=1 ):
      _a				:	str			=   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 					UpperCAmelCase_		(__a      :    Optional[Any] ,	__a      :    List[str] ):






   """simple docstring"""

   _a				:	Dict			=   request.getfixturevalue(__a )
   _a				:	Optional[int]			=   DownloadManager()
   for num_jsonl, (path, file) in enumerate(dl_manager.iter_archive(__a ) ,	start=1 ):
      _test_jsonl(__a ,	__a )
   assert num_jsonl == 2





@pytest.mark.parametrize('archive_nested_jsonl' ,	['tar_nested_jsonl_path', 'zip_nested_jsonl_path'] )
def 					UpperCAmelCase_		(__a      :    Optional[Any] ,	__a      :    int ):






   """simple docstring"""

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





def 					UpperCAmelCase_		(__a      :    Union[str, Any] ):






   """simple docstring"""

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





'''simple docstring'''







import warnings

from ...utils import logging
from .image_processing_videomae import VideoMAEImageProcessor


__lowerCAmelCase         =    logging.get_logger(__name__)







class UpperCAmelCase__	( lowercase__	):





  """simple docstring"""

  def __init__(		self      :     Tuple							,*_a      :     List[str]							,**_a      :     Any       ):


     '''simple docstring'''






     warnings.warn(
         'The class VideoMAEFeatureExtractor is deprecated and will be removed in version 5 of Transformers.'
         ' Please use VideoMAEImageProcessor instead.'							,_a							,)
     super().__init__(*_a							,**_a       )



