403Webshell
Server IP : 35.236.43.222  /  Your IP : 216.73.216.143
Web Server : Apache
System : Linux order-form-vm-001 5.10.0-37-cloud-amd64 #1 SMP Debian 5.10.247-1 (2025-12-11) x86_64
User : deploy ( 1002)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/google-cloud-sdk/lib/googlecloudsdk/appengine/api/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/google-cloud-sdk/lib/googlecloudsdk/appengine/api/__pycache__/datastore.cpython-311.pyc
�

��֠����dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddlm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZd
ZdZdZe
jd��Ze
jddg���ZdZejZej Z ej!Z!ej"j#Z#ej"j$Z$dZ%d�Z&d�Z'dej"fd�Z(Gd�de)��Z*Gd�de*��Z+Gd�dej,��Z-e-��Z.ej/��Z0dZ1d�Z2d �Z3d!�Z4d"�Z5d#�Z6dJd$�Z7		dKd%�Z8d&�Z9d'�Z:d(�Z;d)�Z<d*�Z=d+�Z>d,�Z?d-�Z@d.�ZAd/�ZBGd0�d1eC��ZDGd2�d3eC��ZEdJd4�ZFdJd5�ZGGd6�d7eE��ZHd8�ZId9�ZJd:�ZKd;�ZLd<�ZMd=�ZNd>�ZOd?�ZPd@�ZQdJdA�ZRejSdB��dLdD���ZTdE�ZUdF�ZVdG�ZWGdH�dIejX��ZYejZZ[e(Z\eQZ]ej^Z^ej_Z_dS)Ma�The Python datastore API used by app developers.

Defines Entity, Query, and Iterator classes, as well as methods for all of the
datastore's calls. Also defines conversions between the Python classes and
their PB counterparts.

The datastore errors are defined in the datastore_errors module. That module is
only required to avoid circular imports. datastore imports datastore_types,
which needs BadValueError, so it can't be defined in datastore.
�N)�saxutils)�apiproxy_stub_map)�capabilities)�datastore_errors)�datastore_types)�datastore_pb)�datastore_query)�
datastore_rpc)�	entity_pb)�encoding�����datastore_v3�writei Ni���c�.�t|ttf��s|f}t|vr	t|vsJ�t||��r|gdfSt|t��r+t	jd|�d|�dt
|���d����	t|��}n9#t$r,t	jd|�d|�dt
|���d����wxYw|D]=}t||��s+t	jd|�d|�dt
|���d�����>|dfS)a�Normalizes and type checks the given argument.

  Args:
    arg: an instance or iterable of the given type(s)
    types: allowed type or tuple of types

  Returns:
    A (list, bool) tuple. The list is a normalized, shallow copy of the
    argument. The boolean is True if the argument was a sequence, False
    if it was a single object.

  Raises:
    AssertionError: types includes list or tuple.
    BadArgumentError: arg is not an instance or sequence of one of the given
    types.
  Fz$Expected an instance or iterable of z; received � (a �).zExpected one of T)�
isinstance�list�tuple�
basestringr�BadArgumentError�typename�	TypeError)�arg�types�arg_list�vals    �-lib/googlecloudsdk/appengine/api/datastore.py�NormalizeAndTypeCheckr!esq��"
�E�D�%�=�	)�	)��
�H�E�	
�U�	�	�u�E�1�1�1�	1���U�����5�%�<���#�z�"�"�'��-�-��5�5�#�#�#�x��}�}�}�}�&�
'�
'�'�'��c���h�h���'�'�'��-�-��5�5�#�#�#�x��}�}�}�}�&�
'�
'�'�'�����)�)��
��U�
#�
#�)��/�/�
�U�U�C�C�C��#�����
(�)�)�	)�)�
�T�>�s�
B�6Cc�l�t|tttf��\}}d�|D��}||fS)a�Normalizes and type checks that the given argument is a valid key or keys.

  A wrapper around NormalizeAndTypeCheck() that accepts strings, Keys, and
  Entities, and normalizes to Keys.

  Args:
    keys: a Key or sequence of Keys

  Returns:
    A (list of Keys, bool) tuple. See NormalizeAndTypeCheck.

  Raises:
    BadArgumentError: arg is not an instance or sequence of one of the given
    types.
  c�,�g|]}t|����S�)�_GetCompleteKeyOrError)�.0�keys  r �
<listcomp>z-NormalizeAndTypeCheckKeys.<locals>.<listcomp>�s!��	6�	6�	6�#�
 ��
%�
%�	6�	6�	6�)r!r�Entity�Key)�keys�multiples  r �NormalizeAndTypeCheckKeysr.�s<�� )��
�F�C�/H�I�I�.�$��	6�	6��	6�	6�	6�$�
��	�r)Fc��|sdS|�dd��}|��t|tj��st	jd���d|vrt	jd���|s.|r*t	jdd�|��z���|St|dd��}tj	|j
|t��j�	��|d<|d
i|��S)a�Get a Configuration object from the keyword arguments.

  This is purely an internal helper for the various public APIs below
  such as Get().

  Args:
    kwargs: A dict containing the keyword arguments passed to a public API.
    convert_rpc: If the an rpc should be converted or passed on directly.
    config_class: The config class that should be generated.

  Returns:
    A UserRPC instance, or a Configuration instance, or None.

  Raises:
    TypeError if unexpected keyword arguments are present.
  N�rpcz2rpc= argument should be None or a UserRPC instance�configz.Expected rpc= or config= argument but not bothz Unexpected keyword arguments: %s�, �read_policy)�deadliner3r1r$)
�poprr�UserRPCrr�join�getattrr
�
Configurationr4�_GetConnectionr1)�kwargs�convert_rpc�config_classr0r3s     r �_GetConfigFromKwargsr>�s��$
���4�	�
�
�5�$���#��_��c�,�4�5�5�>��-�<�
>�
>�>��6����-�
:�
<�
<�<���	�D��/�.����6�1B�1B�B�D�D�	D�
�j��#�}�d�3�3�K�$�2���+����%�'�'�'�F�8��
��	�	��	�	�r)c��eZdZed��\ZZZZej	j
Z
ej	jZd�Ze
dejfd���Zd�Zd�Zd�Zd�Zd	�Zd
�Zd�ZdS)
�
_BaseIndex�c��tj}tj|d|d���tj|d|d���t|ttf��s|d���t|��D]�\}}t|ttf��s|d|z���t|��dkr|d	|t|��fz���tj|d
d|��t�|d|j|j
fd
����t|��|_||_t#|��|_||_dS)acConstruct a datastore index instance.

    Args:
      index_id: Required long; Uniquely identifies the index
      kind: Required string; Specifies the kind of the entities to index
      has_ancestor: Required boolean; indicates if the index supports a query
        that filters entities by the entity group parent
      properties: Required list of (string, int) tuples; The entity properties
        to index. First item in a tuple is the property name and the second
        item is the sorting direction (ASCENDING|DESCENDING).
        The order of the properties is based on the order in the index.
    �index_idT)�zero_ok�kind)�empty_okz$properties must be a list or a tuplez&property[%d] must be a list or a tuple�z*property[%d] length should be 2 but was %drz
property name�zsort directionN)rrr�ValidateInteger�ValidateStringrrr�	enumerate�lenr@�_BaseIndex__ValidateEnum�	ASCENDING�
DESCENDING�long�_BaseIndex__id�_BaseIndex__kind�bool�_BaseIndex__has_ancestor�_BaseIndex__properties)�selfrCrE�has_ancestor�
properties�argument_error�idx�index_propertys        r �__init__z_BaseIndex.__init__�s���&�6�N��#�H�j�.�,0�2�2�2�2��"�4���$�O�O�O�O��j�4��-�0�0�C��N�A�B�B�B�(��4�4�
1�
1���^�
���u�
�
6�
6�M��n�E��K�L�L�L�	�^�	�	��	!�	!��n�I��c�.�1�1�2�3�4�4�	4��$�^�A�%6��%3�5�5�5�����q� 1� $����@�/�1�1�1�1��X���D�I��D�K��|�,�,�D��"�D���r)�valuec�v�tj|||��||vr|d|t|��|fz���dS)Nz!%s should be one of %s but was %d)rrI�str)r]�accepted_values�name�	exceptions    r �__ValidateEnumz_BaseIndex.__ValidateEnumsZ���#�E�4��;�;�;��O�#�#��I�9��S��1�1�5�9�:�
;�
;�;�$�#r)c��|jS)zReturns the index id, a long.�rQ�rVs r �_Idz_BaseIndex._Ids
���9�r)c��|jS)z=Returns the index kind, a string.  Empty string ('') if none.)rRrfs r �_Kindz_BaseIndex._Kinds
���;�r)c��|jS)z2Indicates if this is an ancestor index, a boolean.)rTrfs r �_HasAncestorz_BaseIndex._HasAncestors����r)c��|jS)zjReturns the index properties. a tuple of
    (index name as a string, [ASCENDING|DESCENDING]) tuples.
    )rUrfs r �_Propertiesz_BaseIndex._Properties s
����r)c�"�|j|jkS�Nre�rV�others  r �__eq__z_BaseIndex.__eq__&����9��
�"�"r)c�"�|j|jkSrorerps  r �__ne__z_BaseIndex.__ne__)rsr)c�*�t|j��Sro)�hashrQrfs r �__hash__z_BaseIndex.__hash__,s����	�?�?�r)N)�__name__�
__module__�__qualname__�range�BUILDING�SERVING�DELETING�ERRORr	�
PropertyOrderrNrOr\�staticmethodrrrMrgrirkrmrrrurxr$r)r r@r@�s�������(-�u�Q�x�x�$�(�G�X�u��+�5�)��,�7�*�!#�!#�!#�F�29�/�@�;�;�;��<�;�������������#�#�#�#�#�#�����r)r@c�J�eZdZdZejZejZej	Z
ejZdS)�IndexzA datastore index.N)
ryrzr{�__doc__r@rg�Idri�Kindrk�HasAncestorrm�
Propertiesr$r)r r�r�0s3���������~�"�	�	�$��'�+��%�*�*�*r)r�c���eZdZdZejjejejjej	ejj
ejejjej
iZejjejejjejiZd	�fd�	Zd�Zd�Zd�Zd�Zd�Z�xZS)
�DatastoreAdapterzAdapter between datatypes defined here (Entity etc.) and protobufs.

  See the base class in datastore_rpc.py for more docs.
  Nc�X��tt|���|��dSro)�superr�r\)rV�_id_resolver�	__class__s  �r r\zDatastoreAdapter.__init__Ms(���	�
�D�!�!�*�*�<�8�8�8�8�8r)c��|jSro)�_Key__reference)rVr's  r �	key_to_pbzDatastoreAdapter.key_to_pbPs����r)c�6�t�|��Sro)r+�_FromPb�rV�pbs  r �	pb_to_keyzDatastoreAdapter.pb_to_keySs���;�;�r�?�?�r)c�*�|���Sro��_ToPb)rV�entitys  r �entity_to_pbzDatastoreAdapter.entity_to_pbVs���<�<�>�>�r)c�6�t�|��Sro)r*r�r�s  r �pb_to_entityzDatastoreAdapter.pb_to_entityYs���>�>�"���r)c��|���}d�|���D��}t|���|����d��|���|��}tj�	|�
����}||fS)Nc��g|]Z}|����d��tj�|�����f��[S��utf-8)ra�decoder��index_direction_mappings�get�	direction)r&�propertys  r r(z0DatastoreAdapter.pb_to_index.<locals>.<listcomp>^sd��5�5�5���=�=�?�?�)�)�'�2�2�
�
3�
7�
7��8J�8J�8L�8L�
M�
M�O�5�5�5r)r�)�
definition�
property_listr��id�entity_typer��ancestorr��index_state_mappingsr��state)rVr��	index_defrX�indexr�s      r �pb_to_indexzDatastoreAdapter.pb_to_index\s����
�
���I�5�5�#�1�1�3�3�5�5�5�J�
�"�%�%�'�'�9�0�0�2�2�9�9�'�B�B��$�$�&�&�
�
4�
4�E��1�5�5�b�h�h�j�j�A�A�E��%�<�r)ro)ryrzr{r�r�CompositeIndexr�r��DELETEDr�
READ_WRITEr~�
WRITE_ONLYr}r��Index_PropertyrNrOr�r\r�r�r�r�r��
__classcell__�r�s@r r�r�9s�����������
"�
(�%�+�
�
"�
*�E�N�
�
"�
-�u�}�
�
"�
-�u�~�	���
"�
,�e�o�
�
"�
-�u�/?���
9�9�9�9�9�9�������������������r)r��$__DATASTORE_CONNECTION_INITIALIZED__c��tjtjt��rttd��rdSddtjfd�}tj	|t���gt_dtjt<dS)zGInternal method to make sure the connection state has been initialized.�connection_stackNc�R�|rt|���}tj||���S)N)r�)�adapter�_api_version)r�r
�
Connection)r�r�r�s   r �CreateConnectionz*__InitConnection.<locals>.CreateConnection�s2���<� �l�;�;�;�g��#�G�,�O�O�O�Or))r��1)r�GetEncodedValue�os�environ�_ENV_KEY�hasattr�
_thread_localr
�
_DATASTORE_V3�_CreateDefaultConnection�_adapterr�)r�s r �__InitConnectionr�ns�����b�j�(�3�3��
�m�/�0�0��
�F� $�$(�$1�$?�P�P�P�P��,�-=�5=�?�?�?�$�-� ��"�*�X���r)c�B�t��tjdS)zGInternal method to retrieve a datastore connection local to the thread.����r�r�r�r$r)r r:r:�s������	�	'��	+�+r)c�@�t��|tjd<dS)z?Internal method to replace the current thread local connection.r�Nr�)�
connections r �_SetConnectionr��s!������'1�-� ��$�$�$r)c�`�t��tj�|��dS)zyInternal method to save the current connection and sets a new one.

  Args:
    new_connection: The connection to set.
  N)r�r�r��append)�new_connections r �_PushConnectionr��s-������� �'�'��7�7�7�7�7r)c�|�ttj��dksJ�tj���S)z_Internal method to restores the previous connection.

  Returns:
    The current connection.
  rG)rLr�r�r5r$r)r �_PopConnectionr��s5��

