Ë
    #täiµD  ã                   óÐ   — d dl Z d dlZd dlZ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
 d dlZddlmZmZ ddlmZmZ  e j$                  d«      Z G d	„ d
e«      Z G d„ de«      Zy)é    N)Úsuppress)Údatetime)Úquoteé   )ÚAbstractBufferedFileÚAbstractFileSystem)Úinfer_storage_optionsÚtokenizeÚwebhdfsc                   óN  ‡ — e Zd ZdZ e ej                  «       «      ZdZ	 	 	 	 	 	 	 	 	 	 	 dˆ fd„	Z	e
d„ «       Zd„ Zd d„Z	 	 	 	 	 d!d„Zed„ «       Zed	„ «       Zed
„ «       Zd„ Zd„ Zd„ Zd"d„Zd„ Zd„ Zd„ Zd#d„Zd„ Zd„ Zd„ Zd$d„Zd„ Z d„ Z!d"d„Z"d„ Z#d"d„Z$d„ Z%d„ Z&d„ Z'ˆ xZ(S )%ÚWebHDFSaà  
    Interface to HDFS over HTTP using the WebHDFS API. Supports also HttpFS gateways.

    Four auth mechanisms are supported:

    insecure: no auth is done, and the user is assumed to be whoever they
        say they are (parameter ``user``), or a predefined value such as
        "dr.who" if not given
    spnego: when kerberos authentication is enabled, auth is negotiated by
        requests_kerberos https://github.com/requests/requests-kerberos .
        This establishes a session based on existing kinit login and/or
        specified principal/password; parameters are passed with ``kerb_kwargs``
    token: uses an existing Hadoop delegation token from another secured
        service. Indeed, this client can also generate such tokens when
        not insecure. Note that tokens expire, but can be renewed (by a
        previously specified user) and may allow for proxying.
    basic-auth: used when both parameter ``user`` and parameter ``password``
        are provided.

    )r   ÚwebHDFSc                 óî  •— | j                   ryt        ‰| �  di |¤Ž |
rdnd› d|› d|› d�| _        || _        |xs i | _        i | _        |	xs i | _        |�|€|�t        d«      ‚|| j                  d<   || _	        || _
        |�|€t        d	«      ‚|�|| j                  d
<   |�|| j                  d<   |r|�t        d«      ‚|| _        || _        | j                  «        dt        ||«      › �| _        y)a¢  
        Parameters
        ----------
        host: str
            Name-node address
        port: int
            Port for webHDFS
        kerberos: bool
            Whether to authenticate with kerberos for this connection
        token: str or None
            If given, use this token on every call to authenticate. A user
            and user-proxy may be encoded in the token and should not be also
            given
        user: str or None
            If given, assert the user name to connect with
        password: str or None
            If given, assert the password to use for basic auth. If password
            is provided, user must be provided also
        proxy_to: str or None
            If given, the user has the authority to proxy, and this value is
            the user in who's name actions are taken
        kerb_kwargs: dict
            Any extra arguments for HTTPKerberosAuth, see
            `<https://github.com/requests/requests-kerberos/blob/master/requests_kerberos/kerberos_.py>`_
        data_proxy: dict, callable or None
            If given, map data-node addresses. This can be necessary if the
            HDFS cluster is behind a proxy, running on Docker or otherwise has
            a mismatch between the host-names given by the name-node and the
            address by which to refer to them from the client. If a dict,
            maps host names ``host->data_proxy[host]``; if a callable, full
            URLs are passed, and function must conform to
            ``url->data_proxy(url)``.
        use_https: bool
            Whether to connect to the Name-node using HTTPS instead of HTTP
        session_cert: str or Tuple[str, str] or None
            Path to a certificate file, or tuple of (cert, key) files to use
            for the requests.Session
        session_verify: str, bool or None
            Path to a certificate file to use for verifying the requests.Session.
        kwargs
        NÚhttpsÚhttpz://Ú:z/webhdfs/v1z_If passing a delegation token, must not set user or proxy_to, as these are encoded in the tokenÚ
