/usr/local/lib/python3.6/site-packages/datasets/filesystems/__pycache__
NameSizeModeActions
compression.cpython-36.pyc61420644editdlrm
hffilesystem.cpython-36.pyc32260644editdlrm
s3filesystem.cpython-36.pyc56000644editdlrm
__init__.cpython-36.pyc15760644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/datasets/filesystems/__pycache__/hffilesystem.cpython-36.pyc (3226B)
3 <%Eg @s\ddlmZddlmZddlZddlmZddlmZddlm Z m Z Gdd d eZ dS) ) PurePosixPath)OptionalN)AbstractFileSystem) DatasetInfo)"get_authentication_headers_for_url hf_hub_urlcsfeZdZdZdZdZdeeeedfdd Z dd Z deed d d Z ddZ dddZ ZS) HfFileSystemz/Interface to files in a Hugging face repositoryZhfN) repo_infotokenc s&tj|f|||_||_d|_dS)a The file system can be instantiated using a huggingface_hub.hf_api.DatasetInfo object, and can be used to list and open files from a Hugging Face dataset repository with fsspec. Args: repo_info (:obj:``DatasetInfo``, `optional`): Dataset repository info from huggingface_hub.HfApi().dataset_info(...) token (:obj:``str``, `optional`): Hugging Face token. Will default to the locally saved token if not provided. N)super__init__r r dir_cache)selfr r kwargs) __class__K/usr/local/lib/python3.6/site-packages/datasets/filesystems/hffilesystem.pyrszHfFileSystem.__init__cCsf|jdkrbi|_xP|jjD]D}|jddd|j|j<|jjddtt|jjddDqWdS)Nfile)namesizetypecSs"i|]}t|dddt|qS)N directory)rrr)str).0drrr 1sz*HfFileSystem._get_dirs..)rr ZsiblingsZ rfilenameupdatelistrparents)rZhf_filerrr _get_dirs&s zHfFileSystem._get_dirsrb)pathmodecKsPt|jtstd|jt|jj||jjd}tj||t ||j ddjS)Nz;Open is only implemented for dataset repositories, but got )revision)Zuse_auth_token)r&headers) isinstancer rNotImplementedErrorridshafsspecopenrr )rr%r&rurlrrr_open7s zHfFileSystem._opencKs2|j|j|}||jkr&|j|St|dS)N)r#Z_strip_protocolrFileNotFoundError)rr%rrrrinfoFs    zHfFileSystem.infoFc Ks|jt|jd}i}x>|jjD]0\}}t|jd}|j}||kr&||t|<q&Wt|j}|rn|Stt dd|DSdS)N/css|]}|dVqdS)rNr)rfrrr [sz"HfFileSystem.ls..) r#rstripritemsparentrr!valuessorted) rr%Zdetailrpathspr4rootoutrrrlsNs zHfFileSystem.ls)NN)r$)F)__name__ __module__ __qualname____doc__Z root_markerprotocolrrrrr#r0r2r? __classcell__rr)rrr s r ) pathlibrtypingrr-rZhuggingface_hub.hf_apirZutils.file_utilsrrr rrrrs