





'''simple docstring'''




import os
from typing import Optional

import fsspec
from fsspec.archive import AbstractArchiveFileSystem
from fsspec.utils import DEFAULT_BLOCK_SIZE







class   A_	(  lowerCAmelCase_			):
 _lowerCamelCase  : List[str]           =							""""""
 _lowerCamelCase  : str           =							(
     None  # protocol passed in prefix to the url. ex: "gzip", for gzip://file.txt::http://foo.bar/file.txt.gz
 )
 _lowerCamelCase  : str           =							None  # compression type in fsspec. ex: "gzip"
 _lowerCamelCase  : str           =							None  # extension of the filename to strip. ex: "".gz" to get file.txt from file.txt.gz




 def __init__(					self       :    Any	,			snake_case_       :    str = ""	,			snake_case_       :    Optional[str] = None	,			snake_case_       :    Optional[dict] = None	,			**snake_case_       :    str    ):
      super().__init__(self	,			**snake_case_    )
      # always open as "rb" since fsspec can then use the TextIOWrapper to make it work for "r" mode
      _UpperCAmelCase     							=   fsspec.open(
          snake_case_	,			mode="rb"	,			protocol=snake_case_	,			compression=self.compression	,			client_kwargs={
              "requote_redirect_url": False,  # see https://github.com/huggingface/datasets/pull/5459
              "trust_env": True,  # Enable reading proxy env variables.
              **(target_options or {}).pop("client_kwargs"	,			{}    ),  # To avoid issues if it was already passed.
          }	,			**(target_options or {})	,			)
      _UpperCAmelCase     							=   os.path.basename(self.file.path.split("::"    )[0]    )
      _UpperCAmelCase     							=   (
          self.compressed_name[: self.compressed_name.rindex("."    )]
          if "." in self.compressed_name
          else self.compressed_name
      )
      _UpperCAmelCase     							=   None




 @classmethod
 def      lowercase	(					cls       :    int	,			snake_case_       :    str    ):
      # compressed file paths are always relative to the archive root
      return super()._strip_protocol(snake_case_    ).lstrip("/"    )




 def      lowercase	(					self       :    Union[str, Any]    ):
      if self.dir_cache is None:
           _UpperCAmelCase     							=   {**self.file.fs.info(self.file.path    ), "name": self.uncompressed_name}
           _UpperCAmelCase     							=   {f["name"]: f}




 def      lowercase	(					self       :    Any	,			snake_case_       :    str    ):
      return self.file.open().read()




 def      lowercase	(					self       :    Optional[int]	,			snake_case_       :    str	,			snake_case_       :    str = "rb"	,			snake_case_       :    Tuple=None	,			snake_case_       :    Dict=True	,			snake_case_       :    Optional[int]=None	,			**snake_case_       :    Tuple	,			):
      _UpperCAmelCase     							=   self._strip_protocol(snake_case_    )
      if mode != "rb":
           raise ValueError(f'Tried to read with mode {mode} on file {self.file.path} opened with mode \'rb\''    )
      return self.file.open()







class   A_	(  lowerCAmelCase_			):
 _lowerCamelCase  : Tuple           =							"""bz2"""
 _lowerCamelCase  : Tuple           =							"""bz2"""
 _lowerCamelCase  : Union[str, Any]           =							""".bz2"""







class   A_	(  lowerCAmelCase_			):
 _lowerCamelCase  : Dict           =							"""gzip"""
 _lowerCamelCase  : Optional[Any]           =							"""gzip"""
 _lowerCamelCase  : str           =							""".gz"""







class   A_	(  lowerCAmelCase_			):
 _lowerCamelCase  : Tuple           =							"""lz4"""
 _lowerCamelCase  : Any           =							"""lz4"""
 _lowerCamelCase  : List[Any]           =							""".lz4"""







class   A_	(  lowerCAmelCase_			):
 _lowerCamelCase  : Union[str, Any]           =							"""xz"""
 _lowerCamelCase  : Optional[int]           =							"""xz"""
 _lowerCamelCase  : Optional[Any]           =							""".xz"""







class   A_	(  lowerCAmelCase_			):
 _lowerCamelCase  : Optional[int]           =							"""zstd"""
 _lowerCamelCase  : Optional[Any]           =							"""zstd"""
 _lowerCamelCase  : Optional[int]           =							""".zst"""




 def __init__(					self       :    List[str]	,			snake_case_       :    str	,			snake_case_       :    str = "rb"	,			snake_case_       :    Optional[str] = None	,			snake_case_       :    Optional[dict] = None	,			snake_case_       :    int = DEFAULT_BLOCK_SIZE	,			**snake_case_       :    Tuple	,			):
      super().__init__(
          fo=snake_case_	,			mode=snake_case_	,			target_protocol=snake_case_	,			target_options=snake_case_	,			block_size=snake_case_	,			**snake_case_	,			)
      # We need to wrap the zstd decompressor to avoid this error in fsspec==2021.7.0 and zstandard==0.15.2:
      #
      # File "/Users/user/.virtualenvs/hf-datasets/lib/python3.7/site-packages/fsspec/core.py", line 145, in open
      #     out.close = close
      # AttributeError: 'zstd.ZstdDecompressionReader' object attribute 'close' is read-only
      #
      # see https://github.com/intake/filesystem_spec/issues/725
      _UpperCAmelCase     							=   self.file.__enter__







      class   A_	:




       def __init__(					self       :    Optional[Any]	,			snake_case_       :    Optional[Any]    ):
            _UpperCAmelCase     							=   file_




       def __enter__(					self       :    Optional[Any]    ):
            self._file.__enter__()
            return self




       def __exit__(					self       :    List[str]	,			*snake_case_       :    Optional[Any]	,			**snake_case_       :    List[Any]    ):
            self._file.__exit__(*snake_case_	,			**snake_case_    )




       def __iter__(					self       :    Dict    ):
            return iter(self._file    )




       def      lowercase	(					self       :    Optional[Any]    ):
            return next(self._file    )




       def __getattr__(					self       :    List[Any]	,			snake_case_       :    Any    ):
            return getattr(self._file	,			snake_case_    )

      def fixed_enter(*snake_case_       :    List[str]	,			**snake_case_       :    int    ):
           return WrappedFile(_enter(*snake_case_	,			**snake_case_    )    )

      _UpperCAmelCase     							=   fixed_enter











'''simple docstring'''




def 	UpperCAmelCase_							(					__lowercase							:      int       )		->       int:


     '''simple docstring'''



     if not isinstance(__lowercase			,     __lowercase       ) or number < 0:
          raise ValueError("Input must be a non-negative integer"       )

     _UpperCAmelCase     							=   0
     while number:
          # This way we arrive at next set bit (next 1) instead of looping
          # through each bit and checking for 1s hence the
          # loop won't run 32 times it will only run the number of `1` times
          number &= number - 1
          count += 1
     return count


if __name__ == "__main__":
  import doctest

  doctest.testmod()