delegationzQIf passing a password, the user must also beset in order to set up the basic-authz	user.nameÚdoaszJIf using Kerberos auth, do not specify the user, this is handled by kinit.Úwebhdfs_© )Ú_cachedÚsuperÚ__init__ÚurlÚkerbÚkerb_kwargsÚparsÚproxyÚ
ValueErrorÚuserÚpasswordÚsession_certÚsession_verifyÚ_connectr
   Ú_fsid)ÚselfÚhostÚportÚkerberosÚtokenr    r!   Úproxy_tor   Ú
data_proxyÚ	use_httpsr"   r#   ÚkwargsÚ	__class__s                 €úm/Volumes/fast/ai/experiments/MLX_z-image/.venv/lib/python3.12/site-packages/fsspec/implementations/webhdfs.pyr   zWebHDFS.__init__.   s9  ø€ ðr �<Š<ØÜ‰ÑÑ"˜6Ò"Ù!*‘g°Ð7°s¸4¸&ÀÀ$ÀÀ{ÐSˆŒØˆŒ	Ø&Ò,¨"ˆÔØˆŒ	ØÒ% 2ˆŒ
ØÐØÐ 8Ð#7Ü ðóð ð
 ',ˆD�I‰I�lÑ#ØˆŒ	Ø ˆŒàÐØˆ|Ü ð<óð ð
 ÐØ)-�—	‘	˜+Ñ&àÐØ (ˆD�I‰I�fÑÙ˜Ð(Üð2óð ð
 )ˆÔØ,ˆÔà�‰Œà¤¨¨tÓ 4Ð5Ð6ˆ�
ó    c                 ó   — | j                   S ©N)r%   ©r&   s    r0   ÚfsidzWebHDFS.fsid“   s   € à�z‰zÐr1   c                 ó¸  — t        j                  «       | _        | j                  r| j                  | j                  _        | j
                  | j                  _        | j                  r'ddlm	}  |di | j                  ¤Ž| j                  _        | j                  �@| j                  �3ddlm}  || j                  | j                  «      | j                  _        y y y )Nr   )ÚHTTPKerberosAuth)ÚHTTPBasicAuthr   )ÚrequestsÚSessionÚsessionr"   Úcertr#   Úverifyr   Úrequests_kerberosr7   r   Úauthr    r!   Úrequests.authr8   )r&   r7   r8   s      r0   r$   zWebHDFS._connect—   sœ   € Ü×'Ñ'Ó)ˆŒà×ÒØ $× 1Ñ 1ˆD�L‰LÔà"×1Ñ1ˆ�‰Ôà�9Š9Ý:á 0Ñ D°4×3CÑ3CÑ DˆD�L‰LÔà�9‰9Ð  T§]¡]Ð%>Ý3á -¨d¯i©i¸¿¹Ó GˆD�L‰LÕð &?Ð r1   c                 ó   — |�| j                  |«      nd}| j                  | j                  t        |d¬«      z   «      }|j	                  «       }|j                  | j                  «       |j                  «       |d<   t        j                  d||«       | j                  j                  |j                  «       ||||¬«      }	|	j                  dv rY	 |	j                  «       }
|
d   d	   }|
d   d
   }|dv rt        |«      ‚|dv rt        |«      ‚|dv rt!        |«      ‚t#        |«      ‚|	j'                  «        |	S # t        t$        f$ r Y Œ#w xY w)NÚ z/=)ÚsafeÚopzsending %s with %s)Úmethodr   ÚparamsÚdataÚallow_redirects)i�  i‘  i“  i”  iô  ÚRemoteExceptionÚmessageÚ	exception)ÚIllegalArgumentExceptionÚUnsupportedOperationException)ÚSecurityExceptionÚAccessControlException)ÚFileNotFoundException)Ú_strip_protocolÚ_apply_proxyr   r   ÚcopyÚupdater   ÚupperÚloggerÚdebugr;   ÚrequestÚstatus_codeÚjsonr   ÚPermissionErrorÚFileNotFoundErrorÚRuntimeErrorÚKeyErrorÚraise_for_status)r&   rD   rE   ÚpathrG   Úredirectr.   r   ÚargsÚoutÚerrÚmsgÚexps                r0   Ú_callzWebHDFS._call©   sS  € Ø-1Ð-=ˆt×#Ñ# DÔ)À2ˆØ×Ñ §¡¬5°¸DÔ+AÑ AÓBˆØ�{‰{‹}ˆØ�‰�D—I‘IÔØ—X‘X“ZˆˆT‰