�]�
+�	,�	,��	1�	1�	1�	1�	�	'�	+�	+�	-�	-�-r)c��t��}t|tj��r+|�||��|�|��|�||||��}|�|��|S)aThe APIProxy entry point for a synchronous API call.

  Args:
    service: For backwards compatibility, must be 'datastore_v3'.
    call: String representing which function to call.
    request: Protocol buffer for the request.
    response: Protocol buffer for the response.
    config: Optional Configuration to use for this request.

  Returns:
    Response protocol buffer. Caller should always use returned value
    which may or may not be same as passed in 'response'.

  Raises:
    apiproxy_errors.Error or a subclass.
  )r:rr�Query�_set_request_read_policy�_set_request_transaction�_make_rpc_call�check_rpc_success)�service�call�request�responser1�connr0s       r �
_MakeSyncCallr��s���"
�	�	�$����+�,�,�+��!�!�'�6�2�2�2��!�!�'�*�*�*����F�D�'�8�<�<�#��������	�/r)c��|dksJ�t��}d}|�tj|���}|�|��}||_|�||_|S)a�Create an rpc for use in configuring datastore calls.

  NOTE: This functions exists for backwards compatibility.  Please use
  CreateConfig() instead.  NOTE: the latter uses 'on_completion',
  which is a function taking an argument, wherease CreateRPC uses
  'callback' which is a function without arguments.

  Args:
    service: Optional string; for backwards compatibility, must be
      'datastore_v3'.
    deadline: Optional int or float, deadline for calls in seconds.
    callback: Optional callable, a callback triggered when this rpc
      completes; takes no arguments.
    read_policy: Optional read policy; set to EVENTUAL_CONSISTENCY to
      enable eventually consistent reads (i.e. reads that may be
      satisfied from an older version of the datastore in some cases).
      The default read policy may have to wait until in-flight
      transactions are committed.

  Returns:
    A UserRPC instance.
  rN)r4)r:r
r9�_create_rpc�callbackr3)r�r4r�r3r�r1r0s       r �	CreateRPCr��sj��0
�N�	"�	"�	"�	"�	�	�	�$��&�
��
�
(�(�
;�
;�
;�F����� � �#��#�,���!�C�O�	�*r)c�$�tjdi|��S)a�Create a Configuration object for use in configuring datastore calls.

  This configuration can be passed to most datastore calls using the
  'config=...' argument.

  Args:
    deadline: Optional deadline; default None (which means the
      system default deadline will be used, typically 5 seconds).
    on_completion: Optional callback function; default None.  If
      specified, it will be called with a UserRPC object as argument
      when an RPC completes.
    read_policy: Optional read policy; set to EVENTUAL_CONSISTENCY to
      enable eventually consistent reads (i.e. reads that may be
      satisfied from an older version of the datastore in some cases).
      The default read policy may have to wait until in-flight
      transactions are committed.
    **kwds: Other keyword arguments as long as they are supported by
      datastore_rpc.Configuration().

  Returns:
    A datastore_rpc.Configuration instance.
  r$)r
r9��kwdss r �CreateConfigr��s��.
�	$�	,�	,�t�	,�	,�,r)c�$�tjdi|��S)a
Create a configuration object for use in configuring transactions.

  This configuration can be passed as run_in_transaction_option's first
  argument.

  Args:
    deadline: Optional deadline; default None (which means the
      system default deadline will be used, typically 5 seconds).
    on_completion: Optional callback function; default None.  If
      specified, it will be called with a UserRPC object as argument
      when an RPC completes.
    xg: set to true to allow cross-group transactions (high replication
      datastore only)
    retries: set the number of retries for a transaction
    **kwds: Other keyword arguments as long as they are supported by
      datastore_rpc.TransactionOptions().

  Returns:
    A datastore_rpc.TransactionOptions instance.
  r$)r
�TransactionOptionsr�s r �CreateTransactionOptionsr�
s��*
�	)�	1�	1�D�	1�	1�1r)c�����|�dd���t|��}t|dd��tkrt	jd���t
�t��\���D]l}|���rt	jd|z���|�	��r|�
��st	jd|z����m���fd�}t���|�|��S)z�Asynchronously store one or more entities in the datastore.

  Identical to datastore.Put() except returns an asynchronous object. Call
  get_result() on the return value to block on the call and get the results.
  �
