https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/boto/cloudsearch2/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/boto/cloudsearch2/__pycache__/document.cpython-310.pyc
o

ckF[n-�@s�ddlZddlmZddlZddlZddlmZGdd�de�ZGdd�de�Z	Gdd	�d	e�Z
Gd
d�de�ZGdd
�d
e�Z
Gdd�de�ZdS)�N)�json)�CloudSearchDomainConnectionc@seZdZdS)�SearchServiceExceptionN)�__name__�
__module__�__qualname__�rr�</usr/lib/python3/dist-packages/boto/cloudsearch2/document.pyrsrc@seZdZdZdS)�CommitMismatchErrorN)rrr�errorsrrrr	r
#sr
c@�eZdZdZdS)�
EncodingErrorz�
    Content sent for Cloud Search indexing was incorrectly encoded.

    This usually happens when a document is marked as unicode but non-unicode
    characters are present.
    N�rrr�__doc__rrrr	r
)sr
c@r)�ContentTooLongErrorz�
    Content sent for Cloud Search indexing was too long

    This will usually happen when documents queued for indexing add up to more
    than the limit allowed per upload batch (5MB)

    Nrrrrr	r3src@sZeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�DocumentServiceConnectiona/
    A CloudSearch document service.

    The DocumentServiceConection is used to add, remove and update documents in
    CloudSearch. Commands are uploaded to CloudSearch in SDF (Search Document
    Format).

    To generate an appropriate SDF, use :func:`add` to add or update documents,
    as well as :func:`delete` to remove documents.

    Once the set of documents is ready to be index, use :func:`commit` to send
    the commands to CloudSearch.

    If there are a lot of documents to index, it may be preferable to split the
    generation of SDF data and the actual uploading into CloudSearch. Retrieve
    the current SDF with :func:`get_sdf`. If this file is the uploaded into S3,
    it can be retrieved back afterwards for upload into CloudSearch using
    :func:`add_sdf_from_s3`.

    The SDF is not cleared after a :func:`commit`. If you wish to continue
    using the DocumentServiceConnection for another batch upload of commands,
    you will need to :func:`clear_sdf` first to stop the previous batch of
    commands from being uploaded again.

    NcCs�||_||_|js
|j|_g|_d|_i|_d|_|jrO|jjrQ|jjjr.d|jj�	�i|_t
|jjdd�|_|jrS|jj}t|j|j|j
|j|jd�|_dSdSdSdS)NF�http�sign_request)�host�aws_access_key_id�aws_secret_access_key�region�provider)�domain�endpoint�doc_service_endpoint�documents_batch�_sdf�proxyr�layer1�	use_proxy�get_proxy_url_with_auth�getattrrrrrr�domain_connection)�selfrrrrrr	�__init__Ys.
��z"DocumentServiceConnection.__init__cCsd||d�}|j�|�dS)aV
        Add a document to be processed by the DocumentService

        The document will not actually be added until :func:`commit` is called

        :type _id: string
        :param _id: A unique ID used to refer to this document.

        :type fields: dict
        :param fields: A dictionary of key-value pairs to be uploaded .
        �add)�type�id�fieldsN�r�append)r$�_idr)�drrr	r&us
zDocumentServiceConnection.addcCsd|d�}|j�|�dS)a
        Schedule a document to be removed from the CloudSearch service

        The document will not actually be scheduled for removal until
        :func:`commit` is called

        :type _id: string
        :param _id: The unique ID of this document.
        �delete)r'r(Nr*)r$r,r-rrr	r.�s
z DocumentServiceConnection.deletecCs|jr|jSt�|j�S)z�
        Generate the working set of documents in Search Data Format (SDF)

        :rtype: string
        :returns: JSON-formatted string of the documents in SDF
        )rr�dumpsr�r$rrr	�get_sdf�sz!DocumentServiceConnection.get_sdfcCsd|_g|_dS)z�
        Clear the working documents from this DocumentServiceConnection

        This should be used after :func:`commit` if the connection will be
        reused for another set of documents.
        N)rrr0rrr	�	clear_sdf�s
