



"""simple docstring"""
import os
from typing import Optional

import fsspec
from fsspec.archive import AbstractArchiveFileSystem
from fsspec.utils import DEFAULT_BLOCK_SIZE
class 							_UpperCAmelCase							( a      ):





     '''simple docstring'''



     a__									=''''''
     a__									=(
         None  # protocol passed in prefix to the url. ex: "gzip", for gzip://file.txt::http://foo.bar/file.txt.gz
     )
     a__									=None  # compression type in fsspec. ex: "gzip"
     a__									=None  # extension of the filename to strip. ex: "".gz" to get file.txt from file.txt.gz





     def __init__(					self       ,	A = ""       ,	A = None       ,	A = None       ,	**A		)							->					Optional[Any]:
         super().__init__(self       ,	**A		)
         # always open as "rb" since fsspec can then use the TextIOWrapper to make it work for "r" mode
         _UpperCAmelCase							:  Optional[Any]											=    fsspec.open(
             A       ,	mode='''rb'''       ,	protocol=A       ,	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							:  Optional[Any]											=    os.path.basename(self.file.path.split('''::'''		)[0]		)
         _UpperCAmelCase							:  Any											=    (
             self.compressed_name[: self.compressed_name.rindex('''.'''		)]
             if '''.''' in self.compressed_name
             else self.compressed_name
         )
         _UpperCAmelCase							:  Any											=    None





     @classmethod
     def  __lowerCAmelCase	(					cls       ,	A		)							->					Tuple:
         # compressed file paths are always relative to the archive root
         return super()._strip_protocol(A		).lstrip('''/'''		)





     def  __lowerCAmelCase	(					self		)							->					Any:
         if self.dir_cache is None:
             _UpperCAmelCase							:  Dict											=    {**self.file.fs.info(self.file.path		), '''name''': self.uncompressed_name}
             _UpperCAmelCase							:  Tuple											=    {f['''name''']: f}





     def  __lowerCAmelCase	(					self       ,	A		)							->					Tuple:
         return self.file.open().read()





     def  __lowerCAmelCase	(					self       ,	A       ,	A = "rb"       ,	A=None       ,	A=True       ,	A=None       ,	**A       ,	)							->					List[Any]:
         _UpperCAmelCase							:  Optional[Any]											=    self._strip_protocol(A		)
         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 							_UpperCAmelCase							( a      ):





     '''simple docstring'''



     a__									='''bz2'''
     a__									='''bz2'''
     a__									='''.bz2'''



class 							_UpperCAmelCase							( a      ):





     '''simple docstring'''



     a__									='''gzip'''
     a__									='''gzip'''
     a__									='''.gz'''



class 							_UpperCAmelCase							( a      ):





     '''simple docstring'''



     a__									='''lz4'''
     a__									='''lz4'''
     a__									='''.lz4'''



class 							_UpperCAmelCase							( a      ):





     '''simple docstring'''



     a__									='''xz'''
     a__									='''xz'''
     a__									='''.xz'''



class 							_UpperCAmelCase							( a      ):





     '''simple docstring'''



     a__									='''zstd'''
     a__									='''zstd'''
     a__									='''.zst'''





     def __init__(					self       ,	A       ,	A = "rb"       ,	A = None       ,	A = None       ,	A = DEFAULT_BLOCK_SIZE       ,	**A       ,	)							->					str:
         super().__init__(
             fo=A       ,	mode=A       ,	target_protocol=A       ,	target_options=A       ,	block_size=A       ,	**A       ,	)
         # 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							:  int											=    self.file.__enter__
         class 							_UpperCAmelCase							:





              '''simple docstring'''



              def __init__(					self       ,	A		)							->					Optional[Any]:
                  _UpperCAmelCase							:  Optional[int]											=    file_





              def __enter__(					self		)							->					List[str]:
                  self._file.__enter__()
                  return self





              def __exit__(					self       ,	*A       ,	**A		)							->					Union[str, Any]:
                  self._file.__exit__(*A       ,	**A		)





              def __iter__(					self		)							->					Any:
                  return iter(self._file		)





              def  __lowerCAmelCase	(					self		)							->					List[str]:
                  return next(self._file		)





              def __getattr__(					self       ,	A		)							->					List[Any]:
                  return getattr(self._file       ,	A		)

         def fixed_enter(*A       ,	**A		):
             return WrappedFile(_enter(*A       ,	**A		)		)

         _UpperCAmelCase							:  Tuple											=    fixed_enter







"""simple docstring"""
def  lowerCamelCase_						(UpperCamelCase__		:		int     ,       UpperCamelCase__		:		int							):
    if a < 0 or b < 0:
        raise ValueError('''the value of both inputs must be positive'''							)
    _UpperCAmelCase							:  List[str]											=    str(bin(UpperCamelCase__							)							)[2:]  # remove the leading "0b"
    _UpperCAmelCase							:  str											=    str(bin(UpperCamelCase__							)							)[2:]
    _UpperCAmelCase							:  List[str]											=    max(len(UpperCamelCase__							)     ,       len(UpperCamelCase__							)							)
    return "0b" + "".join(
        str(int('''1''' in (char_a, char_b)							)							)
        for char_a, char_b in zip(a_binary.zfill(UpperCamelCase__							)     ,       b_binary.zfill(UpperCamelCase__							)							)							)


if __name__ == "__main__":
  import doctest

  doctest.testmod()


