

"""simple docstring"""
import importlib
import os

import fsspec
import pytest
from fsspec import register_implementation
from fsspec.registry import _registry as _fsspec_registry

from datasets.filesystems import COMPRESSION_FILESYSTEMS, HfFileSystem, extract_path_from_uri, is_remote_filesystem

from .utils import require_lza, require_zstandard




def 					a__						(						lowerCAmelCase    )	-> Optional[Any]:
      assert "mock" in _fsspec_registry
      assert "bz2" in _fsspec_registry




def 					a__						(						)	-> Optional[Any]:
      assert "mock" not in _fsspec_registry
      assert "bz2" in _fsspec_registry




def 					a__						(						)	-> Union[str, Any]:
      UpperCAmelCase__			:							str							=    """mock-s3-bucket"""
      UpperCAmelCase__			:							Optional[Any]							=    F"""s3://{mock_bucket}"""
      UpperCAmelCase__			:							Optional[Any]							=    extract_path_from_uri(lowerCAmelCase    )
      assert dataset_path.startswith("""s3://"""    ) is False

      UpperCAmelCase__			:							Optional[int]							=    """./local/path"""
      UpperCAmelCase__			:							Optional[int]							=    extract_path_from_uri(lowerCAmelCase    )
      assert dataset_path == new_dataset_path




def 					a__						(						lowerCAmelCase    )	-> Union[str, Any]:
      UpperCAmelCase__			:							Optional[int]							=    is_remote_filesystem(lowerCAmelCase    )
      assert is_remote is True

      UpperCAmelCase__			:							List[Any]							=    fsspec.filesystem("""file"""    )

      UpperCAmelCase__			:							str							=    is_remote_filesystem(lowerCAmelCase    )
      assert is_remote is False




@pytest.mark.parametrize("""compression_fs_class"""			,	lowerCAmelCase    )
def 					a__						(						lowerCAmelCase			,	lowerCAmelCase			,	lowerCAmelCase			,	lowerCAmelCase			,	lowerCAmelCase			,	lowerCAmelCase			,	lowerCAmelCase    )	-> Optional[Any]:
      UpperCAmelCase__			:							Optional[int]							=    {"""gzip""": gz_file, """xz""": xz_file, """zstd""": zstd_file, """bz2""": bza_file, """lz4""": lza_file}
      UpperCAmelCase__			:							Dict							=    input_paths[compression_fs_class.protocol]
      if input_path is None:
            UpperCAmelCase__			:							int							=    F"""for '{compression_fs_class.protocol}' compression protocol, """
            if compression_fs_class.protocol == "lz4":
                  reason += require_lza.kwargs["reason"]
            elif compression_fs_class.protocol == "zstd":
                  reason += require_zstandard.kwargs["reason"]
            pytest.skip(lowerCAmelCase    )
      UpperCAmelCase__			:							Dict							=    fsspec.filesystem(compression_fs_class.protocol			,	fo=lowerCAmelCase    )
      assert isinstance(lowerCAmelCase			,	lowerCAmelCase    )
      UpperCAmelCase__			:							str							=    os.path.basename(lowerCAmelCase    )
      UpperCAmelCase__			:							str							=    expected_filename[: expected_filename.rindex("""."""    )]
      assert fs.glob("""*"""    ) == [expected_filename]
      with fs.open(lowerCAmelCase			,	"""r"""			,	encoding="""utf-8"""    ) as f, open(lowerCAmelCase			,	encoding="""utf-8"""    ) as expected_file:
            assert f.read() == expected_file.read()




@pytest.mark.parametrize("""protocol"""			,	["""zip""", """gzip"""]    )
def 					a__						(						lowerCAmelCase			,	lowerCAmelCase			,	lowerCAmelCase    )	-> Any:
      UpperCAmelCase__			:							Optional[Any]							=    {"""zip""": zip_jsonl_path, """gzip""": jsonl_gz_path}
      UpperCAmelCase__			:							List[str]							=    compressed_file_paths[protocol]
      UpperCAmelCase__			:							Optional[int]							=    """dataset.jsonl"""
      UpperCAmelCase__			:							List[str]							=    F"""{protocol}://{member_file_path}::{compressed_file_path}"""
      UpperCAmelCase__					,		*UpperCAmelCase__			:							Optional[int]							=    fsspec.get_fs_token_paths(lowerCAmelCase    )
      assert fs.isfile(lowerCAmelCase    )
      assert not fs.isfile("""non_existing_""" + member_file_path    )




@pytest.mark.integration
def 					a__						(						lowerCAmelCase			,	lowerCAmelCase			,	lowerCAmelCase			,	lowerCAmelCase    )	-> Tuple:
      UpperCAmelCase__			:							Tuple							=    hf_api.dataset_info(lowerCAmelCase			,	token=lowerCAmelCase    )
      UpperCAmelCase__			:							Dict							=    HfFileSystem(repo_info=lowerCAmelCase			,	token=lowerCAmelCase    )
      assert sorted(hffs.glob("""*"""    )    ) == [".gitattributes", "data"]
      assert hffs.isdir("""data"""    )
      assert hffs.isfile(""".gitattributes"""    ) and hffs.isfile("""data/text_data.txt"""    )
      with open(lowerCAmelCase    ) as f:
            assert hffs.open("""data/text_data.txt"""			,	"""r"""    ).read() == f.read()





def 					a__						(						)	-> int:
      UpperCAmelCase__			:							Union[str, Any]							=    """bz2"""

      # Import module
      import datasets.filesystems

      # Overwrite protocol and reload
      register_implementation(lowerCAmelCase			,	lowerCAmelCase			,	clobber=lowerCAmelCase    )
      with pytest.warns(lowerCAmelCase    ) as warning_info:
            importlib.reload(datasets.filesystems    )

      assert len(lowerCAmelCase    ) == 1
      assert (
          str(warning_info[0].message    )
          == F"""A filesystem protocol was already set for {protocol} and will be overwritten."""
      )




"""simple docstring"""
from __future__ import annotations

from functools import lru_cache
from math import ceil

_A							=  1_00

_A							=  set(range(3, NUM_PRIMES, 2))
primes.add(2)
_A							=  42

for prime in range(3, ceil(NUM_PRIMES**0.5), 2):
    if prime not in primes:
        continue
    primes.difference_update(set(range(prime * prime, NUM_PRIMES, prime)))




@lru_cache(maxsize=1_00    )
def 					a__						(						lowerCAmelCase    )	-> set[int]:
      if number_to_partition < 0:
            return set()
      elif number_to_partition == 0:
            return {1}

      UpperCAmelCase__			:							set[int]							=    set()
      UpperCAmelCase__			:							int
      UpperCAmelCase__			:							int

      for prime in primes:
            if prime > number_to_partition:
                  continue
            for sub in partition(number_to_partition - prime    ):
                  ret.add(sub * prime    )

      return ret




def 					a__						(						lowerCAmelCase = 50_00    )	-> int | None:
      for number_to_partition in range(1			,	lowerCAmelCase    ):
            if len(partition(lowerCAmelCase    )    ) > number_unique_partitions:
                  return number_to_partition
      return None


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

