§
    dŠtj…-  ã                   ó^   — d dl Z d dlZd dlZddlmZ ddlmZ ddlmZ  G d„ de¦  «        Z	dS )	é    Né   )ÚAbstractFileSystem©Úinfer_storage_optionsé   )Ú
MemoryFilec                   ó  ‡ — e Zd ZdZdZdZdZdZ	 dˆ fd„	Ze	d„ ¦   «         Z
edd
„¦   «         Ze	d„ ¦   «         Ze	d„ ¦   «         Ze	d„ ¦   «         Zdd„Zdd„Zeˆ fd„¦   «         Zed„ ¦   «         Z	 	 	 	 dd„Zdd„Zdd„Zd„ Zˆ xZS )ÚGithubFileSystema–  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).

    For files less than 1 MB in size, file content is returned directly in a
    MemoryFile. For larger files, or for files tracked by git-lfs, file content
    is returned as an HTTPFile wrapping the ``download_url`` provided by the
    GitHub API.

    When using fsspec.open, allows URIs of the form:

    - "github://path/file", in which case you must specify org, repo and
      may specify sha in the extra args
    - 'github://org:repo@/precip/catalog.yml', where the org and repo are
      part of the URI
    - 'github://org:repo@sha/precip/catalog.yml', where the sha is also included

    ``sha`` can be the full or abbreviated hex of the commit you want to fetch
    from, or a branch or tag name (so long as it doesn't contain special characters
    like "/", "?", which would have to be HTTP-encoded).

    For authorised access, you must provide username and token, which can be made
    at https://github.com/settings/tokens
    z9https://api.github.com/repos/{org}/{repo}/git/trees/{sha}zChttps://api.github.com/repos/{org}/{repo}/contents/{path}?ref={sha}Úgithub)é<   r   Nc                 ó  •—  t          ¦   «         j        d	i |¤Ž || _        || _        |d u |d u z  rt	          d¦  «        ‚|| _        || _        |�|| _        |€cd}t          j	        | 
                    ||¬¦  «        fd| j        i| j        ¤Ž}	|	                     ¦   «          |	                     ¦   «         d         }|| _        |                      d¦  «         	 ddlm}
  |
d	i |¤Ž| _        d S # t&          $ r d | _        Y d S w xY w)
Nz%Auth required both username and tokenz)https://api.github.com/repos/{org}/{repo}©ÚorgÚrepoÚtimeoutÚdefault_branchÚ r   )ÚHTTPFileSystem© )ÚsuperÚ__init__r   r   Ú
ValueErrorÚusernameÚtokenr   ÚrequestsÚgetÚformatÚkwÚraise_for_statusÚjsonÚrootÚlsÚhttpr   Úhttp_fsÚImportError)Úselfr   r   Úshar   r   r   ÚkwargsÚuÚrr   Ú	__class__s              €ú[/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/fsspec/implementations/github.pyr   zGithubFileSystem.__init__,   sO  ø€ ð 	�‰ŒÔÐ"Ð"˜6Ð"Ð"Ð"ØˆŒØˆŒ	Ø˜Ð ¨$ Ñ/ð 	FÝÐDÑEÔEÐEØ ˆŒØˆŒ
ØÐØ"ˆDŒLØˆ;à;ˆAÝ”Ø—’˜S t�Ñ,Ô,ðð Ø6:´lðØFJÄgðð ˆAð ×ÒÑ Ô Ð Ø—&’&‘(”(Ð+Ô,ˆCàˆŒ	Ø�Š�‰Œˆð	 Ø,Ð,Ð,Ð,Ð,Ð,à)˜>Ð3Ð3¨FÐ3Ð3ˆDŒLˆLˆLøÝð 	 ð 	 ð 	 ØˆDŒLˆLˆLˆLð	 øøøs   ÃC/ Ã/DÄDc                 ó4   — | j         rd| j         | j        fiS i S )NÚauth)r   r   ©r&   s    r,   r   zGithubFileSystem.kwJ   s%   € àŒ=ð 	9Ø˜Tœ]¨D¬JÐ7Ð8Ð8Øˆ	ó    Tc                 óº   — t          j        dddg|         › d|› d�| j        ¬¦  «        }|                     ¦   «          d„ |                     ¦   «         D ¦   «         S )av  List repo names for given org or user

        This may become the top level of the FS

        Parameters
        ----------
        org_or_user: str
            Name of the github org or user to query
        is_org: bool (default True)
            Whether the name is an organisation (True) or user (False)

        Returns
        -------
        List of string
        zhttps://api.github.com/ÚusersÚorgsú/z/repos)r   c                 ó   — g | ]
}|d          ‘ŒS ©Únamer   )Ú.0r   s     r,   ú
<listcomp>z*GithubFileSystem.repos.<locals>.<listcomp>f   s   € Ð2Ð2Ð2 ��V”Ð2Ð2Ð2r0   )r   r   r   r   r    )ÚclsÚorg_or_userÚis_orgr*   s       r,   ÚreposzGithubFileSystem.reposP   so   € õ" ŒLØU w°Ð&7¸Ô&?ÐUÐUÀ+ÐUÐUÐUØ”Kð
ñ 
ô 
ˆð 	
×ÒÑÔÐØ2Ð2¨¯ª©¬Ð2Ñ2Ô2Ð2r0   c                 óÄ   — t          j        d| j        › d| j        › d�fd| j        i| j        ¤Ž}|                     ¦   «          d„ |                     ¦   «         D ¦   «         S )zNames of tags in the repoúhttps://api.github.com/repos/r4   z/tagsr   c                 ó   — g | ]
}|d          ‘ŒS r6   r   ©r8   Úts     r,   r9   z)GithubFileSystem.tags.<locals>.<listcomp>q   ó   € Ð,Ð,Ð,˜a��&”	Ð,Ð,Ð,r0   ©r   r   r   r   r   r   r   r    ©r&   r*   s     r,   ÚtagszGithubFileSystem.tagsh   sz   € õ ŒLØG¨D¬HÐGÐG°t´yÐGÐGÐGð
ð 
à”Lð
ð Œgð
ð 
ˆð
 	