extra_hookNr3�1read_policy is only supported on read operations.zCannot put a partial entity: %sz-App and kind must not be empty, in entity: %sc���t|��}t���}||krtjd||fz���t�|��D]Y\}}|jj|jkr?|j���rJ�|jj�|j���Z�r|}n|d}�r�|��S|S)Nz.Put accepted %d entities but returned %d keys.r)rLr�
InternalError�zip�_Entity__keyr��has_id_or_name�CopyFrom)	r,�num_keys�num_entitiesr�r'�result�entitiesr�r-s	      ���r �local_extra_hookz"PutAsync.<locals>.local_extra_hook:s�����4�y�y�H��x�=�=�L��<����*�
:���
"�#�
$�
$�$��8�T�*�*�J�J����	�	�	,��0C�	C�	C��&�5�5�7�7�7�7�7���+�4�4�S�5H�I�I�I�����f�f��A�w�f�� �
�Z��
�
���Mr))
r5r>r8�EVENTUAL_CONSISTENCYr�BadRequestErrorr!r*�
is_projectionrE�appr:�	async_put)r�r;r1r�r�r�r-s`    @@r �PutAsyncr%s8������z�z�,��-�-�*���'�'�&��V�]�D�)�)�-A�A�A�
�
*�;�=�=�=�,�X�v�>�>��(�H��D�D�f�
�����4��,�)�F�2�
4�
4�4��;�;�=�=�D��
�
���D��,�
9�F�
B�
D�
D�D�D��������,
�	�	�	#�	#�F�H�6F�	G�	G�Gr)c�@�t|fi|�����S)aPStore one or more entities in the datastore.

  The entities may be new or previously existing. For new entities, Put() will
  fill in the app id and key assigned by the datastore.

  If the argument is a single Entity, a single Key will be returned. If the
  argument is a list of Entity, a list of Keys will be returned.

  Args:
    entities: Entity or list of Entities
    config: Optional Configuration to use for this request, must be specified
      as a keyword argument.

  Returns:
    Key or list of Keys

  Raises:
    TransactionFailedError, if the Put could not be committed.
  )r�
get_result)r�r;s  r �PutrSs&��(
�(�	%�	%�f�	%�	%�	0�	0�	2�	2�2r)c�����|�dd���t|��}t|��\}���fd�}t���|||��S)z�Asynchronously retrieves one or more entities from the datastore.

  Identical to datastore.Get() except returns an asynchronous object. Call
  get_result() on the return value to block on the call and get the results.
  r�Nc�r���r|}n#|d�tj���|d}�r�|��S|S�Nr)r�EntityNotFoundError)r�r�r�r-s  ��r r�z"GetAsync.<locals>.local_extra_hooktsQ������f�f�	�!��	��2�4�4�4���{�f�� �
�Z��
�
���Mr))r5r>r.r:�	async_get)r,r;r1r�r�r-s    @@r �GetAsyncrjsv�����z�z�,��-�-�*���'�'�&�,�T�2�2�.�$��	�	�	�	�	�	�
�	�	�	#�	#�F�D�2B�	C�	C�Cr)c�@�t|fi|�����S)aXRetrieves one or more entities from the datastore.

  Retrieves the entity or entities with the given key(s) from the datastore
  and returns them as fully populated Entity objects, as defined below. If
  there is an error, raises a subclass of datastore_errors.Error.

  If keys is a single key or string, an Entity will be returned, or
  EntityNotFoundError will be raised if no existing entity matches the key.

  However, if keys is a list or tuple, a list of entities will be returned
  that corresponds to the sequence of keys. It will include entities for keys
  that were found and None placeholders for keys that were not found.

  Args:
    keys: Key or string or list of Keys or strings
    config: Optional Configuration to use for this request, must be specified
      as a keyword argument.

  Returns:
    Entity or list of Entity objects
  )rr�r,r;s  r �Getr�s&��,
�$�	!�	!�&�	!�	!�	,�	,�	.�	.�.r)c���|�dd���t|��}�fd�}t���||��S)z�Asynchronously retrieves the application indexes and their states.

  Identical to GetIndexes() except returns an asynchronous object. Call
  get_result() on the return value to block on the call and get the results.
  r�Nc�"���r�|��S|Sror$)r�r�s �r r�z)GetIndexesAsync.<locals>.local_extra_hook�s ���� �
�Z��
�
���Mr))r5r>r:�async_get_indexes)r;r1r�r�s   @r �GetIndexesAsyncr�s]����z�z�,��-�-�*���'�'�&������

�	�	�	+�	+�F�4D�	E�	E�Er)c�>�tdi|�����S)aRetrieves the application indexes and their states.

  Args:
    config: Optional Configuration to use for this request, must be specified
      as a keyword argument.

  Returns:
    A list of (Index, Index.[BUILDING|SERVING|DELETING|ERROR]) tuples.
    An index can be in the following states:
      Index.BUILDING: Index is being built and therefore can not serve queries
      Index.SERVING: Index is ready to service queries
      Index.DELETING: Index is being deleted
      Index.ERROR: Index encounted an error in the BUILDING state
  r$)rr)r;s r �
GetIndexesr�s$��
�	"�	"�6�	"�	"�	-�	-�	/�	/�/r)c���t|��}t|dd��tkrtjd���t|��\}}t
���||��S)z�Asynchronously deletes one or more entities from the datastore.

  Identical to datastore.Delete() except returns an asynchronous object. Call
  get_result() on the return value to block on the call.
  r3Nr�)r>r8r�rr�r.r:�async_delete)r,r;r1�_s    r �DeleteAsyncr�sn�� ��'�'�&��V�]�D�)�)�-A�A�A�
�
*�;�=�=�=�%�d�+�+�'�$��	�	�	�	&�	&�v�t�	4�	4�4r)c�@�t|fi|�����S)aDeletes one or more entities from the datastore. Use with care!

  Deletes the given entity(ies) from the datastore. You can only delete
  entities from your app. If there is an error, raises a subclass of
  datastore_errors.Error.

  Args:
    # the primary key(s) of the entity(ies) to delete
    keys: Key or string or list of Keys or strings
    config: Optional Configuration to use for this request, must be specified
      as a keyword argument.

  Raises:
    TransactionFailedError, if the Delete could not be committed.
  )rrr
s  r �Deleter�s&�� 
�T�	$�	$�V�	$�	$�	/�	/�	1�	1�1r)c���eZdZdZdZddddgdfd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Ze		dd���Zedd���ZdS)r*z�A datastore entity.

  Includes read-only accessors for app id, kind, and primary key. Also
  provides dictionary-style access to properties.
  FNc�\�tj��}	tj|��}|	�|��|�dd��}
|r$t
jdt|��z���|�|
}n|
�t
jd���tj	|dtj��|��t|��}||���kr,t
jd|�d|��������|�|���}nD||���kr,t
jd|�d|��������|	�
|j��tj|��}tj|	|��|	������}|�|�d	����|�|�t
jd
���|�=tj	|d��|�|�d	����|�*tj|d��|�|��|�|��t2�|	��|_dS)
a*Constructor. Takes the kind and transaction root, which cannot be
    changed after the entity is constructed, and an optional parent. Raises
    BadArgumentError or BadKeyError if kind is invalid or parent is not an
    existing Entity or Key in the datastore.

    Args:
      # this entity's kind
      kind: string
      # if provided, this entity's parent. Its key must be complete.
      parent: Entity or Key
      # if provided, this entity's name.
      name: string
      # if provided, this entity's id.
      id: integer
      # if provided, a sequence of property names that should not be indexed
      # by the built-in single property indices.
      unindexed_properties: list or tuple of strings
      namespace: string
      # if provided, overrides the default namespace_manager setting.
    �
_namespaceNzExcess keyword arguments �6Must not set both _namespace and namespace parameters.rE� z doesn't match parent's app z" doesn't match parent's namespace r�z(Cannot set both name and id on an Entityrar�)r�	Referencer�ResolveAppId�set_appr5rr�reprrJr%r�	namespacer�r��ResolveNamespace�SetNamespace�mutable_path�add_element�set_type�encode�set_namerI�set_id�set_unindexed_propertiesr+r�r�)rVrE�parent�_apprar��unindexed_propertiesr$r��refr�	last_paths            r r\zEntity.__init__�s���6�
�
�
�C��'��-�-�D��K�K��������,��-�-�J��4��-�
%��T�
�
�
2�
4�
4�4����i�i�	�	��-�
B�
D�
D�D��"�4��#3�#D�F�F�F���%�f�-�-�f�	
������	�	��/�/�
�T�T�6�:�:�<�<�<�
!�"�"�	"�

�	��$�$�&�&�	�	���(�(�*�*�*�*��/�/�
�Y�Y��(�(�*�*�*�
,�-�-�	-�
�l�l�6�)�*�*�*��0��;�;�I�� ��i�0�0�0�� � �"�"�.�.�0�0�I�
���t�{�{�7�+�+�,�,�,���B�N��-�
4�
6�
6�6����$�T�6�2�2�2�������W�-�-�.�.�.�	�~��%�b�$�/�/�/����r�����!�!�"6�7�7�7����S�!�!�D�J�J�Jr)c�4�|j���S)zcReturns the name of the application that created this entity, a
    string or None if not set.
    )r�rrfs r rz
Entity.app@s���:�>�>���r)c�4�|j���S)z7Returns the namespace of this entity, a string or None.)r�r$rfs r r$zEntity.namespaceFs���:���!�!�!r)c�4�|j���S)z%Returns this entity's kind, a string.)r�rErfs r rEzEntity.kindJs���:�?�?���r)c���|jj������d}|���|���zo|j���S)z7Returns if this entity has been saved to the datastore.r�)r�r��path�element_list�has_name�has_idr�)rVr2s  r �is_savedzEntity.is_savedNsd���
�*�/�/�1�1�>�>�@�@��D�I�
�
�
�
!�
!�I�$4�$4�$6�$6�
6�
(��J�%�%�'�'�)r)c��|jS)a	Returns if this entity is a projection from full entity.

    Projected entities:
    - may not contain all properties from the original entity;
    - only contain single values for lists;
    - may not contain values with the same type as the original entity.
    )�_Entity__projectionrfs r r�zEntity.is_projectionTs
����r)c��|jS)z2Returns this entity's primary key, a Key instance.)r�rfs r r'z
Entity.key^s
���:�r)c�N�|������S)z\Returns this entity's parent, as a Key. If this entity has no parent,
    returns None.
    )r'r.rfs r r.z
Entity.parentbs���8�8�:�:�����r)c�N�|������S)z�Returns this entity's entity group as a Key.

    Note that the returned Key will be incomplete if this is a a root entity
    and its key is incomplete.
    )r'�entity_grouprfs r rAzEntity.entity_grouphs���8�8�:�:�"�"�$�$�$r)c�$�t|dg��S)zFReturns this entity's unindexed properties, as a frozenset of strings.�_Entity__unindexed_properties)r8rfs r r0zEntity.unindexed_propertiesps���4�8�"�=�=�=r)c���t|t��\}}|s(tjd|�dt	|���d����|D]}tj|d���t|��|_dS)Nz2unindexed_properties must be a sequence; received rr)	r!rrrrr�ValidateProperty�	frozensetrC)rVr0r-�props    r r-zEntity.set_unindexed_propertiesus���	�2�J�?�?�#��(��@��-�-�	�	�	�x�(<�=�=�=�=�	?�
@�
@�@�%�3�3���&�t�T�2�2�2�2�"+�,@�"A�"A�D���r)c�h�tj||��t�|||��dS)z�Implements the [] operator. Used to set property value(s).

    If the property name is the empty string or not a string, raises
    BadPropertyError. If the value is not a supported type, raises
    BadValueError.
    N)rrE�dict�__setitem__�rVrar]s   r rJzEntity.__setitem__�s5���$�T�5�1�1�1����T�4��'�'�'�'�'r)c�d�tj||��t�|||��S)z�If the property exists, returns its value. Otherwise sets it to value.

    If the property name is the empty string or not a string, raises
    BadPropertyError. If the value is not a supported type, raises
    BadValueError.
    )rrErI�
setdefaultrKs   r rMzEntity.setdefault�s-���$�T�5�1�1�1��?�?�4��u�-�-�-r)c�f�|���D]\}}|�||���dS)z�Updates this entity's properties from the values in other.

    If any property name is the empty string or not a string, raises
    BadPropertyError. If any value is not a supported type, raises
    BadValueError.
    N��itemsrJ)rVrqrar]s    r �updatez
Entity.update�sB���{�{�}�}�$�$���e�
���t�U�#�#�#�#�$�$r)c� �td���)�&The copy method is not supported.
    z*Entity does not support the copy() method.��NotImplementedErrorrfs r �copyzEntity.copy�s���J�
K�
K�Kr)c��dtj|�����z}|j���r,|dtjt|j����zz
}|dz
}|j���r|d|j���zz
}|���}|rB|���|dd�	|�
|����zz
}|dz
}|S)a�Returns an XML representation of this entity. Atom and gd:namespace
    properties are converted to XML according to their respective schemas. For
    more information, see:

      http://www.atomenabled.org/developers/syndication/
      https://developers.google.com/gdata/docs/1.0/elements

    This is *not* optimized. It shouldn't be used anywhere near code that's
    performance-critical.
    z<entity kind=%sz key=%s�>z
  <key>%s</key>z
  z
</entity>
)r�	quoteattrrEr�r�r_�ToTagUrir,�sortr7�_PropertiesToXml)rV�xmlrXs   r �ToXmlzEntity.ToXml�s����x�1�$�)�)�+�+�>�>�
>�C��z� � �"�"�=�	�Y��+�C��
�O�O�<�<�
<�<�c��3�J�C��z� � �"�"�9�	�
 �4�:�#6�#6�#8�#8�
8�8�c�
�����J��E��o�o����	�V�f�k�k�$�"7�"7�
�"C�"C�D�D�
D�D�c��?��C��Jr)c��	�
�g}|D]�}|�|��s�tj|��}||}t|t��r|s�Lt|t��s|g}tj|d��}tj|��}|�|��}d|�d|�d��
d�	|�	�
fd�|D��z
}��|S)z� Returns a list of the XML representations of each of the given
    properties. Ignores properties that don't exist in this entity.

    Arg:
      properties: string or list of strings

    Returns:
      list of strings
    rz<property name=z type=rXz</property>c� ��g|]
}�|z�z��Sr$r$)r&r�	close_tag�open_tags  ��r r(z+Entity._PropertiesToXml.<locals>.<listcomp>�s"���N�N�N���C��)�3�N�N�Nr))�has_keyrrYrrr�PropertyTypeName�_XmlEscapeValues)rVrX�xml_properties�propname�propname_xml�values�proptype�proptype_xml�escaped_valuesrarbs         @@r r\zEntity._PropertiesToXml�s������N��O�O��
�\�\�(�
#�
#����'��1�1�l��H�~�f�	�F�D�	!�	!��&��	�
���
%�
%����� �1�&��)�<�<�h��'��1�1�l��,�,�X�6�6�n�n�2>�,�,����M�h� �i��N�N�N�N�N�~�N�N�N�N�n�n��r)c��|�|��sJ�g}||}t|t��s|g}|D]�}t|d��r(|�|������:|�|�d���R|�t
jt|��������|S)z� Returns a list of the XML-escaped string values for the given property.
    Raises an AssertionError if the property doesn't exist.

    Arg:
      property: string

    Returns:
      list of strings
    r^N�)	rcrrr�r�r^r�escape�unicode)rVr�r]rirs     r rezEntity._XmlEscapeValues�s����<�<��!�!�!�!�!�
�C�
�(�^�F��f�d�#�#���x�f��4�4��	��g�	�	�4��
�
�3�9�9�;�;������;�

�*�*�R�.�.�.�.�

�*�*�X�_�W�S�\�\�2�2�
3�
3�
3�
3��Jr)c�,�|�d��S)zeConverts this Entity to its protocol buffer representation.

    Returns:
      entity_pb.Entity
    Fr�rfs r �ToPbzEntity.ToPbs���:�:�e���r)Tc�V�tj��}|����|��������|���������d}|r<|���r(|�	��r|�
��|���}|j�
��r`|�������d��}|����|��|���}|���|D]�\}}t%j||��}t)|t*��s|g}|D]�}	|	���r |	���t$jvs||���vr(|����|	���t|����|	������|���t<kr)t?j d|���z���|S)z�Converts this Entity to its protocol buffer representation. Not
    intended to be used by application developers.

    Returns:
      entity_pb.Entity
    r�rz*Too many indexed properties for entity %r.)!r�EntityProto�mutable_keyr�r'r�r7r8r9r:�clear_id�mutable_entity_groupr�r��elementr(rPr[r�ToPropertyPbrr�has_meaning�meaning�_RAW_PROPERTY_MEANINGSr0�raw_property_listr�r��
property_size�_MAX_INDEXED_PROPERTIESrr�)
rV�mark_key_as_savedr�r2�group�rootrXrarirGs
          r r�zEntity._ToPbsW��
�	�	 �	 �B��N�N�����d�h�h�j�j�.�.�0�0�1�1�1������
�
���,�,�.�.�r�2�I���Y�/�/�1�1��i�6F�6F�6H�6H��������
�#�#�%�%�E��z� � �"�"�)�
�V�V�X�X�]�]�_�_�
$�
$�Q�
'�
'�d������"�"�4�(�(�(������J��O�O����$�*�*���v�"�/��f�=�=�j�
�
�D�
)�
)�"� �\�
��*�*�$�
�
�
�
�
�	*�
�\�\�^�^��E�
E�
E��D�-�-�/�/�/�/�
�
�
�
 �
 �
'�
'��
-�
-�
-�
-�
�
�
�
�
�
#�
#�D�
)�
)�
)�
)�
*�
�����3�3�3��,�
6������
C�
E�
E�E��Ir)�<not specified>c��t|t��r*tj��}|�|��|}t
�|d|���S)aqStatic factory method. Returns the Entity representation of the
    given protocol buffer (datastore_pb.Entity).

    Args:
      pb: datastore_pb.Entity or str encoding of a datastore_pb.Entity
      validate_reserved_properties: deprecated
      default_kind: str, the kind to use if the pb has no key.

    Returns:
      Entity: the Entity representation of pb
    F)�require_valid_key�default_kind)rr_rrt�ParsePartialFromStringr*r�)r��validate_reserved_propertiesr��real_pbs    r �FromPbz
