� <��g�r����ddlZddlZddlZddlZddlZddlmZddlmZddlZddl Z ddl m Z m Z m Z mZddlmZddlmZddlmZddlmZmZmZmZmZd d lmZejd ��Zejd ��Zej d ��Z!d�Z"Gd�de ��Z#Gd�de��Z$ejd��Z%d�Z&Gd�de��Z'Gd�de ��Z(dd�Z)dd�Z*dd�Z+ee+��Z,dS)�N)�copy)�urlparse)�AbstractAsyncStreamedFile�AsyncFileSystem�sync� sync_wrapper)�DEFAULT_CALLBACK)�FSTimeoutError)�AbstractBufferedFile)�DEFAULT_BLOCK_SIZE�glob_translate� isfilelike� nullcontext�tokenize�)�AllBytesz6<(a|A)\s+(?:[^>]*?\s+)?(href|HREF)=["'](?P<url>[^"']+)z-(?P<url>http[s]?://[-a-zA-Z0-9@:%_+.~#?&/=]+)z fsspec.httpc��(K�tjdi|��S)N�)�aiohttp� ClientSession)�kwargss �k/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/fsspec/implementations/http.py� get_clientr s���� � � *� *�6� *� *�*�c �8��eZdZdZdZdddddddddedf �fd� Zed���Zd �Z e d ���Z d �Z e d ���Ze �fd ���Zd d�Zd d�Zee��Zd�Zd!d�Zdefd�Zdeddfd�Zd�Zd�Z d"d�Zd#d�Zd�Zd�Zd$d�Zd�Z �xZ!S)%�HTTPFileSystema2 Simple File-System for fetching data via HTTP(S) ``ls()`` is implemented by loading the parent page and doing a regex match on the result. If simple_link=True, anything of the form "http(s)://server.com/stuff?thing=other"; otherwise only links within HTML href tags will be used. �/TN�bytesFc  ����t��j|f||d�| ��|�|nt|_||_||_||_||_| pi|_| |_ | |_ | |_ d|_ t| ��} | �dd��|_| �dd��| �dd��| �dd��| |_ dS)a� NB: if this is called async, you must await set_client Parameters ---------- block_size: int Blocks to read bytes; if 0, will default to raw requests file-like objects instead of HTTPFile instances simple_links: bool If True, will consider both HTML <a> tags and anything that looks like a URL; if False, will consider only the former. same_scheme: True When doing ls/glob, if this is True, only consider paths that have http/https matching the input URLs. size_policy: this argument is deprecated client_kwargs: dict Passed to aiohttp.ClientSession, see https://docs.aiohttp.org/en/stable/client_reference.html For example, ``{'auth': aiohttp.BasicAuth('user', 'pass')}`` get_client: Callable[..., aiohttp.ClientSession] A callable which takes keyword arguments and constructs an aiohttp.ClientSession. It's state will be managed by the HTTPFileSystem class. storage_options: key-value Any other parameters passed on to requests cache_type, cache_options: defaults used in open )� asynchronous�loopN�use_listings_cacheF�listings_expiry_time� max_paths�skip_instance_cache)�super�__init__r � block_size� simple_links� same_schema� cache_type� cache_options� client_kwargsr�encodedr�_sessionr�popr")�selfr)r(� same_scheme� size_policyr+r,r r!r-rr.�storage_options�request_options� __class__s �rr'zHTTPFileSystem.__init__0s����T ������W�L�t�W�W��W�W�W�(2�(>�*�*�DV���(���&���$���*���*�0�b���$����� �%�� ��� � ��/�/��"1�"5�"5�6J�E�"R�"R������2�D�9�9�9����K��.�.�.����1�4�8�8�8�%�� � � rc��dS)N�httpr�r1s r�fsidzHTTPFileSystem.fsidqs���vrc�8�tj||j���S)N)r.)�yarl�URLr.�r1�urls r� encode_urlzHTTPFileSystem.encode_urlus���x��T�\�2�2�2�2rc���|�K|���r7 t||jd���dS#ttt f$rYnwxYwt |dd��}|�|���dSdS)Ng�������?)�timeout� _connector)� is_runningr�close� TimeoutErrorr �NotImplementedError�getattr�_close)r!�session� connectors r� close_sessionzHTTPFileSystem.close_sessionxs��� � ���� 1� 1� � ��T�7�=�#�6�6�6�6���� �.�2E�F� � � ��� �����G�\�4�8�8� � � � � � � � � � � � !� s�1�A � A c���K�|j�Q|jdd|ji|j���d{V��|_|js&t j||j|j|j��|jS)Nr!r)r/rr!r-r �weakref�finalizerLr9s r� set_sessionzHTTPFileSystem.set_session�su���� �=� �"1�$�/�"W�"W�t�y�"W�D�DV�"W�"W�W�W�W�W�W�W�D�M��$� U�� ��t�'9�4�9�d�m�T�T�T��}�rc��|S)z-For HTTP, we always want to keep the full URLr)�cls�paths r�_strip_protocolzHTTPFileSystem._strip_protocol�s ��� rc�t��t���|��}t|��dkr|SdS)N��)r&�_parent�len)rRrS�parr6s �rrXzHTTPFileSystem._parent�s3����g�g�o�o�d�#�#�� �s�8�8�a�<�<��J��rrc ��K�|j���}|�|��t�|��|����d{V��}|j|�|��fi|j��4�d{V��}|�||�� |� ���d{V��}|j r@t� |��d�t� |��D��z}n$d�t� |��D��}n#t$rg}YnwxYwddd���d{V��n#1�d{V��swxYwYt��} t!|��} |D�]v} t#| t$��r| d} | �d��r&t)| ��dkr| j�d| j�| ��} | �d��r�|jrA| �|�d��dz��r| �| ����| �dd���|�dd���d��dz��r| �| ����"| dvrP| �d�|�d��| �d��g������x| sE|�d��r0|�|�d��d � ���d{V��} |r d �| D��St?| ��S) Nc��g|] }|d�� S�rr��.0�us r� <listcomp>z+HTTPFileSystem._ls_real.<locals>.<listcomp>�s��0P�0P�0P�!��1��0P�0P�0Prc��g|] }|d�� Sr]rr^s rraz+HTTPFileSystem._ls_real.<locals>.<listcomp>�s��<�<�<�a�Q�q�T�<�<�<r�rz://r8�https)z..z../F)�detailc�H�g|]}|d|�d��rdndd��� S)Nr� directory�file��name�size�type)�endswithr^s rraz+HTTPFileSystem._ls_real.<locals>.<listcomp>�sM����� � � �+,�:�:�c�?�?�F�K�K������r) rr�update�logger�debugrP�getr@�_raise_not_found_for_status�textr)�ex2�findall�ex�UnicodeDecodeError�setr� isinstance�tuple� startswithrY�scheme�netlocr*�rstrip�add�replace�join�lstriprm�_ls_real�sorted) r1r?rer�kwrJ�rrs�links�out�parts�ls rr�zHTTPFileSystem._ls_real�s����� �[� � � � �� � � �&����� � �S�����(�(�*�*�*�*�*�*�*�*���7�;�t���s�3�3�C�C�t�{�C�C� � � � � � � �q� � ,� ,�Q�� 4� 4� 4� ��V�V�X�X�~�~�~�~�~�~���$�=��K�K��-�-�0P�0P�r�z�z�$�?O�?O�0P�0P�0P�P�E�E�<�<�2�:�:�d�+;�+;�<�<�<�E���%� � � ����� ���� � � � � � � � � � � � � � � � � � � � � � � ���� � � � ��e�e���� � ��� H� H�A��!�U�#�#� ��a�D���|�|�C� � � :�S��V�V�a�Z�Z��|�9�9�� �9�a�9�9���|�|�F�#�#� H��#��� � �S�Z�Z��_�_�s�5J�(K�(K���G�G�A�J�J�J�J��Y�Y�w��/�/�:�:��K�K���0�0�7�7��<�<�s�B�����G�G�A�J�J�J���M�)�)��G�G�C�H�H�c�j�j��o�o�q�x�x��}�}�%E�F�F�G�G�G��� E�s�|�|�C�(�(� E�� � �c�j�j��o�o�e� �D�D�D�D�D�D�D�D�C� � ��� � ��� ��#�;�;� s7�E�)BD/�.E�/ D>�;E�=D>�>E� E� Ec��K�|jr||jvr|j|}n |j|fd|i|���d{V��}||j|<|S)Nre)r"�dircacher�)r1r?rerr�s r�_lszHTTPFileSystem._ls�sl���� � "� %�s�d�m�';�';��-��$�C�C�%�� �c�C�C�&�C�F�C�C�C�C�C�C�C�C�C�!$�D�M�#� �� rc�b�|jdkrt|���|���dS)zU Raises FileNotFoundError for 404s, otherwise uses raise_for_status. i�N)�status�FileNotFoundError�raise_for_status)r1�responser?s rrrz*HTTPFileSystem._raise_not_found_for_status�s7�� �?�c� !� !�#�C�(�(� (��!�!�#�#�#�#�#rc��vK�|j���}|�|��t�|��|�|�U||krdS|�di�����}|�|||���d{V��|d<||d<|����d{V��}|j|� |��fi|��4�d{V��}|� ���d{V��} |� ||��ddd���d{V��n#1�d{V��swxYwY| S)Nr�headers�Range) rrrnrorpr0�_process_limitsrPrqr@�readrr) r1r?�start�endrr�r�rJr�r�s r� _cat_filezHTTPFileSystem._cat_file�s����� �[� � � � �� � � �&����� � �S���� � �����|�|��s��f�f�Y��+�+�0�0�2�2�G�%)�%9�%9�#�u�c�%J�%J�J�J�J�J�J�J�G�G� �#�B�y�M��(�(�*�*�*�*�*�*�*�*���7�;�t���s�3�3�:�:�r�:�:� 5� 5� 5� 5� 5� 5� 5�a������.�.�.�.�.�.�C� � ,� ,�Q�� 4� 4� 4� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5���� 5� 5� 5� 5�� s�%1D(�( D2�5D2iPc���K�|j���}|�|��t�|��|����d{V��}|j|�|��fi|��4�d{V��} t|j d��} n#ttf$rd} YnwxYw|� | ��|� ||��t|��r|} nt|d��} d} | rY|j�|���d{V��} | �| ��|�t)| ����| �Yt|��s| ���n)#t|��s| ���wwxYwddd���d{V��dS#1�d{V��swxYwYdS)Nzcontent-length�wbT)rrrnrorprPrqr@�intr�� ValueError�KeyError�set_sizerrr�open�contentr��write�relative_updaterYrE) r1�rpath�lpath� chunk_size�callbackrr�rJr�rk�outfile�chunks r� _get_filezHTTPFileSystem._get_file�s������[� � � � �� � � �&����� � �U�����(�(�*�*�*�*�*�*�*�*���7�;�t���u�5�5�<�<��<�<� $� $� $� $� $� $� $�� ��1�9�%5�6�7�7������)� � � ����� ���� � � �d� #� #� #� � ,� ,�Q�� 6� 6� 6��%� � � ,�����u�d�+�+�� $����9�"#�)�.�.��"<�"<�<�<�<�<�<�<�E��M�M�%�(�(�(��,�,�S��Z�Z�8�8�8��9� "�%�(�(�$��M�M�O�O�O���"�%�(�(�$��M�M�O�O�O�O�$����) $� $� $� $� $� $� $� $� $� $� $� $� $� $� $� $� $� $� $� $� $� $� $� $���� $� $� $� $� $� $sP� G �B)�(G �)B?�<G �>B?�?AG �AF�-$G �&F7�7G � G�G�post� overwritec�����K�|dkrtd������fd�}|j���} | �|��|����d{V��} |���}|dvrt d|�����t| |��} | |�|��fd|��i| ��4�d{V��} |� | |��ddd���d{V��dS#1�d{V��swxYwYdS)Nr�zExclusive writec�2�K�t�tj��rt���}d}nt �d��}d}|5}|r?��|�dd����|�d��n$��t|dd����|����}|r>|WV��� t|����|����}|�>ddd��dS#1swxYwYdS)NF�rbTrrrk) ry�io�IOBaserr�r��seekrHr�r�rY)�context�use_seek�fr�r�r�r�s ���r� gen_chunksz,HTTPFileSystem._put_file.<locals>.gen_chunkss_������%���+�+� �%�e�,�,�� ����u�d�+�+����� /�A��@��%�%�a�f�f�Q��l�l�3�3�3��F�F�1�I�I�I�I��%�%�g�a���&>�&>�?�?�?����z�*�*���/��K�K�K�K��,�,�S��Z�Z�8�8�8��F�F�:�.�.�E��/� /� /� /� /� /� /� /� /� /� /� /� /���� /� /� /� /� /� /s�B;D � D�D)r��putz.method has to be either 'post' or 'put', not: �data) rGrrrnrP�lowerr�rHr@rr) r1r�r�r�r��method�moderr�r�rJ�meth�resps ` `` r� _put_filezHTTPFileSystem._put_file s�������� �;� � �%�&7�8�8� 8� /� /� /� /� /� /� /�.�[� � � � �� � � �&�����(�(�*�*�*�*�*�*�*�*�������� �� (� (��K��K�K��� ��w��'�'���4�����.�.�H�H�Z�Z�\�\�H�R�H�H� :� :� :� :� :� :� :�D� � ,� ,�T�5� 9� 9� 9� :� :� :� :� :� :� :� :� :� :� :� :� :� :� :� :� :� :� :� :� :� :� :� :���� :� :� :� :� :� :s�C:�: D�Dc��K�|j���}|�|�� t�|��|����d{V��}|j|�|��fi|���d{V��}|4�d{V��|jdkcddd���d{V��S#1�d{V��swxYwYdS#tj $rYdSwxYw)Ni�F) rrrnrorprPrqr@r�r� ClientError)r1rSrr�rJr�s r�_existszHTTPFileSystem._exists?s����� �[� � � � �� � � �&���� � �L�L�� � � � �,�,�.�.�.�.�.�.�.�.�G�!�g�k�$�/�/�$�"7�"7�>�>�2�>�>�>�>�>�>�>�>�A�� &� &� &� &� &� &� &� &��x�#�~� &� &� &� &� &� &� &� &� &� &� &� &� &� &� &� &� &� &� &� &� &� &� &� &���� &� &� &� &� &� &���"� � � ��5�5� ���s6�A#C� B3� C�3 B=�=C�B=�C�C�Cc��.K�|j|fi|���d{V��S�N)r�)r1rSrs r�_isfilezHTTPFileSystem._isfileKs2����!�T�\�$�1�1�&�1�1�1�1�1�1�1�1�1rr�c ���|dkrt�|�|n|j}|j���} |j| d<| �|��i} |p(| �|j|fi|����p| d}t|j|j ��} |rA|r?| � dd��r)t||f| ||||p|j |p|j |jd�| ��St||f||j| d�| ��S) a�Make a file-like object Parameters ---------- path: str Full URL with protocol mode: string must be "rb" block_size: int or None Bytes to download in one request; use instance value if None. If zero, will return a streaming Requests file-like instance. kwargs: key-value Any other parameters, passed to requests calls r�Nr rk�partialT)rJr(r�rkr+r,r!)r�r!rJ)rGr(rrr rn�inforr!rPrq�HTTPFiler+r,�HTTPStreamFile) r1rSr�r(� autocommitr+r,rkrr�r�rJs r�_openzHTTPFileSystem._openNsT��2 �4�<�<�%� %�#-�#9�Z�Z�t�� � �[� � � � ��!�.��>�� � � �&�������M�t�{�{�9�4�9�T�#<�#<�V�#<�#<�=�=�M��f����t�y�$�"2�3�3�� � �$� �4�8�8�I�t�#<�#<� ���� � �%���%�8���+�A�t�/A��Y� � �� � � �"������Y�� �� � �� rc���K�|����d{V��}|�, |j|fi|���d{V��d}n#t$rYnwxYwt||f|j||d�|��S)Nrk)r!rJrk)rP�_infor��AsyncStreamFiler!)r1rSr�rkrrJs r� open_asynczHTTPFileSystem.open_async�s������(�(�*�*�*�*�*�*�*�*�� �<� �(�d�j��8�8��8�8�8�8�8�8�8�8�&�A����$� � � ��� ����� � � �����  � � �  � � s�;� A�Ac�8�t||j|j��S)z;Unique identifier; assume HTTP files are static, unchanging)rr�protocolr>s r�ukeyzHTTPFileSystem.ukey�s����T�[�$�-�8�8�8rc ��K�i}|����d{V��}dD]�} |�t|�|��f||d�|j�|���d{V����|�d���nJ�^#t $r<}|dkrt|��|�t� d|���Yd}~��d}~wwxYw|dd�|�d d i�S) aHGet info of URL Tries to access location via HEAD, and then GET methods, but does not fetch the data. It is possible that the server does not supply any size information, in which case size will be given as None (and certain operations on the corresponding file will not work). N)�headrq)r3rJrkrqrW)�exc_info�rjrkrlrh) rPrn� _file_infor@rrq� Exceptionr�rorp)r1r?rr�rJ�policy�excs rr�zHTTPFileSystem._info�sT�������(�(�*�*�*�*�*�*�*�*��%� /� /�F� /�� � �$�����,�,��$*� '����+� � !� ������������8�8�F�#�#�/��E�0��� /� /� /��U�?�?�+�C�0�0�c�9�� � �R�#� �.�.�.�.�.�.�.�.�����  /���� �T�B�B�T�B�6�6�B�B�Bs�AA?�? C� 2C�Cc����K�|�|dkrtd���ddl}|�d��}|�|��}|p|�d���|�d��dkr|�d��nt |��}|�d��dkr|�d��nt |��}t ||��}|�d d ��} t|��s5|j |fi|���d{V��r| s|gS||j |fi|���d{V��iS| sgSiSd|d|�vrN|d|�� d��}|d|dz�} ||dzd�� d��dz} n%d } ||dzd�� d��dz} d |vrB|�>|�d ��} || d�� d��dz} | | z |z} nd} |j | f| d d d�|���d{V��}t||rdnd z���|j������fd�t!|�����D��}| r|St%|��S)a Find files by glob-matching. This implementation is idntical to the one in AbstractFileSystem, but "?" is not considered as a character for globbing, because it is so common in URLs, often identifying the "query" part. Nrczmaxdepth must be at least 1rr)z/**z/*�*�[reFrWz**T)�maxdepth�withdirsrec����i|]h\}}��|�d�����-�s6|ddkr*|�d��r|�d��n||��iS)rrlrg)�matchr~rm)r_�pr��append_slash_to_dirname�patterns ��r� <dictcomp>z(HTTPFileSystem._glob.<locals>.<dictcomp>�s����  �  �  ���4��}�}�Q�X�X�c�]�]�+�+�  �/����L�K�/�/��J�J�s�O�O�0����� � � ���  �  �  r)r��rermrT�findrY�minr0� has_magicr�r��rindex�count�_findr �compiler��items�list)r1rSr�rr��ends_with_slash�idx_star� idx_brace�min_idxre�root�depth�idx_double_stars�depth_double_stars�allpathsr�r�r�s @@r�_globzHTTPFileSystem._glob�s9������ � �H�q�L�L��:�;�;� ;�� � � ��-�-��,�,���#�#�D�)�)��"1�"Q�T�]�]�=�5Q�5Q��%)�Y�Y�s�^�^�q�%8�%8�4�9�9�S�>�>�>�c�$�i�i��&*�i�i��n�n��&9�&9�D�I�I�c�N�N�N�s�4�y�y� ��h� �*�*�����H�e�,�,������ 7�!�T�\�$�1�1�&�1�1�1�1�1�1�1�1� ��D� �6�M� � �� �4�(B�(B�6�(B�(B�"B�"B�"B�"B�"B�"B�C�C����I��I� �D��'��N� "� "��8�G�8�n�+�+�C�0�0�G�� �'�A�+� �&�D���1����'�-�-�c�2�2�Q�6�E�E��D���1����'�-�-�c�2�2�Q�6�E� �4�<�<��#�#'�9�9�T�?�?� �%)�*:�*;�*;�%<�%B�%B�3�%G�%G�!�%K�"�� 2�2�X�=�����#��� � � �4�� � �@F� � � � � � � � ��!���)G���R�!H�I�I���"�*�W�%�%��  �  �  �  �  �"�(�.�.�"2�"2�3�3�  �  �  �� � ��J���9�9� rc��K� t|�|���d{V����S#ttf$rYdSwxYw)NF)�boolr�r�r�)r1rSs r�_isdirzHTTPFileSystem._isdirs\���� ��d�h�h�t�n�n�,�,�,�,�,�,�-�-� -��!�:�.� � � ��5�5� ���s�',�A�A)T)NN)r�NNNNN)r�Nr�)"�__name__� __module__� __qualname__�__doc__�seprr'�propertyr:r@� staticmethodrLrP� classmethodrTrXr�r�r�lsrrr�r r�r�r�r�r�r�r�r�r�r�� __classcell__�r6s@rrr$sH��������� �C�������� ����?&�?&�?&�?&�?&�?&�B����X��3�3�3�� � ��\� ��������[��������[��0�0�0�0�d���� ��c� � �B�$�$�$�����&(1�;K�$�$�$�$�D�!�� �0:�0:�0:�0:�d � � �2�2�2� ����� �7�7�7�7�r � � � � 9�9�9� C� C� C�DG�G�G�G�R������rrc�~��eZdZdZ d �fd� Zd �fd� Zd �Zee��Zd �Z d �Z ee ��Z �xZ S)r�a� A file-like object pointing to a remote HTTP(S) resource Supports only reading, with read-ahead of a predetermined block-size. In the case that the server does not supply the filesize, only reading of the complete file in one go is supported. Parameters ---------- url: str Full URL of the remote resource, including the protocol session: aiohttp.ClientSession or None All calls will be made within this session, to avoid restarting connections where the server allows this block_size: int or None The amount of read-ahead to do, in bytes. Default is 5MB, or the value configured for the FileSystem creating this file size: None or int If given, this is the size of the file in bytes, and we don't attempt to call the server to find the value. kwargs: all other key-values are passed to requests calls. Nr�rFc ����|dkrtd���| |_| |_||_||_||dd�|_t ��jd||||||d�| ��dS)Nr�zFile mode not supportedrhri)�fsrSr�r(r+r,r)rGr r!r?rJ�detailsr&r') r1r r?rJr(r�r+r,rkr!r rr6s �rr'zHTTPFile.__init__'s���� �4�<�<�%�&?�@�@� @�(����� ������ � #�T�6�B�B�� ������ ����!�!�'�  � �� � � � � r�����c�<��|dkr6|jdkr+|j�|j|jks|���|j�|dkr|���nt |j|jz |��}t ���|��S)a5Read bytes from file Parameters ---------- length: int Read up to this many bytes. If negative, read all content to end of file. If the server has not supplied the filesize, attempting to read only part of the data will raise a ValueError. r)�locrk� blocksize� _fetch_allr�r&r�)r1�lengthr6s �rr�z HTTPFile.readFs�����a�Z�Z�D�H��M�M��Y�*�t�y�D�N�/J�/J� �O�O� � � � �9� ���z�z����!�!�!�����T�X�-�v�6�6�F��w�w�|�|�F�#�#�#rc��K�t�d|����t|jt��s�|jj|j�|j ��fi|j ���d{V��}|4�d{V��|� ��|� ���d{V��}t t|��dd|���|_t|��|_ddd���d{V��dS#1�d{V��swxYwYdSdS)z�Read whole file in one shot, without caching This is only called when position is still at zero, and read() is called without a byte-count. zFetch all for N)rk�fetcherrr�)rorpry�cacherrJrqr r@r?rr�r�rYrk)r1r�r�s r�async_fetch_allzHTTPFile.async_fetch_all]s����� � � �,�d�,�,�-�-�-��$�*�h�/�/� %�&�d�l�&�t�w�'9�'9�$�(�'C�'C�S�S�t�{�S�S�S�S�S�S�S�S�A�� %� %� %� %� %� %� %� %��"�"�$�$�$��F�F�H�H�n�n�n�n�n�n��%��S���4�4�c����� � ��H�H�� �  %� %� %� %� %� %� %� %� %� %� %� %� %� %� %� %� %� %� %� %� %� %� %� %���� %� %� %� %� %� %� %� %s�=A(C8�8 D�Dc�"�|�dd��}tjd|��}|sdS|ddkrdx}}n(d�|d�d ��D��\}}|d dkrdnt |d ��}|||fS) zParse the Content-Range header� Content-RangerWzbytes (\d+-\d+|\*)/(\d+|\*))NNNrcr�Nc�,�g|]}t|����Sr)r�)r_�xs rraz1HTTPFile._parse_content_range.<locals>.<listcomp>zs��:�:�:�Q�#�a�&�&�:�:�:r�-r)rqr�r��splitr�)r1r��s�mr�r��totals r�_parse_content_rangezHTTPFile._parse_content_rangeps��� �K�K��� ,� ,�� �H�3�Q� 7� 7��� $�#�#� �Q�4�3�;�;�� �E�C�C�:�:�!�A�$�*�*�S�/�/�:�:�:�J�E�3��!��� � ����Q�q�T�����c�5� � rc��K�t�d|�d|�d|����|j���}|�di�����}d|�d|dz ��|d<t�|j�d|d����|jj|j� |j��fd|i|���d {V��}|4�d {V��|j d kr d d d ���d {V��d S|� ��|j d kpU|� |j ��d |kp1t|j �d|dz����||z k}|r|����d {V��}n�|d krt!d���d }g} |j�d���d {V��} | r2|�| ��|t'| ��z }|||z krnnn�Vd �|��d ||z �}|cd d d ���d {V��S#1�d {V��swxYwYd S)a3Download a block of data The expectation is that the server returns only the requested bytes, with HTTP code 206. If this is not the case, we first check the headers, and then stream the output - if the data size is bigger than we requested, an exception is raised. zFetch range for z: rr��bytes=rcr�z : Ni�r��r�Content-Lengthz�The HTTP server doesn't appear to support range requests. Only reading this file from the beginning is supported. Open with block_size=0 for a streaming file interface.Ti)rorprrr0r?rJrqr r@r�r�r r�r�r�r�r��appendrYr�) r1r�r�rr�r��response_is_ranger��clr�s r�async_fetch_rangezHTTPFile.async_fetch_range~s����� � � �=��=�=��=�=��=�=�>�>�>���!�!�#�#���*�*�Y��+�+�0�0�2�2��5�E�5�5�C�!�G�5�5����� � ���7�7�W�W�%5�7�7�8�8�8�"�$�,�"� �G� � �t�x� (� (� � �29� �=C� � � � � � � � ���) �) �) �) �) �) �) �) ��x�3����) �) �) �) �) �) �) �) �) �) �) �) �) �) � � � � � � ���C��P��,�,�Q�Y�7�7��:�e�C�P��q�y�}�}�%5�s�Q�w�?�?�@�@�C�%�K�O� � !� 3��F�F�H�H�n�n�n�n�n�n������� �M�������� �"#�)�.�.��"7�"7�7�7�7�7�7�7�E���� � �5�)�)�)��c�%�j�j�(����e� �+�+�!�,�� ��h�h�s�m�m�M�c�E�k�M�2���S) �) �) �) �) �) �) �) �) �) �) �) �) �) �) �) �) �) �) �) �) �) �) �) ����) �) �) �) �) �) s� H5�?D#H5�5 H?�H?)NNr�rNNNF�r ) r�r�rrr'r�rrrr r(� _fetch_rangerrs@rr�r�s����������8�� ��� � �� � � � � � �>$�$�$�$�$�$�.%�%�%�"��o�.�.�J� !� !� !�9�9�9�v �<� 1�2�2�L�L�L�L�Lrr�z([*[])c�>�t�|��}|duSr�)� magic_check�search)rr�s rr�r��s �� � � �q� !� !�E� �� �rc�V��eZdZd �fd� Zd d�Zd d�Zee��Zd�Z�fd �Z �xZ S) r�r�Nc �2�������dd���_��_|�_|�_|dkrt ��dd��_t��jd|�|dd�������fd�}t�j|���_ |j�_dS) Nr Fr�r��none�r rSr�r+c����K��jj�j����fi�������d{V��}�j�|���|Sr�)rJrqr r@� __aenter__rr)r�rr1r?s ���r�corz$HTTPStreamFile.__init__.<locals>.cor�sn�����&�d�l�&�t�w�'9�'9�#�'>�'>�I�I�&�I�I�T�T�V�V�V�V�V�V�V�V�A� �G� /� /��3� 7� 7� 7��Hrr) r0r r?r!rJr�r r&r'rr�) r1r r?r�r!rJrr4r6s ` ` ` �rr'zHTTPStreamFile.__init__�s�������"�J�J�~�u�=�=�������� ��� � �4�<�<�� � #�T�2�2�� ������Q�B�S�t��Q�Q�&�Q�Q�Q� � � � � � � � �d�i��%�%����G�� � � rrc�b�|dkr|dkrdS||jkr|dkrdStd���)NrrczCannot seek streaming HTTP file)rr�)r1r�whences rr�zHTTPStreamFile.seek�s?�� �!�8�8��!� � � �F� �$�(�?�?�v��{�{� �F��:�;�;�;rr c��K�|jj�|���d{V��}|xjt |��z c_|Sr�)r�r�r�rrY)r1�numr�s r�_readzHTTPStreamFile._read�sJ�����F�N�'�'��,�,�,�,�,�,�,�,�� ���C��H�H����� rc��<K�|j���dSr�)r�rEr9s rrIzHTTPStreamFile._close�s���� �� � �����rc���tj|���|j��t �����dSr�)�asyncio�run_coroutine_threadsaferIr!r&rE�r1r6s �rrEzHTTPStreamFile.close�s5����(������� �B�B�B� ��� � �����r)r�NN)rr)) r�r�rr'r�r9rr�rIrErrs@rr�r��s��������������$<�<�<�<����� �<�� � �D������������rr�c�4��eZdZ d�fd� Zdd�Z�fd�Z�xZS) r�r�Nc ����||_||_d|_|dkrt�|dd�|_||_t ���|||d���||_dS)Nr�r�r0r1) r?rJr�r�r rr&r'rk) r1r r?r�r!rJrkrr6s �rr'zAsyncStreamFile.__init__�sk�������� ���� �4�<�<�� � #�T�2�2�� ��� � �����B�S�t���G�G�G��� � � rr c��K�|j�t|jj|j�|j��fi|j������d{V��}|j�||j��||_|jj � |���d{V��}|xj t|��z c_ |Sr�) r�rJrqr r@r?rr3rrr�r�rrY)r1r8r�r�s rr�zAsyncStreamFile.read�s����� �6�>�&�d�l�&���"�"�4�8�,�,���04� ����j�l�l�������A� �G� /� /��4�8� <� <� <��D�F��F�N�'�'��,�,�,�,�,�,�,�,�� ���C��H�H����� rc���K�|j� |j���d|_t������d{V��dSr�)r�rEr&r>s �rrEzAsyncStreamFile.closesO����� �6� � �F�L�L�N�N�N��D�F��g�g�m�m�o�o���������r)r�NNNr))r�r�rr'r�rErrs@rr�r��sm�������@D� � � � � � � � � � ���������rr�c��,K�|���}|�di�����}d|�d|dz ��|d<|j|fd|i|���d{V��}|���|4�d{V��|����d{V��}ddd���d{V��n#1�d{V��swxYwY|rUt |d��5} | �|��| �|��ddd��dS#1swxYwYdS|S)Nr�r"rrcr�zr+b)rr0rqr�r�r�r�r�) rJr?r�r�rhrr�r�r�r�s r� get_rangerD s����� �[�[�]�]�F��j�j��B�'�'�,�,�.�.�G�1��1�1��a��1�1�G�G���g�k�#�9�9�w�9�&�9�9�9�9�9�9�9�9�A�����������������F�F�H�H�n�n�n�n�n�n�������������������������������� �� �$�� � � �!� �F�F�5�M�M�M� �G�G�C�L�L�L� � � � � � � � � � � � ���� � � � � � �� s$�?B,�, B6�9B6�+D�D �D r�c��HK�t�d|��|���}|�dd��}|�di�����}d|d<||d<i}|dkr|j|fd|i|���d{V��}n/|d kr|j|fd|i|���d{V��}nt d |�����|4�d{V��|���d |jvr6d |jvs|jd d vrt|jd ��|d<n?d|jvr6t|jd� d��d��|d<d|jvr)|jd� d��d|d<|j�d��dkrd|d<t|j ��|d<dD],}|j�|��r|j|||<�- ddd���d{V��n#1�d{V��swxYwY|S)z�Call HEAD on the server to get details about the file (size/checksum etc.) Default operation is to explicitly allow redirects and use encoding 'identity' (no compression) to get the true size of the target. zRetrieve file size for %s�allow_redirectsTr��identityzAccept-Encodingr�Nrqz)size_policy must be "head" or "get", got r$zContent-Encoding)rGrWrkrrrcz Content-Type�;r�mimetypez Accept-Rangesr0Fr�r?)�ETagz Content-MD5�Digest)rorprr0rqr�� TypeErrorr�r�r�r� partition�strr?) r?rJr3r�arr�r�r��checksum_fields rr�r�s)����  �L�L�,�c�2�2�2� �[�[�]�]�F� ���%�t� ,� ,�B� �:�:�i�� $� $� )� )� +� +�D�(�D� ���F�9�� �D��f����'�,�s�A�A�B�A�&�A�A� A� A� A� A� A� A��� �� � ��'�+�c�@�@�2�@��@�@� @� @� @� @� @� @����Q�K�Q�Q�R�R�R��A�A�A�A�A�A�A�A� ������ �q�y� (� (�"���2�2�a�i�@R�6S�X�7�7� #�1�9�-=�#>�?�?��V� �� �� � )� )��q�y��9�?�?��D�D�Q�G�H�H�D��L� �Q�Y� &� &� �y��8�B�B�3�G�G��J�D�� � �9�=�=�� )� )�V� 3� 3�$�D��O��!�%�j�j��U� �?� A� A�N��y�}�}�^�,�,� A�'(�y��'@��^�$�� A�1A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A����A�A�A�A�8 �Ks�D.H� H�Hc��K�|�t���d{V��}t|g|�Rd|i|���d{V��}|�d��S)NrJrk)rr�rq)r?rJ�argsrr�s r� _file_sizerSQsl������"� � �$�$�$�$�$�$���C�B�4�B�B�B��B�6�B�B� B� B� B� B� B� B�D� �8�8�F� � �rr�)r�)-r<r��loggingr�rNr� urllib.parserrr<� fsspec.asynrrrr�fsspec.callbacksr �fsspec.exceptionsr � fsspec.specr � fsspec.utilsr r rrr�cachingrr�rvrt� getLoggerrorrr�r,r�r�r�rDr�rS� file_sizerrr�<module>r^s������� � � � ����� � � � �����������!�!�!�!�!�!����� � � � �V�V�V�V�V�V�V�V�V�V�V�V�-�-�-�-�-�-�,�,�,�,�,�,�,�,�,�,�,�,����������������������R�Z�M�N�N���b�j�E�F�F�� �� �=� )� )��+�+�+�g�g�g�g�g�_�g�g�g�Tk3�k3�k3�k3�k3�#�k3�k3�k3�\�b�j��"�"� ���� &�&�&�&�&�)�&�&�&�R�����/����@����"0�0�0�0�f���� �L�� $� $� � � r
Memory