z#DocumentServiceConnection.clear_sdfcCs|��|_dS)a
        Load an SDF from S3

        Using this method will result in documents added through
        :func:`add` and :func:`delete` being ignored.

        :type key_obj: :class:`boto.s3.key.Key`
        :param key_obj: An S3 key which contains an SDF
        N)�get_contents_as_stringr)r$�key_objrrr	�add_sdf_from_s3�sz)DocumentServiceConnection.add_sdf_from_s3cCs|j�|d�S)N�application/json)r#�upload_documents)r$�sdf�api_versionrrr	�_commit_with_auth�sz+DocumentServiceConnection._commit_with_authcCs`d|j|f}t��}|j|_tjjdddd�}|�d|�|�d|�|j||dd	id
�}|S)Nzhttp://%s/%s/documents/batch��2�)�pool_connections�pool_maxsize�max_retrieszhttp://zhttps://zContent-Typer6)�data�headers)	r�requests�Sessionr�proxies�adapters�HTTPAdapter�mount�post)r$r8r9�url�session�adapter�resprrr	�_commit_without_auth�s�z.DocumentServiceConnection._commit_without_authcCs�|��}d|vr!tj�d�|�d�}tj�||d|d��d}|jr/|jjr/|jjj}|jr9|�	||�}n|�
||�}t||||jd�S)aD
        Actually send an SDF to CloudSearch for processing

        If an SDF file has been explicitly loaded it will be used. Otherwise,
        documents added through :func:`add` and :func:`delete` will be used.

        :rtype: :class:`CommitResponse`
        :returns: A summary of documents added and deleted
        z: nullz?null value in sdf detected. This will probably raise 500 error.�dz
2013-01-01)�signed_request)r1�boto�log�error�indexrr�
APIVersionrr:rN�CommitResponse)r$r8rTr9�rrrr	�commit�s

z DocumentServiceConnection.commit)NN)
rrrrr%r&r.r1r2r5r:rNrXrrrr	r>s

rc@s"eZdZdZddd�Zdd�ZdS)	rVanWrapper for response to Cloudsearch document batch commit.

    :type response: :class:`requests.models.Response`
    :param response: Response from Cloudsearch /documents/batch API

    :type doc_service: :class:`boto.cloudsearch2.document.DocumentServiceConnection`
    :param doc_service: Object containing the documents posted and methods to
        retry

    :raises: :class:`boto.exception.BotoServerError`
    :raises: :class:`boto.cloudsearch2.document.SearchServiceException`
    :raises: :class:`boto.cloudsearch2.document.EncodingError`
    :raises: :class:`boto.cloudsearch2.document.ContentTooLongError`
    Fc	Cs||_||_||_||_|jr||_n(|j�d�}zt�|�|_Wntj	�
d�||j��tjj
|jjd|d��|jd|_|jdkrjdd�|j�d	g�D�|_|jD]}d
|vr`td��|dkrhtd
��qVng|_|jd|_|jd|_|�d|j�|�d|j�dS)Nzutf-8z9Error indexing documents.
Response Content:
{0}

SDF:
{1}�)�body�statusrScSsg|]}|�d��qS)�message)�get)�.0�errr	�
<listcomp>
sz+CommitResponse.__init__.<locals>.<listcomp>rzIllegal Unicode characterz%Illegal Unicode character in documentzThe Content-Length is too longzContent was too long�adds�deletesr&r.)�response�doc_servicer8rP�content�decoder�loadsrQrRrS�format�	exception�BotoServerError�status_coder[r]rr
rrarb�_check_num_ops)r$rcrdr8rP�_bodyr_rrr	r%�sB
��

�
��zCommitResponse.__init__csjt�fdd�|jjD��}||kr3|jrtj�|j�ntj�|jj�t	d�
�||��}|j|_|�dS)aYRaise exception if number of ops in response doesn't match commit

        :type type_: str
        :param type_: Type of commit operation: 'add' or 'delete'

        :type response_num: int
        :param response_num: Number of adds or deletes in the response.

        :raises: :class:`boto.cloudsearch2.document.CommitMismatchError`
        csg|]
}|d�kr|�qS)r'r)r^r-��type_rr	r`'s�z1CommitResponse._check_num_ops.<locals>.<listcomp>z<Incorrect number of {0}s returned. Commit: {1} Response: {2}N)�lenrdrrPrQrR�debugrcrer
rhr)r$ro�response_num�
commit_num�excrrnr	rls
��zCommitResponse._check_num_opsN)F)rrrrr%rlrrrr	rV�s
$rV)�boto.exceptionrQ�boto.compatrrC�boto.cloudsearchdomain.layer1r�	Exceptionrr
r
r�objectrrVrrrr	�<module>s
,

https://t.me/RX1948 - 2025