




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


_lowercase  =			"""http://www.mocksite.com/file1.txt"""
_lowercase  =			"""\"text\": [\"foo\", \"foo\"]"""
_lowercase  =			"""6d8ce9aa78a471c7477201efbeabd3bb01ac2e7d100a6dc024ba1608361f90a8"""
class 						a_				:
	lowercase_       :     Union[str, Any]			  =      200
	lowercase_       :     Optional[int]			  =      {'''Content-Length''': '''100'''}
	lowercase_       :     Optional[int]			  =      {}




	def   lowercase__   (       self     :  Union[str, Any]       ,		**__lowerCAmelCase     :  int      ):
							return [bytes(__lowerCAmelCase       ,		'utf-8'      )]





def 						lowerCamelCase__   (				*a    ,	**a							):
						return MockResponse()
@pytest.mark.parametrize('urls_type'    ,	[str, list, dict]							)
def 						lowerCamelCase__   (				a    ,	a    ,	a							):
						import requests

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

						__snake_case						 =   URL
						if issubclass(a    ,	a							):
												__snake_case						 =   url
						elif issubclass(a    ,	a							):
												__snake_case						 =   [url]
						elif issubclass(a    ,	a							):
												__snake_case						 =   {'train': url}
						__snake_case						 =   'dummy'
						__snake_case						 =   'downloads'
						__snake_case						 =   tmp_path
						__snake_case						 =   DownloadConfig(
						    cache_dir=os.path.join(a    ,	a							)    ,	use_etag=a    ,	)
						__snake_case						 =   DownloadManager(dataset_name=a    ,	download_config=a							)
						__snake_case						 =   dl_manager.download(a							)
						__snake_case						 =   urls
						for downloaded_paths in [downloaded_paths]:
												if isinstance(a    ,	a							):
																		__snake_case						 =   [downloaded_paths]
																		__snake_case						 =   [urls]
												elif isinstance(a    ,	a							):
																		assert "train" in downloaded_paths.keys()
																		__snake_case						 =   downloaded_paths.values()
																		__snake_case						 =   urls.values()
												assert downloaded_paths
												for downloaded_path, input_url in zip(a    ,	a							):
																		assert downloaded_path == dl_manager.downloaded_paths[input_url]
																		__snake_case						 =   Path(a							)
																		__snake_case						 =   downloaded_path.parts
																		assert parts[-1] == HASH
																		assert parts[-2] == cache_subdir
																		assert downloaded_path.exists()
																		__snake_case						 =   downloaded_path.read_text()
																		assert content == CONTENT
																		__snake_case						 =   downloaded_path.with_suffix('.json'							)
																		assert metadata_downloaded_path.exists()
																		__snake_case						 =   json.loads(metadata_downloaded_path.read_text()							)
																		assert metadata_content == {"url": URL, "etag": None}
@pytest.mark.parametrize('paths_type'    ,	[str, list, dict]							)
def 						lowerCamelCase__   (				a    ,	a    ,	a							):
						__snake_case						 =   str(a							)
						if issubclass(a    ,	a							):
												__snake_case						 =   filename
						elif issubclass(a    ,	a							):
												__snake_case						 =   [filename]
						elif issubclass(a    ,	a							):
												__snake_case						 =   {'train': filename}
						__snake_case						 =   'dummy'
						__snake_case						 =   xz_file.parent
						__snake_case						 =   'extracted'
						__snake_case						 =   DownloadConfig(
						    cache_dir=a    ,	use_etag=a    ,	)
						__snake_case						 =   DownloadManager(dataset_name=a    ,	download_config=a							)
						__snake_case						 =   dl_manager.extract(a							)
						__snake_case						 =   paths
						for extracted_paths in [extracted_paths]:
												if isinstance(a    ,	a							):
																		__snake_case						 =   [extracted_paths]
																		__snake_case						 =   [paths]
												elif isinstance(a    ,	a							):
																		assert "train" in extracted_paths.keys()
																		__snake_case						 =   extracted_paths.values()
																		__snake_case						 =   paths.values()
												assert extracted_paths
												for extracted_path, input_path in zip(a    ,	a							):
																		assert extracted_path == dl_manager.extracted_paths[input_path]
																		__snake_case						 =   Path(a							)
																		__snake_case						 =   extracted_path.parts
																		assert parts[-1] == hash_url_to_filename(a    ,	etag=a							)
																		assert parts[-2] == extracted_subdir
																		assert extracted_path.exists()
																		__snake_case						 =   extracted_path.read_text()
																		__snake_case						 =   text_file.read_text()
																		assert extracted_file_content == expected_file_content
def 						lowerCamelCase__   (				a    ,	a							):
						assert path.endswith('.jsonl'							)
						for num_items, line in enumerate(a    ,	start=1							):
												__snake_case						 =   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 						lowerCamelCase__   (				a    ,	a							):
						__snake_case						 =   request.getfixturevalue(a							)
						__snake_case						 =   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 						lowerCamelCase__   (				a    ,	a							):
						__snake_case						 =   request.getfixturevalue(a							)
						__snake_case						 =   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 						lowerCamelCase__   (				a							):
						__snake_case						 =   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


_lowercase  =			logging.get_logger(__name__)
class 						a_				(			UpperCAmelCase__						):




	def __init__(       self     :  Tuple       ,		*__lowerCAmelCase     :  List[str]       ,		**__lowerCAmelCase     :  List[str]      ):
							warnings.warn(
							    'The class VideoMAEFeatureExtractor is deprecated and will be removed in version 5 of Transformers.'
							    ' Please use VideoMAEImageProcessor instead.'       ,		__lowerCAmelCase       ,		)
							super().__init__(*__lowerCAmelCase       ,		**__lowerCAmelCase      )

