"""simple docstring"""




from pathlib import PurePosixPath
from typing import Optional

import fsspec
from fsspec import AbstractFileSystem
from huggingface_hub.hf_api import DatasetInfo

from ..utils.file_utils import get_authentication_headers_for_url
from ..utils.hub import hf_hub_url
class 						__A							( __lowerCamelCase		):
     _UpperCamelCase							:			List[Any]							=		""""""
     _UpperCamelCase							:			Tuple							=		"""hf-legacy"""  # "hf://"" is reserved for hffs






     def __init__(		self				,     a__ = None				,     a__ = None				,     **a__				,     ):
       super().__init__(self				,     **__lowercase  )
       _lowerCAmelCase						:       Dict  			=     repo_info
       _lowerCAmelCase						:       str  			=     token
       _lowerCAmelCase						:       Any  			=     None






     def     __A  (		self  ):
       if self.dir_cache is None:
         _lowerCAmelCase						:       Optional[int]  			=     {}
         for hf_file in self.repo_info.siblings:
           # TODO(QL): add sizes
           _lowerCAmelCase						:       Optional[Any]  			=     {
               '''name''': hf_file.rfilename,
               '''size''': None,
               '''type''': '''file''',
           }
           self.dir_cache.update(
               {
                   str(__lowercase  ): {"""name""": str(__lowercase  ), """size""": None, """type""": """directory"""}
                   for d in list(PurePosixPath(hf_file.rfilename  ).parents  )[:-1]
               }  )






     def     __A  (		self				,     a__				,     a__ = "rb"				,     **a__				,     ):
       if not isinstance(self.repo_info				,     __lowercase  ):
         raise NotImplementedError(F"Open is only implemented for dataset repositories, but got {self.repo_info}"  )
       _lowerCAmelCase						:       Tuple  			=     hf_hub_url(self.repo_info.id				,     __lowercase				,     revision=self.repo_info.sha  )
       return fsspec.open(
           __lowercase				,     mode=__lowercase				,     headers=get_authentication_headers_for_url(__lowercase				,     use_auth_token=self.token  )				,     client_kwargs={"""trust_env""": True}				,     ).open()






     def     __A  (		self				,     a__				,     **a__  ):
       self._get_dirs()
       _lowerCAmelCase						:       Optional[Any]  			=     self._strip_protocol(__lowercase  )
       if path in self.dir_cache:
         return self.dir_cache[path]
       else:
         raise FileNotFoundError(__lowercase  )






     def     __A  (		self				,     a__				,     a__=False				,     **a__  ):
       self._get_dirs()
       _lowerCAmelCase						:       List[Any]  			=     PurePosixPath(path.strip("""/"""  )  )
       _lowerCAmelCase						:       Any  			=     {}
       for p, f in self.dir_cache.items():
         _lowerCAmelCase						:       Optional[Any]  			=     PurePosixPath(p.strip("""/"""  )  )
         _lowerCAmelCase						:       Optional[int]  			=     p.parent
         if root == path:
           _lowerCAmelCase						:       List[Any]  			=     f
       _lowerCAmelCase						:       Dict  			=     list(paths.values()  )
       if detail:
         return out
       else:
         return sorted(f["""name"""] for f in out  )









A__								=						[4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]
A__								=						[3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]
A__								=						{
    0: '''Sunday''',
    1: '''Monday''',
    2: '''Tuesday''',
    3: '''Wednesday''',
    4: '''Thursday''',
    5: '''Friday''',
    6: '''Saturday''',
}



def 			_lowerCAmelCase       (					__lowerCAmelCase  ,  __lowerCAmelCase  ,  __lowerCAmelCase      )   ->					str:


				"""simple docstring"""

				assert len(str(__lowerCAmelCase      )      ) > 2, "year should be in YYYY format"
				assert 1 <= month <= 12, "month should be between 1 to 12"
				assert 1 <= day <= 31, "day should be between 1 to 31"

				# Doomsday algorithm:
				snake_case__	:      Optional[int]     		=	year // 100
				snake_case__	:      List[str]     		=	(5 * (century % 4) + 2) % 7
				snake_case__	:      Dict     		=	year % 100
				snake_case__	:      Union[str, Any]     		=	centurian % 12
				snake_case__	:      List[Any]     		=	(
				    (centurian // 12) + centurian_m + (centurian_m // 4) + century_anchor
				) % 7
				snake_case__	:      List[str]     		=	(
				    DOOMSDAY_NOT_LEAP[month - 1]
				    if (year % 4 != 0) or (centurian == 0 and (year % 400) == 0)
				    else DOOMSDAY_LEAP[month - 1]
				)
				snake_case__	:      List[str]     		=	(dooms_day + day - day_anchor) % 7
				return WEEK_DAY_NAMES[week_day]


if __name__ == "__main__":
				import doctest

				doctest.testmod()