Entity.FromPb>sb���"�c�����%�'�'�g�
�$�$�R�(�(�(��b��>�>�
�e�,��@�@�@r)c
��|���������sR|����t
�|d�������|���������d}|r�|�	��|�
��zsJ�|�	��r|���dksJ�n,|�
��sJ�|���sJ�d�|�
��D��}|������r'|������}nd}t!t#|���d��||������|���}|jj}|�|�����i}|���|�
��fD�]9}	|	D�]2}
|
���t0jjkrd|_	t9j|
��}n^#t<t>t@tBf$r>tEj#d|
����d	tIj%�������wxYw|
�&��}|r|g}|
���}
|�'|
��}|�|||
<��|rtQ|tR��stEj#d|
z���|�*|����4��;|�+��D]F\}
}t#|
d��}t9j,||��tZ�.|||���G|S)a�Static factory method. Returns the Entity representation of the
    given protocol buffer (datastore_pb.Entity). Not intended to be used by
    application developers.

    The Entity PB's key must be complete. If it isn't, an AssertionError is
    raised.

    Args:
      # a protocol buffer Entity
      pb: datastore_pb.Entity
      default_kind: str, the kind to use if the pb has no key.

    Returns:
      # the Entity representation of the argument
      Entity
    rr�c�R�g|]$}t|���d����%Sr�)rpra)r&�ps  r r(z"Entity._FromPb.<locals>.<listcomp>us:��=�=�=� !�$�A�F�F�H�H�g�6�6�=�=�=r)rnr�)r0r/r$Tz	Property z is corrupt in the datastore:
NzfProperty %s is corrupt in the datastore; it has multiple values, but is not marked as multiply valued.)/r'r7�element_sizerur�r+�	from_pathr�r8r:r9r�rar}�has_name_space�
name_spacer*rp�typerr�r�r�r{r�Property�INDEX_VALUEr=r�FromPropertyPb�AssertionError�AttributeErrorr�
ValueErrorr�Error�	traceback�
format_excr-r�rr�extend�	iteritems�ValidateReadPropertyrIrJ)r�r�r�r2r0r$�er1�temporary_values�	prop_listrGr]r-ra�	cur_value�decoded_names                r r�zEntity._FromPbUs���&�6�6�8�8�=�=�?�?�'�'�)�)�H��n�n������
�
�l�A� >� >� D� D� F� F�G�G�G������
�
���,�,�.�.�r�2�I�� �
�
�
�
�
�)�"4�"4�"6�"6�
6�6�6�
6�	�	�	�	�	� ��|�|�~�~��"�"�"�"�"��!�!�#�#�#�#�#��~�~������=�=�%'�%9�%9�%;�%;�=�=�=��
�v�v�x�x��� � ���&�&�(�(�%�%�'�'�i�i��i��w�y�~�~�'�'��1�1�$8��F�F�H�H�L�L�N�N�i�	9�	9�	9�A��'�
!�C��L�L������������&�&�(�(�"�*>�*>�*@�*@�A�"�"�	��"�"�$��<�<�>�>�Y�/�;�;�;��!�.�	3�!�0��6�6�%�%����	�:�F�	3�	3�	3� �&�&�
�Y�Y�[�[�[�[�)�.�0�0�0�
2�3�3�3�	3����
�=�=�?�?���	��'�%��y�y�{�{��$�(�(��.�.�	���#(�
�4�
 �
 ��	"��I�t�!<�!<�	"� �&�
<�>B�
C�D�D�D��
�
�5�
!�
!�
!�
!�/"�6(�1�1�3�3�/�/���e��T�7�+�+�l�
�*�<��?�?�?�
���q�,��.�.�.�.��Hs
�)J>�>AL)T)Tr�)ryrzr{r�r=r\rr$rEr;r�r'r.rAr0r-rJrMrQrVr^r\rerrr�r�r�r�r$r)r r*r*�s����������,�"&�T���$&�$�V"�V"�V"�V"�p���"�"�"����)�)�)����������%�%�%�>�>�>�

B�
B�
B�	(�	(�	(�	.�	.�	.�$�$�$�L�L�L�
���>#�#�#�J���8���.�.�.�.�`�.2�+�@�@�@��<�@�,�W
�W
�W
��<�W
�W
�W
r)r*c��eZdZdZejjZejjZejj	Z	ejj
Z
ejjZdejj
diZe�ejj
��ejjZeddg��Zejdd�e��zejejz��ZdZdZdZdZdZd	ZdZ dZ!dZ"dZ#dZ$d
Z%dZ&d
Z'didd	ddddddddfd�Z(d
�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d�Z/d�Z0d�Z1d�Z2d�Z3d)d�Z4d�Z5d*d�Z6d+d�Z7d�Z8d�Z9d�Z:d �Z;d!�Z<d"�Z=d#�Zd$�Z>d%�Z?		d,d&�Z@d-d'�ZAd(�ZBeBZCe3ZDdS).r�aJA datastore query.

  (Instead of this, consider using appengine.ext.gql.Query! It provides a
  query language interface on top of the same functionality.)

  Queries are used to retrieve entities that match certain criteria, including
  app id, kind, and property filters. Results may also be sorted by properties.

  App id and kind are required. Only entities from the given app, of the given
  type, are returned. If an ancestor is set, with Ancestor(), only entities
  with that ancestor are returned.

  Property filters are used to provide criteria based on individual property
  values. A filter compares a specific property in each entity to a given
  value or list of possible values.

  An entity is returned if its property values match *all* of the query's
  filters. In other words, filters are combined with AND, not OR. If an
  entity does not have a value for a property used in a filter, it is not
  returned.

  Property filters map filter strings of the form '<property name> <operator>'
  to filter values. Use dictionary accessors to set property filters, like so:

  > query = Query('Person')
  > query['name ='] = 'Ryan'
  > query['age >='] = 21

  This query returns all Person entities where the name property is 'Ryan'
  and the age property is at least 21.

  Another way to build this query is:

  > query = Query('Person')
  > query.update({'name =': 'Ryan', 'age >=': 21})

  The supported operators are =, >, <, >=, and <=. Only one inequality
  filter may be used per query. Any number of equals filters may be used in
  a single Query.

  A filter value may be a list or tuple of values. This is interpreted as
  multiple filters with the same filter string and different values, all ANDed
  together. For example, this query returns everyone with the tags "google"
  and "app engine":

  > Query('Person', {'tag =': ('google', 'app engine')})

  Result entities can be returned in different orders. Use the Order()
  method to specify properties that results will be sorted by, and in which
  direction.

  Note that filters and orderings may be provided at any time before the query
  is run. When the query is fully specified, Run() runs the query and returns
  an iterator. The query results can be accessed through the iterator.

  A query object may be reused after it's been run. Its filters and
  orderings can be changed to create a modified query.

  If you know how many result entities you need, use Get() to fetch them:

  > query = Query('Person', {'age >': 21})
  > for person in query.Get(4):
  >   print 'I have four pints left. Have one on me, %s!' % person['name']

  If you don't know how many results you need, or if you need them all, you
  can get an iterator over the results by calling Run():

  > for person in Query('Person', {'age >': 21}).Run():
  >   print 'Have a pint on me, %s!' % person['name']

  Get() is more efficient than Run(), so use Get() whenever possible.

  Finally, the Count() method returns the number of result entities matched by
  the query. The returned count is cached; successive Count() calls will not
  re-scan the datastore unless the query is changed.
  �==�=�<z<=z^\s*([^\s]+)(\s+(%s)\s*)?$�|NFrTc
��|�|}n|�tjd���|� tj|dtj��||_g|_i|_|�|��tj|��|_	tj
|��|_||_tj|||||	���|_|
r:|jjstjd���d|_|jj|_dSdS)a�Constructor.

    Raises BadArgumentError if kind is not a string. Raises BadValueError or
    BadFilterError if filters is not a dictionary of valid filters.

    Args:
      namespace: string, the namespace to query.
      kind: string, the kind of entities to query, or None.
      filters: dict, initial set of filters.
      keys_only: boolean, if keys should be returned instead of entities.
      projection: iterable of property names to project.
      distinct: boolean, if projection should be distinct.
      compile: boolean, if the query should generate cursors.
      cursor: datastore_query.Cursor, the start cursor to use.
      end_cursor: datastore_query.Cursor, the end cursor to use.
      _namespace: deprecated, use namespace instead.
    NrrE)�	keys_only�produce_cursors�start_cursor�
end_cursor�
projectionz,cannot specify distinct without a projectionT)rrrrJ�_Query__kind�_Query__orderings�_Query__filter_orderrQr!�_Query__appr%�_Query__namespace�_Query__read_time_usr	�QueryOptions�_Query__query_optionsr��
BadQueryError�_Query__distinct�_Query__group_by)
rVrE�filtersr/r��compile�cursorr$r�r��distinctr�
_read_time_uss
             r r\zQuery.__init__'s2��B���i�i�	�	��-�
B�
D�
D�D����$�T�6�%5�%F�H�H�H��D�K��D���D���K�K����� �-�d�3�3�D�J�&�7�	�B�B�D��'�D��+�7���������D���8�
�
!�
,�<��,�:�<�<�	<��d�o��,�7�d�o�o�o�8�8r)c	���t|��}t|tt|������D�]c\}}t	|t
��sNt	|t��rt|��dvs(tjd|�dt|���d����t	|t
��r|f}tj|ddtj��|d}|d}|tj
tjfvrCt|��dkr$tjd	t|��z���tj
}|j�A|tjks|tj
kr!tjdtjz���||f||<��e|rI|jrB|dd|jkr+tjd|dd�d
|j�����||_|S)a�Specify how the query results should be sorted.

    Result entities will be sorted by the first property argument, then by the
    second, and so on. For example, this:

    > query = Query('Person')
    > query.Order('bday', ('age', Query.DESCENDING))

    sorts everyone in order of their birthday, starting with January 1.
    People with the same birthday are sorted by age, oldest to youngest.

    The direction for each sort property may be provided; if omitted, it
    defaults to ascending.

    Order() may be called multiple times. Each call resets the sort order
    from scratch.

    If an inequality filter exists in this Query it must be the first property
    passed to Order. Any number of sort orders may be used after the
    inequality filter property. Without inequality filters, any number of
    filters with different orders may be specified.

    Entities with multiple values for an order property are sorted by their
    lowest value.

    Note that a sort order implies an existence filter! In other words,
    Entities without the sort order property are filtered out, and *not*
    included in the query results.

    If the sort order property has different types in different entities - ie,
    if bob['id'] is an int and fred['id'] is a string - the entities will be
    grouped first by the property type, then sorted within type. No attempt is
    made to compare property values across types.

    Raises BadArgumentError if any argument is of the wrong format.

    Args:
      # the properties to sort by, in sort order. each argument may be either a
      # string or (string, direction) 2-tuple.

    Returns:
      # this query
      Query
    )rGrz4Order() expects strings or 2- or 3-tuples; received rz). rzsort order propertyr�rz:Order() expects Query.ASCENDING or DESCENDING; received %sNz:Only %s ascending orders are supported on kindless queriesznFirst ordering property must be the same as inequality filter property, if specified for this query; received z, expected )rr�r|rLrrrrrrrrJr�rNrOr_r��KEY_SPECIAL_PROPERTY�_Query__inequality_propr�)rV�	orderings�order�ir�r�s      r �OrderzQuery.Orderks��Z�Y���I��)�U�3�y�>�>�%:�%:�;�;� +� +�
�����
�+�+�$��%��'�'�$�,/��J�J�&�,@�,@��/�/��5�5�(�5�/�/�/�/�#�$�$�	$�

�E�:�	&�	&������$�U�1�X�/D�%5�%F�H�H�H��q��h���)�i�	�5�?�E�,<�=�	=�	=��u�:�:��?�?� �1�H��	�N�N�
�����O�	�
�+�
���;�;�;�
�u��
&�
&��/�H��0�
1�2�2�	2��	�*�i��l�l�	�3�d�,�3��!��Q��4�1�1�1��-�-�
�1��a����$�0�0�	2�
3�
3�3�
!�D���Kr)c�b�||jjur tj||j���|_|S)a�Sets a hint for how this query should run.

    The query hint gives us information about how best to execute your query.
    Currently, we can only do one index scan, so the query hint should be used
    to indicates which index we should scan against.

    Use FILTER_FIRST if your first filter will only match a few results. In
    this case, it will be most efficient to scan against the index for this
    property, load the results into memory, and apply the remaining filters
    and sort orders there.

    Similarly, use ANCESTOR_FIRST if the query's ancestor only has a few
    descendants. In this case, it will be most efficient to scan all entities
    below the ancestor and load them into memory first.

    Use ORDER_FIRST if the query has a sort order and the result set is large
    or you only plan to fetch the first few results. In that case, we
    shouldn't try to load all of the results into memory; instead, we should
    scan the index for this property, which is in sorted order.

    Note that hints are currently ignored in the v3 datastore!

    Arg:
      one of datastore.Query.[ORDER_FIRST, ANCESTOR_FIRST, FILTER_FIRST]

    Returns:
      # this query
      Query
    )�hintr1)r�r�r	r�)rVr�s  r �Hintz
Query.Hint�s<��<�4�'�,�,�,�,�9��D�0�2�2�2�d���Kr)c�R�t|�����|_|S)a�Sets an ancestor for this query.

    This restricts the query to only return result entities that are descended
    from a given entity. In other words, all of the results will have the
    ancestor as their parent, or parent's parent, or etc.

    Raises BadArgumentError or BadKeyError if parent is not an existing Entity
    or Key in the datastore.

    Args:
      # the key must be complete
      ancestor: Entity or Key

    Returns:
      # this query
      Query
    )r%r��_Query__ancestor_pb)rVr�s  r �AncestorzQuery.Ancestor�s%��$0��9�9�?�?�A�A�D���Kr)c��|jjS)z9Returns True if this query is keys only, false otherwise.)r�r�rfs r �
