

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    __lowerCamelCase      (					UpperCamelCase__ ):







							'''simple docstring'''






							assert "mock" in _fsspec_registry
							assert "bz2" in _fsspec_registry





def    __lowerCamelCase      (					):







							'''simple docstring'''






							assert "mock" not in _fsspec_registry
							assert "bz2" in _fsspec_registry





def    __lowerCamelCase      (					):







							'''simple docstring'''






							snake_case_     							=       'mock-s3-bucket'
							snake_case_     							=       F'''s3://{mock_bucket}'''
							snake_case_     							=       extract_path_from_uri(UpperCamelCase__ )
							assert dataset_path.startswith('s3://' ) is False

							snake_case_     							=       './local/path'
							snake_case_     							=       extract_path_from_uri(UpperCamelCase__ )
							assert dataset_path == new_dataset_path





def    __lowerCamelCase      (					UpperCamelCase__ ):







							'''simple docstring'''






							snake_case_     							=       is_remote_filesystem(UpperCamelCase__ )
							assert is_remote is True

							snake_case_     							=       fsspec.filesystem('file' )

							snake_case_     							=       is_remote_filesystem(UpperCamelCase__ )
							assert is_remote is False





@pytest.mark.parametrize('compression_fs_class'  ,				UpperCamelCase__ )
def    __lowerCamelCase      (					UpperCamelCase__  ,				UpperCamelCase__  ,				UpperCamelCase__  ,				UpperCamelCase__  ,				UpperCamelCase__  ,				UpperCamelCase__  ,				UpperCamelCase__ ):







							'''simple docstring'''






							snake_case_     							=       {'gzip': gz_file, 'xz': xz_file, 'zstd': zstd_file, 'bz2': bza_file, 'lz4': lza_file}
							snake_case_     							=       input_paths[compression_fs_class.protocol]
							if input_path is None:
														snake_case_     							=       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(UpperCamelCase__ )
							snake_case_     							=       fsspec.filesystem(compression_fs_class.protocol  ,				fo=UpperCamelCase__ )
							assert isinstance(UpperCamelCase__  ,				UpperCamelCase__ )
							snake_case_     							=       os.path.basename(UpperCamelCase__ )
							snake_case_     							=       expected_filename[: expected_filename.rindex('.' )]
							assert fs.glob('*' ) == [expected_filename]
							with fs.open(UpperCamelCase__  ,				'r'  ,				encoding='utf-8' ) as f, open(UpperCamelCase__  ,				encoding='utf-8' ) as expected_file:
														assert f.read() == expected_file.read()





@pytest.mark.parametrize('protocol'  ,				['zip', 'gzip'] )
def    __lowerCamelCase      (					UpperCamelCase__  ,				UpperCamelCase__  ,				UpperCamelCase__ ):







							'''simple docstring'''






							snake_case_     							=       {'zip': zip_jsonl_path, 'gzip': jsonl_gz_path}
							snake_case_     							=       compressed_file_paths[protocol]
							snake_case_     							=       'dataset.jsonl'
							snake_case_     							=       F'''{protocol}://{member_file_path}::{compressed_file_path}'''
							snake_case_							,       *snake_case_     							=       fsspec.get_fs_token_paths(UpperCamelCase__ )
							assert fs.isfile(UpperCamelCase__ )
							assert not fs.isfile('non_existing_' + member_file_path )





@pytest.mark.integration
def    __lowerCamelCase      (					UpperCamelCase__  ,				UpperCamelCase__  ,				UpperCamelCase__  ,				UpperCamelCase__ ):







							'''simple docstring'''






							snake_case_     							=       hf_api.dataset_info(UpperCamelCase__  ,				token=UpperCamelCase__ )
							snake_case_     							=       HfFileSystem(repo_info=UpperCamelCase__  ,				token=UpperCamelCase__ )
							assert sorted(hffs.glob('*' ) ) == [".gitattributes", "data"]
							assert hffs.isdir('data' )
							assert hffs.isfile('.gitattributes' ) and hffs.isfile('data/text_data.txt' )
							with open(UpperCamelCase__ ) as f:
														assert hffs.open('data/text_data.txt'  ,				'r' ).read() == f.read()





def    __lowerCamelCase      (					):







							'''simple docstring'''






							snake_case_     							=       'bz2'

							# Import module
							import datasets.filesystems

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

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







def    __lowerCamelCase      (					UpperCamelCase__ = 1000 ):







							'''simple docstring'''






							snake_case_     							=       2**power
							snake_case_     							=       0
							while n:
														snake_case_							,       snake_case_     							=       r + n % 10, n // 10
							return r


if __name__ == "__main__":
					print(solution(int(str(input()).strip())))