Ü�‰Ð)¨3°Ô7Ø�l‰l×"Ñ"Ø—<‘<“>ØØØØ$ð #ó 
ˆð �?‰?Ð7Ñ7ð,Ø—h‘h“j�ØÐ+Ñ,¨YÑ7�ØÐ+Ñ,¨[Ñ9�ð ÐWÑWÜ$ S›/Ð)ØÐKÑKÜ)¨#Ó.Ð.ØÐ5Ñ5Ü+¨CÓ0Ð0ä& sÓ+Ð+Ø×ÑÔØˆ
øô ¤Ð)ò Ùðús   Ã D; Ä;EÅEc           
      ó\   — |xs | j                   }t        | |||| j                  |||¬«      S )a^  

        Parameters
        ----------
        path: str
            File location
        mode: str
            'rb', 'wb', etc.
        block_size: int
            Client buffer size for read-ahead or write buffer
        autocommit: bool
            If False, writes to temporary file that only gets put in final
            location upon commit
        replication: int
            Number of copies of file on the cluster, write mode only
        permissions: str or int
            posix permissions, write mode only
        kwargs

        Returns
        -------
        WebHDFile instance
        )ÚmodeÚ
block_sizeÚtempdirÚ
autocommitÚreplicationÚpermissions)Ú	blocksizeÚ	WebHDFilerk   )r&   r`   ri   rj   rl   rm   rn   r.   s           r0   Ú_openzWebHDFS._openÊ   s<   € ðB  Ò1 4§>¡>ˆ
ÜØØØØ!Ø—L‘LØ!Ø#Ø#ô	
ð 		
r1   c                 óB   — | d   j                  «       | d<   | d   | d<   | S )NÚtypeÚlengthÚsize)Úlower)Úinfos    r0   Ú_process_infozWebHDFS._process_info÷   s*   € à˜F‘|×)Ñ)Ó+ˆˆV‰Ø˜H‘~ˆˆV‰Øˆr1   c                 ó   — t        |«      d   S )Nr`   )r	   )Úclsr`   s     r0   rQ   zWebHDFS._strip_protocolý   s   € ä$ TÓ*¨6Ñ2Ð2r1   c                 ó”   — t        | «      }|j                  dd «       |j                  dd «       d|v r|j                  d«      |d<   |S )Nr`   ÚprotocolÚusernamer    )r	   Úpop)Úurlpathrc   s     r0   Ú_get_kwargs_from_urlszWebHDFS._get_kwargs_from_urls  sG   € ä# GÓ,ˆØ�‰�˜ÔØ�‰�
˜DÔ!Ø˜ÑØŸ'™' *Ó-ˆC�‰KØˆ
r1   c                 óz   — | j                  d|¬«      }|j                  «       d   }||d<   | j                  |«      S )NÚGETFILESTATUS©r`   Ú
FileStatusÚname)rg   rZ   rx   )r&   r`   rc   rw   s       r0   rw   zWebHDFS.info
  s>   € Ø�j‰j˜¨tˆjÓ4ˆØ�x‰x‹z˜,Ñ'ˆØˆˆV‰Ø×!Ñ! $Ó'Ð'r1   c                 ó’   — | j                  |«      }|j                  dd«      }|�t        j                  |dz  «      S t	        d«      ‚)z=Return the created timestamp of a file as a datetime.datetimeÚmodificationTimeNéè  z5Could not retrieve creation time (modification time).©rw   Úgetr   Úfromtimestampr]   ©r&   r`   rw   Úmtimes       r0   ÚcreatedzWebHDFS.created  sI   € ð �y‰y˜‹ˆØ—‘Ð+¨TÓ2ˆØÐÜ×)Ñ)¨%°$©,Ó7Ð7ÜÐRÓSÐSr1   c                 ó’   — | j                  |«      }|j                  dd«      }|�t        j                  |dz  «      S t	        d«      ‚)z>Return the modified timestamp of a file as a datetime.datetimer‡   Nrˆ   z%Could not retrieve modification time.r‰   rŒ   s       r0   ÚmodifiedzWebHDFS.modified  sG   € à�y‰y˜‹ˆØ—‘Ð+¨TÓ2ˆØÐÜ×)Ñ)¨%°$©,Ó7Ð7ÜÐBÓCÐCr1   c                 ó  — | j                  d|¬«      }|j                  «       d   d   }|D ]0  }| j                  |«       |j                  d«      dz   |d   z   |d<   Œ2 |rt	        |d„ ¬	«      S t	        d
