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/cloudsearch/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

ckF[4&�@s�ddlZddlmZddlZddlZGdd�de�ZGdd�de�ZGdd�de�ZGd	d
�d
e�Z	Gdd�de
�ZGd
d�de
�ZdS)�N)�jsonc@�eZdZdS)�SearchServiceExceptionN��__name__�
__module__�__qualname__�r	r	�;/usr/lib/python3/dist-packages/boto/cloudsearch/document.pyr�rc@r)�CommitMismatchErrorNrr	r	r	r
r"rr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__r	r	r	r
r%src@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)

    Nrr	r	r	r
r.src@sLeZdZdZddd�Zddd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�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|_dS)N)�domain�endpoint�doc_service_endpoint�documents_batch�_sdf)�selfrrr	r	r
�__init__Rs
z"DocumentServiceConnection.__init__�encCs d||||d�}|j�|�dS)a�
        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 version: int
        :param version: Version of the document being indexed. If a file is
            being reindexed, the version should be higher than the existing one
            in CloudSearch.

        :type fields: dict
        :param fields: A dictionary of key-value pairs to be uploaded .

        :type lang: string
        :param lang: The language code the data is in. Only 'en' is currently
            supported
        �add)�type�id�version�lang�fieldsN�r�append)r�_idrr r�dr	r	r
rZs�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.

        :type version: int
        :param version: Version of the document to remove. The delete will only
            occur if this version number is higher than the version currently
            in the index.
        �delete)rrrNr!)rr#rr$r	r	r
r%ts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�rr	r	r
�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)rrr'r	r	r
�	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_objr	r	r
�add_sdf_from_s3�sz)DocumentServiceConnection.add_sdf_from_s3cCs�|��}d|vr!tj�d�|�d�}tj�||d|d��d|j}t��}tjj	dddd�}|�
d	|�|�
d
|�|j||ddid
�}t|||�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$http://%s/2011-02-01/documents/batch��2�)�pool_connections�pool_maxsize�max_retrieszhttp://zhttps://zContent-Typezapplication/json)�data�headers)
r(�boto�log�error�indexr�requests�Session�adapters�HTTPAdapter�mount�post�CommitResponse)r�sdfr9�url�session�adapter�rr	r	r
�commit�s 

�z DocumentServiceConnection.commit)NN)r)rrrrrrr%r(r)r,rFr	r	r	r
r8s


rc@s eZdZdZdd�Zdd�ZdS)r@ajWrapper 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.cloudsearch.document.DocumentServiceConnection`
    :param doc_service: Object containing the documents posted and methods to
        retry

    :raises: :class:`boto.exception.BotoServerError`
    :raises: :class:`boto.cloudsearch.document.SearchServiceException`
    :raises: :class:`boto.cloudsearch.document.EncodingError`
    :raises: :class:`boto.cloudsearch.document.ContentTooLongError`
    c	Cs(||_||_||_|j�d�}zt�|�|_Wntj�	d�
||j��tjj|jj
d|d��|jd|_|jdkrudd�|j�d	g�D�|_|jD]}d
|vrVtd��|dkr^td
��qLd|jvsid|jvrttd|j�dd���ng|_|jd|_|jd|_|�d|j�|�d|j�dS)Nzutf-8z9Error indexing documents.
Response Content:
{0}

SDF:
{1}�)�body�statusr8cSsg|]}|�d��qS)�message)�get)�.0�er	r	r
�
<listcomp>�sz+CommitResponse.__init__.<locals>.<listcomp>�errorszIllegal Unicode characterz%Illegal Unicode character in documentzThe Content-Length is too longzContent was too long�adds�deleteszError indexing documents => %srJrr%)�response�doc_servicerA�content�decoder�loadsr6r7r8�format�	exception�BotoServerError�status_coderIrKrOrrrrPrQ�_check_num_ops)rrRrSrA�_bodyrMr	r	r
r�sD
��

�
���zCommitResponse.__init__cs8t�fdd�|jjD��}||krtd��||���dS)aXRaise 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.cloudsearch.document.CommitMismatchError`
        csg|]
}|d�kr|�qS)rr	)rLr$��type_r	r
rN	s�z1CommitResponse._check_num_ops.<locals>.<listcomp>z<Incorrect number of {0}s returned. Commit: {1} Response: {2}N)�lenrSrrrW)rr^�response_num�
commit_numr	r]r
r[�s
��zCommitResponse._check_num_opsN)rrrrrr[r	r	r	r
r@�s#r@)
�boto.exceptionr6�boto.compatrr:�	Exceptionrrrr�objectrr@r	r	r	r
�<module>s	


https://t.me/RX1948 - 2025