IsKeysOnlyzQuery.IsKeysOnlys����)�)r)c��|jS)z@Returns a datastore_query.QueryOptions for the current instance.)r�rfs r �GetQueryOptionszQuery.GetQueryOptionss����r)c
��tj|j|j|j|j|���|���|j|j	���S)z9Returns a datastore_query.Query for the current instance.)rr$rEr��filter_predicater��group_by�read_time_us)
r	r�r�r�r�r��GetFilterPredicate�GetOrderr�r�rfs r �GetQueryzQuery.GetQuerysZ��� �T�Z�+/�+;�&*�k�*.�*<�26�2I�2I�2K�2K�'+�}�}���*.�/�.2�.A�C�C�C�Cr)c�T�d�|jD��}|rtj|��SdS)z�Gets a datastore_query.Order for the current instance.

    Returns:
      datastore_query.Order or None if there are no sort orders set on the
      current Query.
    c�>�g|]\}}tj||����Sr$)r	r�)r&r�r�s   r r(z"Query.GetOrder.<locals>.<listcomp>s9��;�;�;�%�(�I��+�H�i�@�@�;�;�;r)N)r�r	�CompositeOrder)rV�orderss  r r�zQuery.GetOrdersA��;�;�)-�)9�;�;�;�F�
�4�
�
+�F�
3�
3�3��4r)c���d�|j���D��}|���g}|D]�\}}||vr�
||}|�||��}|�d��}|�d��}|�|dkrd}|�t
j|||������|r$t
jtjj	|��SdS)z�Returns a datastore_query.FilterPredicate for the current instance.

    Returns:
      datastore_query.FilterPredicate or None if no filters are set on the
      current Query.
    c��g|]	\}}||f��
Sr$r$)r&�fr�s   r r(z,Query.GetFilterPredicate.<locals>.<listcomp>*s ��J�J�J�$�!�Q��1�v�J�J�Jr)rHrNr�r�)
r�r�r[�_CheckFilterr�r�r	�make_filter�CompositeFilter�AND)	rV�ordered_filters�property_filtersr�
filter_strri�matchra�ops	         r r�zQuery.GetFilterPredicate"s��K�J�$�*=�*G�*G�*I�*I�J�J�J�O���������(�M�M�
��:�	�4�	�	���J��f����
�F�3�3�e�
�[�[��^�^�d��;�;�q�>�>�b�	��r�T�z�z�
�����o�9�$��F�K�K�L�L�L�L���
�
,�
�
)�
-�
�����4r)c��|jS)z|Returns True if the current instance is distinct.

    Returns:
      A boolean indicating if the distinct flag is set.
    )r�rfs r �GetDistinctzQuery.GetDistinctDs���?�r)c�F�|j}|r
|��Std���)z�Get the index list from the last run of this query.

    Returns:
      A list of indexes used by the last run of this query.

    Raises:
      AssertionError: The query has not yet been run.
    z@No index list available because this query has not been executed)�_Query__index_list_sourcer�)rV�index_list_functions  r �GetIndexListzQuery.GetIndexListLs;���2���#�
 �
 �
"�
"�"�
�)�*�*�*r)c�N�|j}|r|��}|r|Std���)a`Get the cursor from the last run of this query.

    The source of this cursor varies depending on what the last call was:
      - Run: A cursor that points immediately after the last result pulled off
        the returned iterator.
      - Get: A cursor that points immediately after the last result in the
        returned list.
      - Count: A cursor that points immediately after the last result counted.

    Returns:
      A datastore_query.Cursor object that can be used in subsequent query
      requests.

    Raises:
      AssertionError: The query has not yet been run or cannot be compiled.
    zxNo cursor available, either this query has not been executed or there is no compilation available for this kind of query)�_Query__cursor_sourcer�)rV�cursor_functionr�s   r �	GetCursorzQuery.GetCursor[sE��&�*�O����� � �f�	���
�
�<�=�=�=r)c��|����|��}|jr$|j|jkrtjd���|����t��|��S)a6Runs this query and returns a datastore_query.Batcher.

    This is not intended to be used by application developers. Use Get()
    instead!

    Args:
      config: Optional Configuration to use for this request.

    Returns:
      # an iterator that provides access to the query results
      Iterator
    z/cannot override projection when distinct is set)
r��merger�r�r�rrr��runr:)rVr1�
query_optionss   r �
GetBatcherzQuery.GetBatcherwsz�� �(�(�*�*�0�0��8�8�M���=�=�3�t��F�F�

�-�
;�
=�
=�=��=�=�?�?���~�/�/��?�?�?r)c���t|dtj���}t|�|�����}|j|_|j|_|j	|_
|S)aRuns this query.

    If a filter string is invalid, raises BadFilterError. If a filter value is
    invalid, raises BadValueError. If an IN filter is provided, and a sort
    order on another property is provided, raises BadQueryError.

    If you know in advance how many results you want, use limit=#. It's
    more efficient.

    Args:
      kwargs: Any keyword arguments accepted by datastore_query.QueryOptions().

    Returns:
      # an iterator that provides access to the query results
      Iterator
    T�r<r=�r1)r>r	r��Iteratorr�r�r�r�r��_compiled_query�_Query__compiled_query_source)rVr;r1�itrs    r �Runz	Query.Run�se��""�&�d�/>�/K�M�M�M�F�
�4�?�?�&�?�1�1�
2�
2�C�"�/�D���:�D��#&�#6�D� ��Jr)c�v�|�|�dt��t|jd||d�|����S)aZDeprecated, use list(Run(...)) instead.

    Args:
      limit: int or long representing the maximum number of entities to return.
      offset: int or long representing the number of entities to skip
      kwargs: Any keyword arguments accepted by datastore_query.QueryOptions().

    Returns:
      # a list of entities
      [Entity, ...]
    N�
batch_size��limit�offsetr$�rM�_MAX_INT_32rr��rVrrr;s    r rz	Query.Get�sF��
�}�����k�2�2�2�����>�u�V�>�>�v�>�>�?�?�?r)rc�|��|�dd��}|�t}nt||zt��}d|d<||d<t|dtj���}|�|��������fd�|_�fd	�|_	�fd
�|_
td�j|z
��S)ajReturns the number of entities that this query matches.

    Args:
      limit, a number or None. If there are more results than this, stop short
      and just return this number. Providing this argument makes the count
      operation more efficient.
      config: Optional Configuration to use for this request.

    Returns:
      The number of results.
    rrNrTr�r�c�&��d��jD��S)Nc��g|]\}}|��Sr$r$�r&r�r�s   r r(z1Query.Count.<locals>.<lambda>.<locals>.<listcomp>�s��<�<�<�<�5�%��<�<�<r))�
index_list��batchs�r �<lambda>zQuery.Count.<locals>.<lambda>�s���<�<�5�+;�<�<�<�r)c�.����d��Sr�r�rs�r r
zQuery.Count.<locals>.<lambda>�s���5�<�<��?�?�r)c����jSro)r�rs�r r
zQuery.Count.<locals>.<lambda>�s
���5�+@�r))
r5r�minr>r	r�r��nextr�r�r��max�skipped_results)rVrr;�original_offsetrr1rs      @r �CountzQuery.Count�s�����j�j��1�-�-�O��}��f�f��5�?�*�K�8�8�f��F�7�O��F�8��
!�&�d�/>�/K�M�M�M�F�
�O�O�6�O�*�*�/�/�1�1�E�<�<�<�<�	��2�2�2�2�D��#@�#@�#@�#@�D� ��q�%�'�/�9�:�:�:r)c� �td���)Nz@Query objects should not be used as iterators. Call Run() first.rTrfs r �__iter__zQuery.__iter__�s��
�H�J�J�Jr)c�V�|j���}d|d<d|d<d|d<|S)Nr�r�r�)�__dict__rV�rVr�s  r �__getstate__zQuery.__getstate__�s;���M��� � �E�)-�E�
%�&�%)�E�
!�"�-1�E�
)�*��Lr)c���d|vrgtj|�d��|�d��|�d��|�d�����|d<||_dS)Nr��_Query__keys_only�_Query__compile�_Query__cursor�_Query__end_cursor)r�r�r�r�)r	r�r5rrs  r �__setstate__zQuery.__setstate__�sw���e�+�+�'6�'C��)�)�/�0�0��	�	�"3�4�4��Y�Y�/�0�0��9�9�1�2�2�	(4�(4�(4�e�#�$�
�D�M�M�Mr)c��t|t��rt|��}tjd|��|�||��}|�d��}|�d��}t�|||��||j	vr<|tj
kr,|j�||_n
|j|ksJ�|xjdz
c_||j
vr!|j|j
|<|xjdz
c_dSdS)z�Implements the [] operator. Used to set filters.

    If the filter string is empty or not a string, raises BadFilterError. If
    the value is not a supported type, raises BadValueError.
    rrHrN)rrrrrEr�r�rIrJ�INEQUALITY_OPERATORS�)_UNAPPLIED_LOG_TIMESTAMP_SPECIAL_PROPERTYr��_Query__inequality_countr��_Query__filter_counter)rV�filterr]r�r��operators      r rJzQuery.__setitem__�s���%������5�k�k�e��$�S�%�0�0�0����f�e�,�,�E��{�{�1�~�~�H��{�{�1�~�~�H����T�6�5�)�)�)��D�-�-�-��O�M�M�M�	
�	�	'�!)�����%��1�1�1�1�
����"����T�(�(�(�$(�$9�d��&�!�
���q� �����)�(r)c��tjd|��|�||��t�|||��S)z�If the filter exists, returns its value. Otherwise sets it to value.

    If the property name is the empty string or not a string, raises
    BadPropertyError. If the value is not a supported type, raises
    BadValueError.
    r)rrEr�rIrM)rVr(r]s   r rMzQuery.setdefaultsC���$�S�%�0�0�0����f�e�$�$�$��?�?�4���/�/�/r)c�p�t�||��|j|=tj�|��}|�d��}|�d��}||jvr>|jdksJ�||j	ksJ�|xjdzc_|jdkrd|_	dSdSdS)z<Implements the del [] operator. Used to remove filters.
    rHrrN)
rI�__delitem__r�r��FILTER_REGEXr�r�r$r&r�)rVr(r�r�r)s     r r,zQuery.__delitem__s���	���T�6�"�"�"���F�#�
��$�$�V�,�,�E��{�{�1�~�~�H��{�{�1�~�~�H��4�,�,�,�
�
$��
)�
)�
)�
)�
��/�
/�
/�
/�
/�
����"���	
�	 �A�	%�	%�!%�����-�,�
&�	%r)c�f�|���D]\}}|�||���dS)z�Updates this query's filters from the ones in other.

    If any filter string is invalid, raises BadFilterError. If any value is
    not a supported type, raises BadValueError.
    NrO)rVrqr(r]s    r rQzQuery.update+sB�������&�&�
���
���v�u�%�%�%�%�&�&r)c� �td���)rSz)Query does not support the copy() method.rTrfs r rVz
Query.copy4s���I�
J�
J�Jr)c
�f�t|t��r|stjd���	tj�|��}|s$tjdt|��z���n2#t$r%tjdt|��z���wxYw|�
d��}|�
d��}|�d}t|t��rt|��}nt|t��s|g}t|dtj
��r*tjdt|d��z���||jvr�|tjkr�|jr:||jkr/tjd	d
�|j��z���t'|j��dkrF|jdd|kr/tjdd
�|j��z���|j�A|tjkr1|tjkr!tjdtjz���|tjkr[|jr!tjd
tjz���||jvr*tjd|j�dtj�d����|tjvr^|tjkrN|D]K}t|t2��s4tjtj�d|�dt|���d�����L|S)a�Type check a filter string and list of values.

    Raises BadFilterError if the filter string is empty, not a string, or
    invalid. Raises BadValueError if the value type is not supported.

    Args:
      filter: String containing the filter text.
      values: List of associated filter values.

    Returns:
      re.MatchObject (never None) that matches the 'filter'. Group 1 is the
      property name, group 3 is the operator. (Group 2 is unused.)
    zCannot filter on []z!Could not parse filter string: %srHrNr�rz,Filtering on %s properties is not supported.z=Only one property per query may have inequality filters (%s).r2zoInequality operators (%s) must be on the same property as the first sort order, if any sort orders are suppliedz0Only %s filters are allowed on kindless queries.z*Only kindless queries can have %s filters.zOnly z operators are supported with z	 filters.z& filter value must be a Key; received r�))rrr�
BadValueErrorr�r-r��BadFilterErrorr_rr�rr�_RAW_PROPERTY_TYPESrr$r%r�r7rLr�r�r��UPPERBOUND_INEQUALITY_OPERATORS�_SPECIAL_PROPERTIESr+)rVr(rir�r�r)r]s       r r�zQuery._CheckFilter9s����&�$���B��B��*�+@�A�A�A�;�� �&�&�v�.�.�e�
�=��-�
-��F���
;�=�=�	=�=���;�;�;��+�+�c�&�k�k�9�
;�
;�;�;�����{�{�1�~�~�H��{�{�1�~�~�H����h��&�%� � ���F�|�|�f�f�
���
%�
%���x�f��&��)�_�@�A�A�N��*�6��&��)�9L�9L�L�
N�
N�N�	�D�-�-�-��O�M�M�M�	
�	�2�H��0F�$F�$F��-�K��I�I�d�/�0�0�
1�2�2�	2��t�� � �A�%�%�$�*:�1�*=�a�*@�H�*L�*L��-�
@��I�I�d�/�0�0�
1�2�2�	2�
	
����O�8�8�8��O�M�M�M��+�
<�
�
.�/�
0�
0�0��?�L�L�L�	
��G��-�8��E�
F�G�G�	G���=�
=�
=��-�-��0�0�0��E�E�E�
G�H�H�	H�
�?�6�6�6�

�_�9�	9�	9��	N�	N�E��E�3�'�'�N�"�1��3�3�3�U�U�U�H�U�O�O�O�O�M�N�N�
N�N�
�Ls�AA3�3/B"c�&�|jd||||d�|��S)zDeprecated, use Run() instead.)rr�
prefetch_sizer�r$)r�)rVrr�prefetch_count�
next_countr;s      r �_Runz
Query._Run�s5���4�8��%��"0�Z������r)c��tj|���|||���}|����t��|��S)N)r1rrr�)r	r�r�r��_to_pbr:)rVrr�countr�s     r r�zQuery._ToPb�sW��#�0��#�#�%�%����	���M�
�=�=�?�?�!�!�.�"2�"2�M�B�B�Br)c�N�|j}|r|��}|r|Std���)z�Returns the internal-only pb representation of the last query run.

    Do not use.

    Raises:
      AssertionError: Query not compiled or not yet executed.
    z�No compiled query available, either this query has not been executed or there is no compilation available for this kind of query)r�r�)rV�compiled_query_function�compiled_querys   r �_GetCompiledQueryzQuery._GetCompiledQuery�sH��#�:����.�.�0�0�n�	����
�<�=�=�=r)ro�r�r)NNNN)NNN)Eryrzr{r�r	r�rNrOr��ORDER_FIRST�ANCESTOR_FIRST�FILTER_FIRST�PropertyFilter�
_OPERATORS�	OPERATORSrQ�_INEQUALITY_OPERATORSr$rFr5�rer�r7�
IGNORECASE�UNICODEr-r�r�r�r�r�r�r�r�r�r�r�r'r�r&r\r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr"rJrMr,rVr�r;r�rB�GetCompiledQuery�GetCompiledCursorr$r)r r�r��sE������K�K�Z�+�5�)��,�7�*� �,�8�+�"�/�>�.� �-�:�,��_�3�>�s�C�D�)����?�1�<�=�=�=�(�7�M��$-�I�s�D�k�$:�$:�!���� �3�8�8�I�#6�#6�6��M�B�J�� � �,��&�
�%��+��+��-��*��*����/� ��
�.������������D�D�T���$�!�B8�B8�B8�B8�H[�[�[�z!�!�!�F���**�*�*� � � �	C�	C�	C�
�
�
� � � �D���
*�
*�
*�=�=�=�8@�@�@�@�4���8@�@�@�@�";�;�;�;�:J�J�J�������!�!�!�<	0�	0�	0�&�&�&�$&�&�&�K�K�K�
P�P�P�d%)�+/�����C�C�C�C�=�=�=�"'�����r)r�c�r�|�dd��}t|��}t|dd��tkrt	jd���t
|��\}}t|��dkrt	jd���t���
||d||��}|S)z�Asynchronously allocates a range of IDs.

  Identical to datastore.AllocateIds() except returns an asynchronous object.
  Call get_result() on the return value to block on the call and get the
  results.
  rNr3r�rHz9Cannot allocate IDs for more than one model key at a timer)r5r>r8r�rr�r.rLrr:�async_allocate_ids)�	model_key�sizer;rr1r,rr0s        r �AllocateIdsAsyncrU�s���	�
�
�5�$���#���'�'�&��V�]�D�)�)�-A�A�A�
�
*�;�=�=�=�%�i�0�0�'�$����Y�Y��]�]�
�
+�C�E�E�E�	���+�+�F�D��G�T�3�G�G�#�	�*r)c�B�t||fi|�����S)axAllocates a range of IDs of size or with max for the given key.

  Allocates a range of IDs in the datastore such that those IDs will not
  be automatically assigned to new entities. You can only allocate IDs
  for model keys from your app. If there is an error, raises a subclass of
  datastore_errors.Error.

  Either size or max must be provided but not both. If size is provided then a
  range of the given size is returned. If max is provided then the largest
  range of ids that are safe to use with an upper bound of max is returned (can
  be an empty range).

  Max should only be provided if you have an existing numeric id range that you
  want to reserve, e.g. bulk loading entities that already have IDs. If you
  don't care about which IDs you receive, use size instead.

  Args:
    model_key: Key or string to serve as a model specifying the ID sequence
               in which to allocate IDs
    size: integer, number of IDs to allocate.
    max: integer, upper bound of the range of IDs to allocate.
    config: Optional Configuration to use for this request.

  Returns:
    (start, end) of the allocated range, inclusive.
  )rUr)rSrTr;s   r �AllocateIdsrW�s(��6
�)�T�	4�	4�V�	4�	4�	?�	?�	A�	A�Ar)c��eZdZdZd�Zd�Zdd�ZGd�de��Zd�Z	d	�Z
d
�Zdd�Zd
�Z
d�Zd�Zd�Zd�Zd�ZeZeZdS)�
MultiQuerya�Class representing a query which requires multiple datastore queries.

  This class is actually a subclass of datastore.Query as it is intended to act
  like a normal Query object (supporting the same interface).

  Does not support keys only queries, since it needs whole entities in order
  to merge sort them. (That's not true if there are no sort orders, or if the
  sort order is on __key__, but allowing keys only queries in those cases, but
  not in others, would be confusing.)
  c���t|��tkr+tjdtt|��fz���|o|d���j}|D][}||���jkrtjd���|���rtjd����\||_||_	||_
d|_dS)NzoCannot satisfy query -- too many subqueries (max: %d, got %d). Probable cause: too many IN/!= filters in query.rz*All queries must have the same projection.z&MultiQuery does not support keys_only.F)rL�MAX_ALLOWABLE_QUERIESrrr�r�r�r��_MultiQuery__projection�_MultiQuery__bound_queries�_MultiQuery__orderings�_MultiQuery__compile)rV�
bound_queriesr�r��querys     r r\zMultiQuery.__init__�s��
�=���1�1�1��-�>� �#�m�"4�"4�
5�6�
7�
7�7�
 �@���"�2�2�4�4�?���6�6��	�u�,�,�.�.�9�	9�	9��,�8�:�:�	:�	�	�	�	�	�6��,�4�6�6�	6�6�#�D��(�D�� �D���D�N�N�Nr)c�F�d}|jD]}|�dt|����}�|S)NzMultiQuery: r)r]r_)rV�resras   r �__str__zMultiQuery.__str__	s6��
�C��%�(�(���s�s�C��J�J�J�'�c�c��Jr)rc�v�|�|�dt��t|jd||d�|����S)a�Deprecated, use list(Run(...)) instead.

    Args:
      limit: int or long representing the maximum number of entities to return.
      offset: int or long representing the number of entities to skip
      kwargs: Any keyword arguments accepted by datastore_query.QueryOptions().

    Returns:
      A list of entities with at most "limit" entries (less if the query
      completes before reading limit values).
    Nr�rr$rrs    r rzMultiQuery.GetsF��
�}�����k�2�2�2�����>�u�V�>�>�v�>�>�?�?�?r)c�<�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	S)
�MultiQuery.SortOrderEntityz�Allow entity comparisons using provided orderings.

    The iterator passed to the constructor is eventually consumed via
    calls to GetNext(), which generate new SortOrderEntity s with the
    same orderings.
    c��||_d|_i|_	|���|_||_dS#t
$rYdSwxYw)z�Ctor.

      Args:
        entity_iterator: an iterator of entities which will be wrapped.
        orderings: an iterable of (identifier, order) pairs. order
          should be either Query.ASCENDING or Query.DESCENDING.
      N)�!_SortOrderEntity__entity_iterator�_SortOrderEntity__entity�%_SortOrderEntity__min_max_value_cacher�_SortOrderEntity__orderings�
StopIteration)rV�entity_iteratorr�s   r r\z#MultiQuery.SortOrderEntity.__init__'sg�� /�d���d�m�#%�d� �%�'�,�,�.�.��
�%�������
�
�
����
���s�9�
A�Ac�*�t|j��Sro)r_rjrfs r rdz"MultiQuery.SortOrderEntity.__str__9s��
���
�
�r)c��|jS)zGets the wrapped entity.)rjrfs r �	GetEntityz$MultiQuery.SortOrderEntity.GetEntity<s
��
�]�r)c�L�t�|j|j��S)ztWrap and return the next entity.

      The entity is retrieved from the iterator given at construction time.
      )rY�SortOrderEntityrirlrfs r �GetNextz"MultiQuery.SortOrderEntity.GetNext@s'��
�
'�
'��(>�(,�(8�:�:�:r)c��|jst|j|j��S|jD]\\}}|�|||��}|�|||��}t||��}|tjkr|}|r|cS�]dS)aVCompare two entities and return their relative order.

      Compares self to that based on the current sort orderings and the
      key orders between them. Returns negative, 0, or positive depending on
      whether self is less, equal to, or greater than that. This
      comparison returns as if all values were to be placed in ascending order
      (highest value last).  Only uses the sort orderings to compare (ignores
       keys).

      Args:
        that: SortOrderEntity

      Returns:
        Negative if self < that
        Zero if self == that
        Positive if self > that
      r)rj�cmprl�_SortOrderEntity__GetValueForIdr�rO)rV�that�
identifierr��value1�value2r�s       r �
CmpPropertiesz(MultiQuery.SortOrderEntity.CmpPropertiesHs���&�]�1��4�=�$�-�0�0�0�"&�!1�	�	�
�:�u��%�%�d�J��>�>���%�%�d�J��>�>���V�V�$�$���E�$�$�$��7�&��	��-�-�-�	�
�Qr)c�8�t|j|��}t|t��ro|j���}||f|jvr|j||f}n/|tjkrt|��}nt|��}||j||f<|Sro)
�_GetPropertyValuerjrrr'rkr�rOrr)rV�sort_order_entityry�
sort_orderr]�
entity_keys      r �__GetValueForIdz*MultiQuery.SortOrderEntity.__GetValueForIdks��� � 1� :�J�G�G�e�	�E�4�	 �	 �E�&�/�3�3�5�5�
��
�#�t�'A�A�A��,�j�*�-E�F�%�%�
�5�+�
+�
+��e�*�*�%�%��e�*�*�%�?D��"�J�
�#;�<�
�lr)c��|�|��}|r|St|j���|j�����S)a�Compare self to that w.r.t. values defined in the sort order.

      Compare an entity with another, using sort-order first, then the key
      order to break ties. This can be used in a heap to have faster min-value
      lookup.

      Args:
        that: other entity to compare to
      Returns:
        negative: if self is less than that in sort order
        zero: if self is equal to that in sort order
        positive: if self is greater than that in sort order
      )r|rvrjr')rVrx�property_compares   r �__cmp__z"MultiQuery.SortOrderEntity.__cmp__|sT���+�+�D�1�1��	�=����4�=�$�$�&�&��
�(9�(9�(;�(;�<�<�<r)N)ryrzr{r�r\rdrqrtr|rwr�r$r)r rsrgs���������%�%�%�$ � � ����:�:�:�!�!�!�F���"=�=�=�=�=r)rsc��|�dS|jpd}|j}|r1|�t||zt��}t	jd||���}|||fS)a<This function extracts the range of results to consider.

    Since MultiQuery dedupes in memory, we must apply the offset and limit in
    memory. The results that should be considered are
    results[lower_bound:upper_bound].

    We also pass the offset=0 and limit=upper_bound to the base queries to
    optimize performance.

    Args:
      config: The base datastore_query.QueryOptions.

    Returns:
      a tuple consisting of the lower_bound and upper_bound to impose in memory
      and the config to use with each bound query. The upper_bound may be None.
    N)rNNr)rrr1)rrrrr	r�)rVr1�lower_bound�upper_bounds    r �_ExtractBoundszMultiQuery._ExtractBounds�sq��"�~�
�]��-�$�1�K��,�K��;�	�	 ��+��3�[�A�A���+�1�2=�39�;�;�;�f���V�+�+r)c��tj�|��}|�|j}n|}|sdSt	��}|jD]\}}||vr|�|���|s|dfS||t|��zfS)z�Returns a tuple of (original projection, projection override).

    If projection is None, there is no projection. If override is None,
    projection is sufficent for this query.
    N)NN)r	r�r�r\�setr^�addr)rVr1r��overriderGrs      r �__GetProjectionOverridez"MultiQuery.__GetProjectionOverride�s���!�-�8�8��@�@�J����$�j�j��j���
�Z��u�u�H��#�����a�	
�Z�	�	����T�������
��
���z�E�(�O�O�3�3�3r)c�|����
��t|dtj���}|r|jrt	jd�����|��\}�}��|��\�
��rtj�|���}g}d}tj	dz
}�j
D]H}tj|d|z��|�|�
|�����|dz
}�I�
fd�����
��fd	�}||��}		t|��D]}
|	����n#t $rYnwxYw|	S)
a=Return an iterable output with all results in order.

    Merge sort the results. First create a list of iterators, then walk
    though them and yield results in order.

    Args:
      kwargs: Any keyword arguments accepted by datastore_query.QueryOptions().

    Returns:
      An iterator for the result set.
    Tr�z3keys only queries are not supported by multi-query.�r�r1rHzRunning query #%ir�c����rY|������t|��������fS|������Sro)rqr'rFr�)rr�s �r �GetDedupeKeyz$MultiQuery.Run.<locals>.GetDedupeKey�sv���	�3�!�+�+�-�-�1�1�3�3��*�4�4�6�6�@�@�B�B�C�C�E�	E�!�*�*�,�,�0�0�2�2�2r)c3�`�K�g}|D]K}t�|�j��}|���rt	j||���Lt
