U C^ @s0ddlZddlZddlmZGdddeZdS)N)AbstractFileSystemcsBeZdZdZdZdZdZdfdd Zdd d ZdddZ Z S)GithubFileSystema[Experimental] interface to files in github An instance of this class provides the files residing within a remote github repository. You may specify a point in the repos history, by SHA, branch or tag (default is current master). Given that code files tend to be small, and that github does not support retrieving partial content, we always fetch whole files. z9https://api.github.com/repos/{org}/{repo}/git/trees/{sha}z;https://raw.githubusercontent.com/{org}/{repo}/{sha}/{path}Zgithubmasterc s.tjf|||_||_||_|ddS)N)super__init__orgreporootls)selfr r shakwargs __class__A/tmp/pip-install-6_kvzl1k/fsspec/fsspec/implementations/github.pyrs zGithubFileSystem.__init__FNc  sdkr|j}|dkrdd}d|j}|D]h}|jd|d}rVd|n|7fdd|Dd}|dd kr|r|gSS|d }q4|jkrt|jj|j |j |d }fd d| d D|j<|r|jSt dd|jDSdS)Nr/T)rcsg|]}|dkr|qSnamer).0o)so_farrr &s z'GithubFileSystem.ls..rtypefiler)r r rc sRg|]J}rd|dn|d|dddd|d|dd|d d qS) rpathmoder directory)Zblobtreersizerr)rrrr!r)getrf)rrrr/s r cSsg|] }|dqSrrr#rrrr<s) r rstripsplitr Zdircacherequestsr"urlformatr r jsonsorted) r rZdetailrrpartspartoutrr)rrrr s.       zGithubFileSystem.lsrbTc Ks<|dkr t|jj|j|j||jd}t|}t |j S)Nr0)r r rr) NotImplementedErrorrurlr)r r r r'r"ioBytesIOcontent) r rr block_sizeZ autocommitZ cache_optionsrr(r/rrr_open>s  zGithubFileSystem._open)r)FN)r0NTN) __name__ __module__ __qualname____doc__r(r2protocolrr r7 __classcell__rrrrrs  %r)r3r'specrrrrrrs