×ÒÑÔÐØ,Ð, 1§6¢6¡8¤8Ð,Ñ,Ô,Ð,r0   c                 óÄ   — t          j        d| j        › d| j        › d�fd| j        i| j        ¤Ž}|                     ¦   «          d„ |                     ¦   «         D ¦   «         S )zNames of branches in the repor?   r4   z	/branchesr   c                 ó   — g | ]
}|d          ‘ŒS r6   r   rA   s     r,   r9   z-GithubFileSystem.branches.<locals>.<listcomp>|   rC   r0   rD   rE   s     r,   ÚbrancheszGithubFileSystem.branchess   sz   € õ ŒLØK¨D¬HÐKÐK°t´yÐKÐKÐKð
ð 
à”Lð
ð Œgð
ð 
ˆð
 	
×ÒÑÔÐØ,Ð, 1§6¢6¡8¤8Ð,Ñ,Ô,Ð,r0   c                 ó    — | j         | j        dœS )z#Named references, tags and branches©rF   rI   rK   r/   s    r,   ÚrefszGithubFileSystem.refs~   s   € ð œ	¨t¬}Ð=Ð=Ð=r0   Fc                 ó|  ‡‡
‡— |                       ‰¦  «        Š‰dk    r	|p| j        }|€£‰                     d¦  «                             d¦  «        }dŠ
|p| j        }|D ]m}|                      ‰
d||¬¦  «        }‰
‰
rd|z   n|z  Š
ˆ
fd„|D ¦   «         }|st          ‰¦  «        ‚|d         }|d         d	k    r|r|gc S ‰c S |d
         }Œn‰| j        vs|| j        dfvr³t          j        | j	         
                    | j        | j        |¬¦  «        fd| j        i| j        ¤Ž}	|	j        dk    rt          ‰¦  «        ‚|	                     ¦   «          d	ddœŠˆˆfd„|	                     ¦   «         d         D ¦   «         }|| j        dfv r