��}|�rI��t|���krdSt	j|��}�|��}||vr9|���}�r|�	��D]	}|�
vr||=�
|V�n	|�
|��g}|rbt	j|��}	|�|	��kr|�|	��n)|�|	�����|�b|�|�����|D]+}
|
���rt	j||
���,|��GdSdS)a�Iterator function to return all results in sorted order.

      Iterate over the array of results, yielding the next element, in
      sorted order. This function is destructive (results will be empty
      when the operation is complete).

      Args:
        results: list of result iterators to merge and iterate through

      Yields:
        The next result in sorted order.
      N)
rYrsr^rq�heapq�heappushr�rL�heappopr,r�r�rt)�results�result_heapr��
heap_value�	used_keys�
top_result�
dedupe_keyr'�results_to_pushr�
popped_resultr�r�r�rVr�s           �����r �IterateResultsz&MultiQuery.Run.<locals>.IterateResults�s������k��2�2�&��/�/���8H�I�I�
����!�!�	2�
�.��j�
1�
1�
1���%�%�i�
�'7��"�s�9�~�~��'D�'D�
�%��]�;�/�/�
�!�\�*�-�-�
��Y�&�&��'�'�)�)�&�
� ��{�{�}�}�
 �
 ���J�&�&��3�K���,�,�,�,���
�
�j�!�!�!����		3���{�+�+�$�
�<�<��-�-�
-�
-��"�"�4�(�(�(��
�"�"�4�<�<�>�>�2�2�2��		3�	���z�1�1�3�3�4�4�4�-�	7�	7�M��
$�
$�
&�
&�7��N�;�
�6�6�6��O
�'7�'7�'7�'7�'7r))r>r	r�r�rr�r��"_MultiQuery__GetProjectionOverride�logging�DEBUGr]�logr�r��xrangerrm)rVr;r1r�r�r>�	log_level�bound_queryr��itrr�r�r�r�s`          @@@@r r�zMultiQuery.Run�s��������"�&�d�/>�/K�M�M�M�F�
�A�&�"�A��,�
?�
A�
A�A�(,�':�':�6�'B�'B�$�K��f��7�7��?�?��J���P��+�x��O�O�O�f��G�
�E��
��!�I��+����
�k�)�0�5�8�9�9�9�
�n�n�[�_�_�F�_�3�3�4�4�4��q�j�e�e�3�3�3�3�3�C7�C7�C7�C7�C7�C7�C7�C7�C7�J
���	 �	 �B���k�"�"���!�
���	�	�	�	�������
�d������Is�&D,�,
D9�8D9rc��||d<t|dtj���}|�|��\}}|stjd|���}n|rtj||���}|�|��\}}}t��}|jD]�}	|	�|���D]o}
|r6|
���t|
�
����f}n|
}|�|��|rt|��|kr	||z
ccS�p��tdt|��|z
��S)a�Return the number of matched entities for this query.

    Will return the de-duplicated count of results.  Will call the more
    efficient Get() function if a limit is given.

    Args:
      limit: maximum number of entries to count (for any result > limit, return
      limit).
      config: Optional Configuration to use for this request.

    Returns:
      count of the number of entries returned.
    rTr�)r�r1r�r�r)r>r	r�r�r�r�r]r�r'rr�r�rLr)rVrr;r1r�r�r�r�r�r�r�r�s            r rzMultiQuery.CountC	sz���F�7�O�
!�&�d�/>�/K�M�M�M�F� �7�7��?�?��J���P��+�d�6�J�J�J�f�f�	�P��+�x��O�O�O�f�(,�':�':�6�'B�'B�$�K��f����I��+�
+�
+���O�O�6�O�2�2�	+�	+�&��	��
�
����f�.�.�0�0�1�1�3�*�*��*��
�
�j�!�!�!��	+�3�y�>�>�[�8�8��{�*�
*�
*�
*�
*�
*��	+��q�#�i�.�.�;�.�/�/�/r)c� �td���)NzONo index_list available for a MultiQuery (queries using "IN" or "!=" operators)�r�rfs r r�zMultiQuery.GetIndexListp	���
�9�:�:�:r)c� �td���)NzKNo cursor available for a MultiQuery (queries using "IN" or "!=" operators)r�rfs r r�zMultiQuery.GetCursoru	s��
�9�:�:�:r)c� �td���)zInternal only, do not use.zPNo compilation available for a MultiQuery (queries using "IN" or "!=" operators)r�rfs r rBzMultiQuery._GetCompiledQueryy	r�r)c��g}t|j��D]m\}}|�|�|d����	|||<�5#t	j|jd|�|��D]\}}|�|||<�
||=��xYwdS)aOAdd a new filter by setting it on all subqueries.

    If any of the setting operations raise an exception, the ones
    that succeeded are undone and the exception is propagated
    upward.

    Args:
      query_filter: a string of the form "property operand".
      value: the value that the given property is compared against.
    N)rKr]r�r��	itertools�izip)rV�query_filterr]�saved_itemsr�ra�q�	old_values        r rJzMultiQuery.__setitem__~	s����K�!�$�"6�7�7�����u�������<��6�6�7�7�7�	�#��l�����%�N�4�+?����+G�+6�8�8�	 �	 �L�A�y�
�
"�'�A�l�O�O��,���
�����s�A�6Bc�x�t|j��}d}g}t|j��D]w\}}	|�|�|d����||=�3#t
$r|dz
}Y�Dt
j|jd|�|��D]\}}|�|||<�
�xYw||krt|���dS)apDelete a filter by deleting it from all subqueries.

    If a KeyError is raised during the attempt, it is ignored, unless
    every subquery raised a KeyError. If any other exception is
    raised, any deletes will be rolled back.

    Args:
      query_filter: the filter to delete.

    Raises:
      KeyError: No subquery had an entry containing query_filter.
    rNrH)rLr]rKr�r��KeyErrorr�r�)	rVr��subquery_count�keyerror_countr�r�rar�r�s	         r r,zMultiQuery.__delitem__�	s�����-�.�.�N��N��K�!�$�"6�7�7�����u�
����5�9�9�\�4�8�8�9�9�9��,����
�����!������%�N�4�+?����+G�+6�8�8�	(�	(�L�A�y�
�
"�'�A�l�O��
������'�'��\�"�"�"�(�'s�,A � B"�11B"c�*�t|j��Sro)�iterr]rfs r rzMultiQuery.__iter__�	s����$�%�%�%r)NrCrD)ryrzr{r�r\rdr�objectrsr�r�r�rr�r�rBrJr,rrPrOr$r)r rYrY�s2������	�	����.���@�@�@�@� p=�p=�p=�p=�p=��p=�p=�p=�d,�,�,�<4�4�4�4x�x�x�t+0�+0�+0�+0�Z:�:�:�
:�:�:�:�:�:�
���2#�#�#�@&�&�&� ��&���r)rYc�$�td|g|�Ri|��S)a�Runs a function inside a datastore transaction.

     Runs the user-provided function inside transaction, retries default
     number of times.

    Args:
      function: a function to be run inside the transaction on all remaining
        arguments
      *args: positional arguments for function.
      **kwargs: keyword arguments for function.

  Returns:
    the function's return value, if any

  Raises:
    TransactionFailedError, if the transaction could not be committed.
  N��RunInTransactionOptions��function�argsr;s   r �RunInTransactionr��	s$��$
!��x�	A�$�	A�	A�	A�&�	A�	A�Ar)c�$�td|g|�Ri|��S)aURuns a function inside a read-only datastore transaction.

     A read-only transaction cannot perform writes, but may be able to execute
     more efficiently.

     Runs the user-provided function inside a read-only transaction, retries
     default number of times.

  Args:
    function: a function to be run inside the transaction on all remaining
      arguments
    *args: positional arguments for function.
    **kwargs: keyword arguments for function.

  Returns:
    the function's return value, if any

  Raises:
    TransactionFailedError, if the transaction could not be committed.
  N)�RunInReadOnlyTransactionOptionsr�s   r �RunInReadOnlyTransactionr��	s$��*
)��x�	I�$�	I�	I�	I�&�	I�	I�Ir)c�N�tj|���}t||g|�Ri|��S)a%Runs a function inside a datastore transaction.

     Runs the user-provided function inside transaction, with a specified
     number of retries.

    Args:
      retries: number of retries (not counting the initial try)
      function: a function to be run inside the transaction on all remaining
        arguments
      *args: positional arguments for function.
      **kwargs: keyword arguments for function.

  Returns:
    the function's return value, if any

  Raises:
    TransactionFailedError, if the transaction could not be committed.
  )�retries)r
r�r�)r�r�r�r;�optionss     r �RunInTransactionCustomRetriesr��	s7��&
�,�W�=�=�=�'�	 ��(�	D�T�	D�	D�	D�V�	D�	D�Dr)c�D�t|tjj|g|�Ri|��S)a4Runs a function inside a datastore transaction.

  Runs the user-provided function inside a full-featured, ACID datastore
  transaction. Every Put, Get, and Delete call in the function is made within
  the transaction. All entities involved in these calls must belong to the
  same entity group. Queries are supported as long as they specify an
  ancestor belonging to the same entity group.

  The trailing arguments are passed to the function as positional arguments.
  If the function returns a value, that value will be returned by
  RunInTransaction. Otherwise, it will return None.

  The function may raise any exception to roll back the transaction instead of
  committing it. If this happens, the transaction will be rolled back and the
  exception will be re-raised up to RunInTransaction's caller.

  If you want to roll back intentionally, but don't have an appropriate
  exception to raise, you can raise an instance of datastore_errors.Rollback.
  It will cause a rollback, but will *not* be re-raised up to the caller.

  The function may be run more than once, so it should be idempotent. It
  should avoid side effects, and it shouldn't have *any* side effects that
  aren't safe to occur multiple times. This includes modifying the arguments,
  since they persist across invocations of the function. However, this doesn't
  include Put, Get, and Delete calls, of course.

  Example usage:

  > def decrement(key, amount=1):
  >   counter = datastore.Get(key)
  >   counter['count'] -= amount
  >   if counter['count'] < 0:    # don't let the counter go negative
  >     raise datastore_errors.Rollback()
  >   datastore.Put(counter)
  >
  > counter = datastore.Query('Counter', {'name': 'foo'})
  > datastore.RunInTransaction(decrement, counter.key(), amount=5)

  Transactions satisfy the traditional ACID properties. They are:

  - Atomic. All of a transaction's operations are executed or none of them are.

  - Consistent. The datastore's state is consistent before and after a
  transaction, whether it committed or rolled back. Invariants such as
  "every entity has a primary key" are preserved.

  - Isolated. Transactions operate on a snapshot of the datastore. Other
  datastore operations do not see intermediated effects of the transaction;
  they only see its effects after it has committed.

  - Durable. On commit, all writes are persisted to the datastore.

  Nested transactions are not supported.

  Args:
    options: TransactionOptions specifying options (number of retries, etc) for
      this transaction
    function: a function to be run inside the transaction on all remaining
      arguments
      *args: positional arguments for function.
      **kwargs: keyword arguments for function.

  Returns:
    the function's return value, if any

  Raises:
    TransactionFailedError, if the transaction could not be committed.
  )�_RunInTransactionInternalr