„ |D «       «      S )NÚ
LISTSTATUSrƒ   ÚFileStatusesr„   Ú/Ú
pathSuffixr…   c                 ó   — | d   S )Nr…   r   )Úis    r0   Ú<lambda>zWebHDFS.ls.<locals>.<lambda>(  s   € ¨q°ªyr1   )Úkeyc              3   ó&   K  — | ]	  }|d    –— Œ y­w)r…   Nr   )Ú.0rw   s     r0   Ú	<genexpr>zWebHDFS.ls.<locals>.<genexpr>*  s   è ø€ Ð9±5¨4˜$˜v�,±5ùs   ‚)rg   rZ   rx   ÚrstripÚsorted)r&   r`   Údetailr.   rc   Úinfosrw   s          r0   Úlsz
WebHDFS.ls!  s†   € Ø�j‰j˜¨DˆjÓ1ˆØ—‘“
˜>Ñ*¨<Ñ8ˆÛˆDØ×Ñ˜tÔ$ØŸ;™; sÓ+¨cÑ1°D¸Ñ4FÑFˆD�ŠLð ñ Ü˜%Ñ%8Ô9Ð9äÑ9±5Ó9Ó9Ð9r1   c                 óN   — | j                  d|¬«      }|j                  «       d   S )z8Total numbers of files, directories and bytes under pathÚGETCONTENTSUMMARYrƒ   ÚContentSummary©rg   rZ   )r&   r`   rc   s      r0   Úcontent_summaryzWebHDFS.content_summary,  s'   € à�j‰jÐ,°4ˆjÓ8ˆØ�x‰x‹zÐ*Ñ+Ð+r1   c                 óD  — | j                  d|d¬«      }d|j                  v r\| j                  |j                  d   «      }| j                  j	                  |«      }|j                  «        |j                  «       d   S |j                  «        |j                  «       d   S )z/Checksum info of file, giving method and resultÚGETFILECHECKSUMF)r`   ra   ÚLocationÚFileChecksum)rg   ÚheadersrR   r;   rŠ   r_   rZ   )r&   r`   rc   ÚlocationÚout2s        r0   ÚukeyzWebHDFS.ukey1  sŠ   € à�j‰jÐ*°ÀˆjÓFˆØ˜Ÿ™Ñ$Ø×(Ñ(¨¯©°ZÑ)@ÓAˆHØ—<‘<×#Ñ# HÓ-ˆDØ×!Ñ!Ô#Ø—9‘9“;˜~Ñ.Ð.à× Ñ Ô"Ø—8‘8“:˜nÑ-Ð-r1   c                 óJ   — | j                  d«      }|j                  «       d   S )zGet user's home directoryÚGETHOMEDIRECTORYÚPathr¥   )r&   rc   s     r0   Úhome_directoryzWebHDFS.home_directory=  s"   € à�j‰jÐ+Ó,ˆØ�x‰x‹z˜&Ñ!Ð!r1   c                 óš   — |r| j                  d|¬«      }n| j                  d«      }|j                  «       d   }|€t        d«      ‚|d   S )zÒRetrieve token which can give the same authority to other uses

        Parameters
        ----------
        renewer: str or None
            User who may use this token; if None, will be current user
        ÚGETDELEGATIONTOKEN)ÚrenewerÚTokenz1No token available for this user/security contextÚ	urlString)rg   rZ   r   )r&   rµ   rc   Úts       r0   Úget_delegation_tokenzWebHDFS.get_delegation_tokenB  sT   € ñ Ø—*‘*Ð1¸7�*ÓC‰Cà—*‘*Ð1Ó2ˆCØ�H‰H‹J�wÑˆØˆ9ÜÐPÓQÐQØ�‰~Ðr1   c                 óP   — | j                  dd|¬«      }|j                  «       d   S )z/Make token live longer. Returns new expiry timeÚRENEWDELEGATIONTOKENÚput©rE   r*   Úlongr¥   )r&   r*   rc   s      r0   Úrenew_delegation_tokenzWebHDFS.renew_delegation_tokenS  s(   € à�j‰jÐ/¸ÀUˆjÓKˆØ�x‰x‹z˜&Ñ!Ð!r1   c                 ó,   — | j                  dd|¬«       y)z Stop the token from being usefulÚCANCELDELEGATIONTOKENr¼   r½   N©rg   )r&   r*   s     r0   Úcancel_delegation_tokenzWebHDFS.cancel_delegation_tokenX  s   € à�
‰
Ð*°5Àˆ
ÕFr1   c                 ó.   — | j                  dd||¬«       y)a  Set the permission at path

        Parameters
        ----------
        path: str
            location to set (file or directory)
        mod: str or int
            posix epresentation or permission, give as oct string, e.g, '777'
            or 0o777
        ÚSETPERMISSIONr¼   )rE   r`   Ú
permissionNrÂ   )r&   r`   Úmods      r0   ÚchmodzWebHDFS.chmod\  s   € ð 	�
‰
�?¨5°tÈˆ
ÕLr1   c                 óN   — i }|�||d<   |�||d<    | j                   dd|dœ|¤Ž y)zChange owning user and/or groupNÚownerÚgroupr¼   ©rE   r`   )ÚSETOWNERrÂ   )r&   r`   rÊ   rË   r.   s        r0   ÚchownzWebHDFS.chowni  s=   € àˆØÐØ#ˆF�7‰OØÐØ#ˆF�7‰OØˆ�
‰
ÐA e°$ÑA¸&ÓAr1   c                 ó.   — | j                  d|d|¬«       y)a9  
        Set file replication factor

        Parameters
        ----------
        path: str
            File location (not for directories)
        replication: int
            Number of copies of file on the cluster. Should be smaller than
            number of data nodes; normally 3 on most systems.
        ÚSETREPLICATIONr¼   )r`   rE   rm   NrÂ   )r&   r`   rm   s      r0   Úset_replicationzWebHDFS.set_replicationr  s   € ð 	�
‰
Ð#¨$°uÈ+ˆ
ÕVr1   c                 ó,   — | j                  dd|¬«       y )NÚMKDIRSr¼   rÌ   rÂ   ©r&   r`   r.   s      r0   ÚmkdirzWebHDFS.mkdir€  s   € Ø�
‰
�8 E°ˆ
Õ5r1   c                 óf   — |du r| j                  |«      rt        |«      ‚| j                  |«       y )NF)ÚexistsÚFileExistsErrorrÕ   )r&   r`   Úexist_oks      r0   ÚmakedirszWebHDFS.makedirsƒ  s,   € Ø�uÑ §¡¨TÔ!2Ü! $Ó'Ð'Ø�
‰
�4Õr1   c                 ó.   — | j                  dd||¬«       y )NÚRENAMEr¼   )rE   r`   ÚdestinationrÂ   )r&   Úpath1Úpath2r.   s       r0   Úmvz
WebHDFS.mvˆ  s   € Ø�
‰
�8 E°À5ˆ
ÕIr1   c                 óB   — | j                  dd||rd¬«       y d¬«       y )NÚDELETEÚdeleteÚtrueÚfalse)rE   r`   Ú	recursiverÂ   )r&   r`   ræ   r.   s       r0   Úrmz
WebHDFS.rm‹  s0   € Ø�
‰
ØØØÙ )�fð	 	õ 	
ð 07ð	 	õ 	
r1   c                 ó&   — | j                  |«       y r3   )rç   rÔ   s      r0   Úrm_filezWebHDFS.rm_file“  s   € Ø�‰��r1   c                 óè  — | j                  |«      5 }dj                  | j                  |«      dt        j                  d«      › �g«      }	 | j                  |d«      5 }t        j                  ||«       d d d «       | j                  ||«       	 d d d «       y # 1 sw Y   Œ%xY w# t        $ r7 t        t        «      5  | j                  |«       d d d «       ‚ # 1 sw Y   ‚ xY ww xY w# 1 sw Y   y xY w)Nr”   z.tmp.é   Úwb)ÚopenÚjoinÚ_parentÚsecretsÚ	token_hexÚshutilÚcopyfileobjrà   ÚBaseExceptionr   r\   rç   )r&   ÚlpathÚrpathr.   ÚlstreamÚ	tmp_fnameÚrstreams          r0   Úcp_filezWebHDFS.cp_file–  sÈ   € Ø�Y‰Y�uÔ ØŸ™ $§,¡,¨uÓ"5¸¼w×?PÑ?PÐQSÓ?TÐ>UÐ7VÐ!WÓXˆIðØ—Y‘Y˜y¨$Ô/°7Ü×&Ñ& w°Ô8÷ 0à—‘˜	 5Õ)÷ Ð÷
 0Ð/ûô !ò ÜÔ/Õ0Ø—G‘G˜IÔ&÷ 1à÷ 1àúðú÷ ÐúsM   ’9C(ÁB%ÁBÁ5B%ÂB"	ÂB%Â%C%Â=CÃ	C%ÃC!ÃC%Ã%C(Ã(C1c                 óð   — | j                   r(t        | j                   «      r| j                  |«      }|S | j                   r5| j                   j                  «       D ]  \  }}|j                  ||d«      }Œ |S )Né   )r   ÚcallableÚitemsÚreplace)r&   r¬   ÚkÚvs       r0   rR   zWebHDFS._apply_proxy¤  sf   € Ø�:Š:œ( 4§:¡:Ô.Ø—z‘z (Ó+ˆHð
 ˆð	 �ZŠZàŸ
™
×(Ñ(Ö*‘��1Ø#×+Ñ+¨A¨q°!Ó4‘ð +àˆr1   )i–Ã  FNNNNNNFNT)rŠ   NNT)ÚrbNTNN©Fr3   )NN))Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚtempfileÚ
gettempdirrk   r|   r   Úpropertyr5   r$   rg   rq   Ústaticmethodrx   ÚclassmethodrQ   r€   rw   rŽ   r�   r¡   r¦   r®   r²   r¹   r¿   rÃ   rÈ   rÎ   rÑ   rÕ   rÚ   rà   rç   ré   rú   rR   Ú__classcell__©r/   s   @r0   r   r      s-  ø„ ññ* Ð%�(×%Ñ%Ó'Ó(€GØ#€Hð
 ØØØØØØØØØØõc7ðJ ñó ðòHó$ðH ØØØØó+
ðZ ñó ðð
 ñ3ó ð3ð ñó ðò(òTòDó	:ò,ò

.ò"ó
ò""ò
GòMóBòWò6óò
Jó
òòör1   r   c                   óB   ‡ — e Zd ZdZˆ fd„Zdd„Zd„ Zd„ Zd„ Zd„ Z	ˆ xZ
S )	rp   z"A file living in HDFS over webHDFSc                 óô  •— t        ‰| �  ||fi |¤Ž |j                  «       }|j                  dd «      €|j	                  dd «       |j                  dd «      €|j	                  dd «       |j	                  dd«      | _        |j	                  d«      }|j	                  dd«      du rR| j                  | _        t        j                  j                  |t        t        j                  «       «      «      | _        y y )Nrn   rm   iÿ  rk   rl   F)r   r   rS   rŠ   r~   rn   r`   ÚtargetÚosrî   r  ÚuuidÚuuid4)r&   Úfsr`   r.   rk   r/   s        €r0   r   zWebHDFile.__init__±  sÅ   ø€ Ü‰Ñ˜˜TÑ, VÒ,Ø—‘“ˆØ�:‰:�m TÓ*Ð2Ø�J‰J�} dÔ+Ø�:‰:�m TÓ*Ð2Ø�J‰J�} dÔ+Ø!Ÿ:™: m°SÓ9ˆÔØ—*‘*˜YÓ'ˆØ�:‰:�l EÓ*¨eÑ3ØŸ)™)ˆDŒKÜŸ™Ÿ™ W¬c´$·*±*³,Ó.?Ó@ˆD�Ið 4r1   c                 ó¼   — | j                   j                  j                  | j                  | j                  j                  «       ddi¬«      }|j                  «        y)zÔWrite one part of a multi-block file upload

        Parameters
        ==========
        final: bool
            This is the last block, so should complete file, if
            self.autocommit is True.
        úcontent-typeúapplication/octet-stream)rG   r«   T)r  r;   Úpostr¬   ÚbufferÚgetvaluer_   )r&   Úfinalrc   s      r0   Ú_upload_chunkzWebHDFile._upload_chunk¾  sR   € ð �g‰g�o‰o×"Ñ"Ø�M‰MØ—‘×%Ñ%Ó'Ø#Ð%?Ð@ð #ó 
ˆð
 	×ÑÔØr1   c                 óZ  — | j                   j                  «       }d| j                  v rd\  }}n
d\  }}d|d<    | j                  j                  ||| j
                  fddi|¤Ž}| j                  j                  |j                  d   «      }d	| j                  v r’| j                  j                  j                  |d
di¬«      }|j                  «         | j                  j                  dd| j
                  fddi|¤Ž}| j                  j                  |j                  d   «      | _        yy)zCreate remote file/uploadÚa)ÚAPPENDÚPOST)ÚCREATEÚPUTrä   Ú	overwritera   Fr©   Úwr  r  )r«   r!  r"  N)r.   rS   ri   r  rg   r`   rR   r«   r;   r¼   r_   r¬   )r&   r.   rD   rE   rc   r¬   r­   s          r0   Ú_initiate_uploadzWebHDFile._initiate_uploadÏ  s  € à—‘×!Ñ!Ó#ˆØ�$—)‘)ÑØ)‰JˆB‘à(‰JˆB�Ø"(ˆF�;ÑØˆd�g‰g�m‰m˜B ¨¯	©	ÑL¸EÐLÀVÑLˆØ—7‘7×'Ñ'¨¯©°JÑ(?Ó@ˆØ�$—)‘)Ñà—7‘7—?‘?×&Ñ&Ø >Ð3MÐ"Nð 'ó ˆDð ×!Ñ!Ô#à �4—7‘7—=‘= ¨6°4·9±9ÑWÀuÐWÐPVÑWˆDØ ŸG™G×0Ñ0°·±¸jÑ1IÓJˆD�Mð r1   c                 óÐ  — t        |d«      }t        | j                  |«      }||k\  s|| j                  k\  ry| j                  j	                  d| j
                  |||z
  d¬«      }|j                  «        d|j                  v rY|j                  d   }| j                  j                  j                  | j                  j                  |«      «      }|j                  S |j                  S )Nr   r1   ÚOPENF)r`   Úoffsetrt   ra   r©   )ÚmaxÚminru   r  rg   r`   r_   r«   r;   rŠ   rR   Úcontent)r&   ÚstartÚendrc   r¬   r­   s         r0   Ú_fetch_rangezWebHDFile._fetch_rangeã  s¿   € Ü�E˜1“ˆÜ�$—)‘)˜SÓ!ˆØ�CŠ<˜5 D§I¡IÒ-ØØ�g‰g�m‰mØ˜Ÿ™¨5¸¸u¹Èuð ó 