|| j        ‰<   n| j        ‰         }|r|S t%          d„ |D ¦   «         ¦  «        S )a	  List files at given path

        Parameters
        ----------
        path: str
            Location to list, relative to repo root
        detail: bool
            If True, returns list of dicts, one per file; if False, returns
            list of full filenames only
        sha: str (optional)
            List at the given point in the repo history, branch or tag name or commit
            SHA
        _sha: str (optional)
            List this specific tree object (used internally to descend into trees)
        r   Nr4   T)r'   Ú_shac                 ó,   •— g | ]}|d          ‰k    ¯|‘ŒS r6   r   )r8   ÚoÚso_fars     €r,   r9   z'GithubFileSystem.ls.<locals>.<listcomp>�   s'   ø€ Ð=Ð=Ð=˜Q¨¨6¬°fÒ)<Ð)<�qÐ)<Ð)<Ð)<r0   r   ÚtypeÚfiler'   )r   r   r'   r   é”  Ú	directory)ÚblobÚtreec           	      ó¸   •— g | ]V}|d          ‰v ¯‰r‰dz   |d         z   n|d         |d         ‰|d                   |                      dd¦  «        |d         dœ‘ŒWS )rR   r4   ÚpathÚmodeÚsizer   r'   )r7   rZ   rR   r[   r'   )r   )r8   ÚfrY   Útypess     €€r,   r9   z'GithubFileSystem.ls.<locals>.<listcomp>±   s†   ø€ ð 
ð 
ð 
ð Ø�V”9 Ð%Ð%ð 7;ÐI˜D 3™J¨¨6¬Ñ2Ð2ÀÀ&Ä	Ø˜fœIØ! ! F¤)Ô,ØŸEšE &¨!Ñ,Ô,Ø˜Uœ8ðð ð &Ð%Ð%r0   rW   c                 ó   — g | ]
}|d          ‘ŒS r6   r   )r8   r\   s     r,   r9   z'GithubFileSystem.ls.<locals>.<listcomp>Ã   s   € Ð2Ð2Ð2¨˜1˜Vœ9Ð2Ð2Ð2r0   )Ú_strip_protocolr!   ÚrstripÚsplitr"   ÚFileNotFoundErrorÚdircacher   r   Úurlr   r   r   r   r   Ústatus_coder   r    Úsorted)r&   rY   Údetailr'   rN   r(   ÚpartsÚpartÚoutr*   rQ   r]   s    `        @@r,   r"   zGithubFileSystem.lsƒ   sE  øøø€ ð  ×#Ò# DÑ)Ô)ˆØ�2Š:ˆ:ØÐ#˜$œ)ˆDØˆ<Ø—K’K Ñ$Ô$×*Ò*¨3Ñ/Ô/ˆEØˆFØÐ#˜$œ)ˆDØð "ð "�Ø—g’g˜f d°¸$�gÑ?Ô?�Ø¨Ð8˜# ™*˜*°DÑ8�Ø=Ð=Ð=Ð= #Ð=Ñ=Ô=�Øð 2Ý+¨DÑ1Ô1Ð1Ø˜!”f�Ø�v”; &Ò(Ð(Øð $Ø #˜u˜˜˜à#˜˜˜Ø˜5”z��Ø�t”}Ð$Ð$¨°D´I¸tÐ3DÐ(DÐ(DÝ”Ø”—’ D¤H°4´9À$�ÑGÔGðð àœðð ”'ðð ˆAð
 Œ} Ò#Ð#Ý'¨Ñ-Ô-Ð-Ø×ÒÑ Ô Ð Ø#¨[Ð9Ð9ˆEð
ð 
ð 
ð 
ð 
ð Ÿš™œ &Ô)ð
ñ 
ô 
ˆCð �t”y $Ð'Ð'Ð'Ø&)�”˜dÑ#øà”- Ô%ˆCØð 	4ØˆJåÐ2Ð2¨cÐ2Ñ2Ô2Ñ3Ô3Ð3r0   c                 ó8   — | j                              ¦   «          d S ©N)rc   Úclear)r&   rY   s     r,   Úinvalidate_cachez!GithubFileSystem.invalidate_cacheÅ   s   € ØŒ×ÒÑÔÐÐÐr0   c                 ó¢   •— t          |¦  «        }d|vr!t          ¦   «                              |¦  «        S |d                              d¦  «        S )Nr   rY   r4   )r   r   r_   Úlstrip)r:   rY   Úoptsr+   s      €r,   r_   z GithubFileSystem._strip_protocolÈ   sK   ø€ å$ TÑ*Ô*ˆØ˜TÐ!Ð!Ý‘7”7×*Ò*¨4Ñ0Ô0Ð0Ø�FŒ|×"Ò" 3Ñ'Ô'Ð'r0   c                 óx   — t          | ¦  «        }d|vri S |d         |d         dœ}|d         r|d         |d<   |S )Nr   Úpasswordr   Úhostr'   r   )rY   rq   rj   s      r,   Ú_get_kwargs_from_urlsz&GithubFileSystem._get_kwargs_from_urlsÏ   sT   € å$ TÑ*Ô*ˆØ˜TÐ!Ð!ØˆIØ˜:Ô&°°ZÔ0@ÐAÐAˆØ�Œ<ð 	&Ø˜fœˆC�‰JØˆ
r0   Úrbc                 ó0  — |dk    rt           ‚| j                             | j        | j        ||p| j        ¬¦  «        }t          j        |fd| j        i| j	        ¤Ž}|j
        dk    rt          |¦  «        ‚|                     ¦   «          |                     ¦   «         }	|	d         r@t          j        |	d         ¦  «        }
|
                     d¦  «        st#          d d |
¦  «        S | j        €t'          d¦  «        ‚ | j        j        |	d         f|||d	œ|¤ŽS )
Nrv   ©r   r   rY   r'   r   rT   Úcontents#   version https://git-lfs.github.com/zRPlease install fsspec[http] to access github files >1 MB or git-lfs tracked files.Údownload_url)rZ   Ú
block_sizeÚcache_options)ÚNotImplementedErrorÚcontent_urlr   r   r   r!   r   r   r   r   re   rb   r   r    Úbase64Ú	b64decodeÚ
startswithr   r$   r%   Úopen)r&   rY   rZ   r{   r|   r'   r(   rd   r*   Úcontent_jsonry   s              r,   Ú_openzGithubFileSystem._openÙ   sR  € ð �4Š<ˆ<Ý%Ð%ð Ô×%Ò%Ø”˜tœy¨t¸Ð9IÀÄ	ð &ñ 
ô 
ˆõ
 ŒL˜Ð>Ð> d¤lÐ>°d´gÐ>Ð>ˆØŒ=˜CÒÐÝ# DÑ)Ô)Ð)Ø	×ÒÑÔÐØ—v’v‘x”xˆð ˜	Ô"ð 	7ÝÔ& |°IÔ'>Ñ?Ô?ˆGð ×%Ò%Ð&LÑMÔMð 7Ý! $¨¨gÑ6Ô6Ð6ð
 Œ<ÐÝð,ñô ð ð !ˆtŒ|Ô Ø˜Ô(ð
àØ!Ø'ð	
ð 
ð
 ð
ð 
ð 	
r0   c                 óˆ   — |                       |||¬¦  «        }t          |¦  «        D ]}|                      ||¬¦  «         Œd S )N)Ú	recursiveÚmaxdepth)Úmessage)Úexpand_pathÚreversedÚrm_file)r&   rY   r†   r‡   rˆ   Úps         r,   ÚrmzGithubFileSystem.rm  sT   € Ø×Ò °	ÀHÐÑMÔMˆÝ˜$‘”ð 	-ð 	-ˆAØ�LŠL˜ GˆLÑ,Ô,Ð,Ð,ð	-ð 	-r0   c                 óŽ  — | j         st          d¦  «        ‚|                      |¦  «        }|                      |¦  «        }|s¦| j                             | j        | j        |                     d¦  «        | j	        ¬¦  «        }t          j        |fd| j        i| j        ¤Ž}|j        dk    rt          |¦  «        ‚|                     ¦   «          |                     ¦   «         d         }| j                             | j        | j        || j	        ¬¦  «        }| j	        }|pd|› �|dœ|rd	|ini ¥}	t          j        |f|	| j        d
œ| j        ¤Ž}|                     ¦   «                              dd¦  «        }
t'          j        d|
¦  «        rd}t          |¦  «        ‚|                     ¦   «          |                      |¦  «         dS )aW  
        Remove a file from a specified branch using a given commit message.

        Since Github DELETE operation requires a branch name, and we can't reliably
        determine whether the provided SHA refers to a branch, tag, or commit, we
        assume it's a branch. If it's not, the user will encounter an error when
        attempting to retrieve the file SHA or delete the file.

        Parameters
        ----------
        path: str
            The file's location relative to the repository root.
        message: str, optional
            The commit message for the deletion.
        zAuthentication requiredr4   rx   r   rT   r'   zDelete )rˆ   r'   Úbranch)r    r   rˆ   r   zBranch .+ not foundzTRemove only works when the filesystem is initialised from a branch or default (None)N)r   r   r_   Ú_get_sha_from_cacher~   r   r   r   rp   r!   r   r   r   r   re   rb   r   r    ÚdeleteÚreÚsearchrn   )r&   rY   rˆ   r(   r'   rd   r*   Ú
delete_urlr�   ÚdataÚerror_messageÚerrors               r,   r‹   zGithubFileSystem.rm_file  sè  € ð" Œ}ð 	8ÝÐ6Ñ7Ô7Ð7à×#Ò# DÑ)Ô)ˆð ×&Ò& tÑ,Ô,ˆØð 	"ØÔ"×)Ò)Ø”H 4¤9°4·;²;¸sÑ3CÔ3CÈÌð *ñ ô ˆCõ ”˜SÐBÐB¨$¬,ÐB¸$¼'ÐBÐBˆAØŒ} Ò#Ð#Ý'¨Ñ-Ô-Ð-Ø×ÒÑ Ô Ð Ø—&’&‘(”(˜5”/ˆCð Ô%×,Ò,Ø”˜tœy¨t¸¼ð -ñ 
ô 
ˆ
ð ”ˆàÐ2Ð"2¨DÐ"2Ð"2Øð
ð 
ð &,Ð3�˜&Ð!Ð!°ð
ˆõ ŒO˜JÐS¨T¸4¼<ÐSÐSÈ4Ì7ÐSÐSˆØŸš™œŸš Y°Ñ3Ô3ˆÝŒ9Ð+¨]Ñ;Ô;ð 	$ØjˆEÝ˜UÑ#Ô#Ð#Ø	×ÒÑÔÐà×Ò˜dÑ#Ô#Ð#Ð#Ð#r0   c                 ó¢   — | j                              ¦   «         D ]4}|D ]/}|                     d¦  «        }|r||k    rd|v r|d         c c S Œ0Œ5d S )Nr7   r'   )rc   Úvaluesr   )r&   rY   ÚentriesÚentryÚ
entry_paths        r,   r�   z$GithubFileSystem._get_sha_from_cacheG  s|   € Ø”}×+Ò+Ñ-Ô-ð 	(ð 	(ˆGØ ð (ð (�Ø"ŸYšY vÑ.Ô.�
Øð ( *°Ò"4Ð"4¸À%¸¸Ø  œ<Ð'Ð'Ð'Ð'Ð'øð(ð ˆtr0   )NNNN)T)FNNrl   )rv   NNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rd   r~   Úprotocolr   r   Úpropertyr   Úclassmethodr=   rF   rI   rL   r"   rn   r_   Ústaticmethodru   r„   r�   r‹   r�   Ú__classcell__)r+   s   @r,   r
   r
      s¹  ø€ € € € € ðð ð6 F€CØW€KØ€HØ€Gð GKð ð  ð  ð  ð  ð  ð< ðð ñ „Xðð
 ð3ð 3ð 3ñ „[ð3ð. ð-ð -ñ „Xð-ð ð-ð -ñ „Xð-ð ð>ð >ñ „Xð>ð@4ð @4ð @4ð @4ðDð ð ð ð ð(ð (ð (ð (ñ „[ð(ð ðð ñ „\ðð ØØØð1
ð 1
ð 1
ð 1
ðf-ð -ð -ð -ð
4$ð 4$ð 4$ð 4$ðlð ð ð ð ð ð r0   r
   )
r   r’   r   Úspecr   Úutilsr   Úmemoryr   r
   r   r0   r,   ú<module>r©      s•   ðØ €€€Ø 	€	€	€	à €€€à %Ð %Ð %Ð %Ð %Ð %Ø )Ð )Ð )Ð )Ð )Ð )Ø Ð Ð Ð Ð Ð ðBð Bð Bð Bð BÐ)ñ Bô Bð Bð Bð Br0   