�TransactionModer��r�r�r�r;s    r r�r�
s?��J
#�7�#0�#@�#K�#+�
>�.2�
>�
>�
>�6<�
>�
>�>r)c�D�t|tjj|g|�Ri|��S)a�Runs a function inside a read-only datastore transaction.

     A read-only transaction cannot perform writes, but may be able to execute
     more efficiently.

     Like RunInTransactionOptions, but with a read-only transaction.

  Args:
    options: TransactionOptions specifying options (number of retries, etc) for
      this transaction
    function: a function to be run inside the transaction on all remaining
      arguments
      *args: positional arguments for function.
      **kwargs: keyword arguments for function.

  Returns:
    the function's return value, if any

  Raises:
    TransactionFailedError, if the transaction could not be committed.
  )r�r
r��	READ_ONLYr�s    r r�r�P
s>��,
#�7�#0�#@�#J�#+�
>�.2�
>�
>�
>�6<�
>�
>�>r)c�B�tj|��}t��r�|jdtjjfvrtjd���|jtjjurDt��}	t|||g|�Ri|��t|��S#t|��wxYw||i|��S|jtjjurtjd���|j}|�t}t��}td��d}d}		td|dz��D]�}
|�|||��}	t#|	��t%|||��\}}|r|ct��S|
|krt'jdd��|tjjkr|	j}��	t��n#t��wxYw|	�:	|	���n$#t2$rt'jd��YnwxYwtjd	���)
z/Runs a function inside a datastore transaction.Nz&Nested transactions are not supported.z!Requires an existing transaction.rrHz%Transaction collision. Retrying... %srn�Exception sending Rollback:z9The transaction could not be committed. Please try again.)r
r��IsInTransaction�propagation�NESTEDrr��INDEPENDENTr�r�r��	MANDATORYr��DEFAULT_TRANSACTION_RETRIESr:r|�new_transactionr��	_DoOneTryr��warningr�r��transaction�rollback�	Exceptionrb�TransactionFailedError)
r��moder�r�r;�txn_connectionr�r��previous_transaction�transactional_connr��okr�s
             r r�r�k
s���
�,�W�5�5�'����%���t�]�%E�%L�M�M�M��,�
2�
4�
4�4�	�	�
� @� L�	L�	L�&�'�'�n�(�(��$�)1�D�48�D�D�D�<B�D�D�	��'�'�'�'����'�'�'�'�����8�T�$�V�$�$�$���M�<�F�F�F�
�
*�+N�
O�
O�O�
�O�'��_�)�G�	�	�	�$��$���������
�1�g��k�
"�
"�>�>���/�/��9M�04�6�6���'�(�(�(��X�t�V�4�4�j�b�&�	���
�
������
�W���	��?��D�D�D�	
��.�9�	9�	9� 2�=���#>�&������N���������#�7��!�!�#�#�#�#���7�7�7�
��5�6�6�6�6�6�7����
	�/�A�	C�	C�Cs1�8B�B*�AF>�68F>�>G�G)�)H
�	H
c�N�	||i|��}t�����rd|fSdS#t$rj	t�����n$#t$rtjd��YnwxYwtttj	��rYdS�wxYw)z�Helper to call a function in a transaction, once.

  Args:
    function: The function to call.
    *args: Tuple of positional arguments.
    **kwargs: Dict of keyword arguments.
  T)FNr�)TN)
r:�commit�original_exceptionr�r�r�rbrr�Rollback)r�r�r;r�s    r r�r��
s����
�X�t�
&�v�
&�
&�F������ � ��
�6�\��
�[��!
����7������!�!�!�!���7�7�7���5�6�6�6�6�6�	7����
�$�&6�&?�@�@��
�Z�Z�����s2�0�
B$� A�B$�A=�:B$�<A=�="B$�"B$c�D�t���|��S)aOBegin a transaction, if necessary, and populate it in the request.

  This API exists for internal backwards compatibility, primarily with
  api/taskqueue/taskqueue.py.

  Args:
    request: A protobuf with a mutable_transaction() method.
    keys: Unused.

  Returns:
    A transaction if we're inside a transaction, otherwise None
  )r:r�)r�r,s  r �_MaybeSetupTransactionr��
s��
�	�	�	2�	2�7�	;�	;�;r)c�N�tt��tj��S)zxDetermine whether already running in transaction.

  Returns:
    True if already running in transaction, else False.
  )rr:r
�TransactionalConnectionr$r)r r�r��
s��
�N�$�$�m�&K�	L�	L�Lr)c����|�t��|��S|�dd��s%|�dtjj��tjdi|����fd�}|S)a�A decorator that makes sure a function is run in a transaction.

  Defaults propagation to datastore_rpc.TransactionOptions.ALLOWED, which means
  any existing transaction will be used in place of creating a new one.

  WARNING: Reading from the datastore while in a transaction will not see any
  changes made in the same transaction. If the function being decorated relies
  on seeing all changes made in the calling scoope, set
  propagation=datastore_rpc.TransactionOptions.NESTED.

  Args:
    _func: do not use.
    **kwargs: TransactionOptions configuration options.

  Returns:
    A wrapper for the given function that creates a new transaction if needed.
  N�require_newr�c������fd�}|S)Nc�&��t��g|�Ri|��Sror�)r�r��funcr�s  ��r �
inner_wrapperz;Transactional.<locals>.outer_wrapper.<locals>.inner_wrapper
s#���
$�W�d�
B�T�
B�
B�
B�T�
B�
B�Br)r$)r�r�r�s` �r �
outer_wrapperz$Transactional.<locals>.outer_wrapper	s.����C�C�C�C�C�C��r)r$)�
Transactionalr5rMr
r��ALLOWED)�_funcr;r�r�s   @r r�r��
s����&���=�?�?�5�!�!�!�
���M�4�	(�	(�O�
���m�]�%E�%M�N�N�N��,�6�6�v�6�6�'������
�r)rHTc�D��|�t��|��S�fd�}|S)a�A decorator that insures a function is run outside a transaction.

  If there is an existing transaction (and allow_existing=True), the existing
  transaction is paused while the function is executed.

  Args:
    _func: do not use
    allow_existing: If false, throw an exception if called from within a
      transaction

  Returns:
    A wrapper for the decorated function that ensures it runs outside a
    transaction.
  Nc������fd�}|S)Nc����t��s�|i|��S�stjd���t��}	�|i|��t	|��S#t	|��wxYw)Nz4Function cannot be called from within a transaction.)r�rr�r�r�)r�r�r��allow_existingr�s   ��r r�z>NonTransactional.<locals>.outer_wrapper.<locals>.inner_wrapper%s����
�
�
�#��t�T�"�T�"�"�"�
�D��.�B�D�D�	D�
&�'�'�n�(��t�T�"�T�"�"���'�'�'�'����'�'�'�'���s�A�A%r$)r�r�r�s` �r r�z'NonTransactional.<locals>.outer_wrapper$s*����(�(�(�(�(�(��r))�NonTransactional)r�r�r�s ` r r�r�sC���"������e�$�$�$������"
�r)c���t|t��r|}n�t|t��rt|��}ngt|t��r|���}n=t|t��s(tjd|�dt|���d����t|t��sJ�|���stj	d|z���|S)z�Expects an Entity or a Key, and returns the corresponding Key. Raises
  BadArgumentError or BadKeyError if arg is a different type or is incomplete.

  Args:
    arg: Entity or Key

  Returns:
    Key
  z2Expects argument to be an Entity or Key; received rrzKey %r is not complete.)
rr+rr*r'rrrr��BadKeyError)rr's  r r%r%8s�����S���
�

�C�C��#�z�"�"��

�c�(�(�C�C��#�v����

�'�'�)�)�C�C��c�3����
�
+�
+�
�s�s�H�S�M�M�M�M�����
�C��	�	���	�

�	�	�	�	�H�
�
&�'@�3�'F�
G�
G�G�	�*r)c��|tjvrE|tjkrt|���|tjksJ�|���S||S)aXReturns an entity's value for a given property name.

  Handles special properties like __key__ as well as normal properties.

  Args:
    entity: datastore.Entity
    property: str; the property name

  Returns:
    property value. For __key__, a datastore_types.Key.

  Raises:
    KeyError, if the entity does not have the given property.
  )rr6r%r�r�r')r�r�s  r r~r~Ws[����4�4�4��?�L�L�L��X������;�;�;�;�;��:�:�<�<���(��r)c��||vr=||}t|t��r|�|��dS||g||<dS|||<dS)aNAdds the value to the existing values in the dictionary, if any.

  If dictionary[key] doesn't exist, sets dictionary[key] to value.

  If dictionary[key] is not a list, sets dictionary[key] to [old_value, value].

  If dictionary[key] is a list, appends value to that list.

  Args:
    dictionary: a dict
    key, value: anything
  N)rrr�)�
dictionaryr'r]�existing_values    r �_AddOrAppendrpsc��	�J�����_�N��.�$�'�'�0����E�"�"�"�"�"�'��/�j��o�o�o��J�s�O�O�Or)c�8��eZdZdZdd�Zd�Z�fd�ZeZeZ�xZ	S)r�zpThin wrapper of datastore_query.ResultsIterator.

  Deprecated, do not use, only for backwards compatability.
  Nc�p�|�d}g}|D],}t|��|krn|�|���-|S)N�)rLr�)rVr>r��rs    r �_NextzIterator._Next�sP���}��e�
�F�
����	�V����	�	�
���m�m�A������Mr)c�*�|���Sror)rVras  r rPzIterator.GetCompiledCursor�s���;�;�=�=�r)c�j��tt|�����}d�|D��S)z6Returns the list of indexes used to perform the query.c��g|]\}}|��Sr$r$r	s   r r(z)Iterator.GetIndexList.<locals>.<listcomp>�s��7�7�7�l�e�U�E�7�7�7r))r�r�r
)rV�tuple_index_listr�s  �r r�zIterator.GetIndexList�s4����X�t�,�,�7�7�9�9��7�7�&6�7�7�7�7r)ro)
ryrzr{r�rrPr��_Getr
r�r�s@r r�r��sg���������
�������8�8�8�8�8�

�$��*�*�*�*�*r)r�ro)rNNN)NT)`r�r�r�r�r�rL�sys�	threadingr��xml.saxr�googlecloudsdk.appengine.apirrrr�"googlecloudsdk.appengine.datastorerr	r
�2googlecloudsdk.appengine.googlestorage.onestore.v3r�googlecloudsdk.core.utilrr[�MAXIMUM_RESULTSr��
CapabilitySet�READ_CAPABILITY�WRITE_CAPABILITYr�_MAX_ID_BATCH_SIZEr+rr9�STRONG_CONSISTENCYr�rr!r.r>r�r@r��AbstractAdapterr�r��localr�r�r�r:r�r�r�r�r�r�r�rrrrrrrrrIr*r�rUrWrYr�r�r�r�r�r�r�r�r�r��_positionalr�r%r~r�ResultsIteratorr�r6�DatastoreRPC�GetRpcFromKwargs�_CurrentTransactionKey�_ToDatastoreError�)_DatastoreExceptionFromErrorCodeAndDetailr$r)r �<module>r"s��� 	�	�2
������������	�	�	�	�	�	�	�	�
�
�
�
���������������:�:�:�:�:�:�5�5�5�5�5�5�9�9�9�9�9�9�8�8�8�8�8�8�;�;�;�;�;�;�>�>�>�>�>�>�<�<�<�<�<�<�H�H�H�H�H�H�-�-�-�-�-�-����� ��-�,�,�^�<�<��-�<�-�������� ��#�5������#��#�0�C��$�2�G����1�1�1�h���..3�&3�&A�* �* �* �* �ZP�P�P�P�P��P�P�P�f&�&�&�&�&�J�&�&�&�+�+�+�+�+�}�4�+�+�+�\������	��!�!�
�2�� � � �F,�,�,�2�2�2�8�8�8�.�.�.�����4%�8<�!
�!
�!
�!
�H-�-�-�42�2�2�0+H�+H�+H�\3�3�3�.D�D�D�0/�/�/�0F�F�F�"0�0�0�"5�5�5�2�2�2�&O
�O
�O
�O
�O
�T�O
�O
�O
�d} �} �} �} �} �D�} �} �} �@
�
�
�
�,B�B�B�B�@V'�V'�V'�V'�V'��V'�V'�V'�rB�B�B�*J�J�J�6E�E�E�.G>�G>�G>�T>�>�>�6GC�GC�GC�T���:
<�
<�
<� M�M�M�!�!�!�!�H���1���$�$�$���$�N
�
�
�>���2���.������.����@!�(��'��(��!�3���;�*�)�)r)

Youez - 2016 - github.com/yon3zu
LinuXploit