ˆð 	×ÑÔØ˜Ÿ™Ñ$Ø—{‘{ :Ñ.ˆHØ—7‘7—?‘?×&Ñ& t§w¡w×';Ñ';¸HÓ'EÓFˆDØ—<‘<Ðà—;‘;Ðr1   c                 ód   — | j                   j                  | j                  | j                  «       y r3   )r  rà   r`   r  r4   s    r0   ÚcommitzWebHDFile.commitó  s   € Ø�‰�
‰
�4—9‘9˜dŸk™kÕ*r1   c                 óN   — | j                   j                  | j                  «       y r3   )r  rç   r`   r4   s    r0   ÚdiscardzWebHDFile.discardö  s   € Ø�‰�
‰
�4—9‘9Õr1   r  )r  r  r  r  r   r  r'  r0  r2  r4  r  r  s   @r0   rp   rp   ®  s&   ø„ Ù,ôAóò"Kò(ò +ör1   rp   )Úloggingr  rð   rò   r	  r  Ú
contextlibr   r   Úurllib.parser   r9   Úspecr   r   Úutilsr	   r
   Ú	getLoggerrV   r   rp   r   r1   r0   Ú<module>r;     s\   ðó Û 	Û Û Û Û Ý Ý Ý ã ç ;ß 3à	ˆ×	Ñ	˜9Ó	%€ôVÐ ô VôrIÐ$õ Ir1   