
    vKgJ                         S SK r S SKrS SKJr  S SKJr  SSKJr  SSKJ	r	  SSK
Jr  SS	KJr  \R                  " \5      r " S
 S5      r " S S5      r " S S5      rg)    N)
xform_name)merge_dicts   )	docstring   )BatchAction)create_request_parameters)ResourceHandlerc                   N    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rSrg)ResourceCollection   a  
Represents a collection of resources, which can be iterated through,
optionally with filtering. Collections automatically handle pagination
for you.

See :ref:`guide_collections` for a high-level overview of collections,
including when remote service requests are performed.

:type model: :py:class:`~boto3.resources.model.Collection`
:param model: Collection model
:type parent: :py:class:`~boto3.resources.base.ServiceResource`
:param parent: The collection's parent resource
:type handler: :py:class:`~boto3.resources.response.ResourceHandler`
:param handler: The resource response handler used to create resource
                instances
c                     Xl         X l        [        UR                  R                  5      U l        X0l        [        R                  " U5      U l	        g N)
_model_parentr   request	operation_py_operation_name_handlercopydeepcopy_params)selfmodelparenthandlerkwargss        Z/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/boto3/resources/collection.py__init__ResourceCollection.__init__.   s8    ",U]]-D-D"E}}V,    c                     SR                  U R                  R                  U R                  U R                  R                  R
                   SU R                  R                  R                   35      $ Nz
{}({}, {}).	format	__class____name__r   metaservice_namer   resourcetyper   s    r   __repr__ResourceCollection.__repr__5   Y    ""NN##LL||  --.a0D0D0I0I/JK
 	
r!   c              #      #    U R                   R                  SS5      nSnU R                  5        H"  nU H  nUv   US-  nUc  M  X!:  d  M      g   M$     g7f)ai  
A generator which yields resource instances after doing the
appropriate service operation calls and handling any pagination
on your behalf.

Page size, item limit, and filter parameters are applied
if they have previously been set.

    >>> bucket = s3.Bucket('boto3')
    >>> for obj in bucket.objects.all():
    ...     print(obj.key)
    'key1'
    'key2'

limitNr   r   )r   getpages)r   r2   countpageitems        r   __iter__ResourceCollection.__iter__<   sY         $/JJLD
 
$  !s   AAA
Ac                     [         R                  " U R                  5      n[        X!SS9  U R                  " U R
                  U R                  U R                  40 UD6nU$ )a  
Create a clone of this collection. This is used by the methods
below to provide a chainable interface that returns copies
rather than the original. This allows things like:

    >>> base = collection.filter(Param1=1)
    >>> query1 = base.filter(Param2=2)
    >>> query2 = base.filter(Param3=3)
    >>> query1.params
    {'Param1': 1, 'Param2': 2}
    >>> query2.params
    {'Param1': 1, 'Param3': 3}

:rtype: :py:class:`ResourceCollection`
:return: A clone of this resource collection
Tappend_lists)r   r   r   r   r'   r   r   r   )r   r   paramsclones       r   _cloneResourceCollection._cloneY   sP    " t||,F6KKt}}
8>
 r!   c              #     #    U R                   R                  R                  nU R                  R	                  5       nUR                  SS5      nUR                  SS5      n[        U R                   U R                  R                  5      n[        XRSS9  UR                  U R                  5      (       ar  [        R                  SU R                   R                  R                  U R                  U5        UR                  U R                  5      nUR                   " SSX4S.0UD6nO\[        R                  S	U R                   R                  R                  U R                  U5        [#        XR                  5      " S0 UD6/nS
nU HZ  n	/ n
U R%                  U R                   XY5       H%  nU
R'                  U5        US-  nUc  M  X:  d  M%    O   U
v   Uc  MS  X:  d  MZ    g   g7f)a2  
A generator which yields pages of resource instances after
doing the appropriate service operation calls and handling
any pagination on your behalf. Non-paginated calls will
return a single page of items.

Page size, item limit, and filter parameters are applied
if they have previously been set.

    >>> bucket = s3.Bucket('boto3')
    >>> for page in bucket.objects.pages():
    ...     for obj in page:
    ...         print(obj.key)
    'key1'
    'key2'

:rtype: list(:py:class:`~boto3.resources.base.ServiceResource`)
:return: List of resource instances
r2   N	page_sizeTr;   zCalling paginated %s:%s with %rPaginationConfig)MaxItemsPageSizezCalling %s:%s with %rr   r    )r   r)   clientr   r   popr	   r   r   r   can_paginater   loggerdebugr*   get_paginatorpaginategetattrr   append)r   rG   cleaned_paramsr2   rB   r=   	paginatorr4   r5   r6   
page_itemsr7   s               r   r4   ResourceCollection.pagesq   s    ( ""))**,""7D1"&&{D9	*4<<9L9LMF> t6677LL1!!..''	 ,,T-D-DEI&& .3!KE
 LL'!!..''	 V%<%<=GGHE DJdllFA!!$' 
$ B   U^ s   G G&G&	G&G&!G&c                 "    U R                  5       $ )a  
Get all items from the collection, optionally with a custom
page size and item count limit.

This method returns an iterable generator which yields
individual resource instances. Example use::

    # Iterate through items
    >>> for queue in sqs.queues.all():
    ...     print(queue.url)
    'https://url1'
    'https://url2'

    # Convert to list
    >>> queues = list(sqs.queues.all())
    >>> len(queues)
    2
r?   r-   s    r   allResourceCollection.all   s    & {{}r!   c                 &    U R                   " S0 UD6$ )a,  
Get items from the collection, passing keyword arguments along
as parameters to the underlying service operation, which are
typically used to filter the results.

This method returns an iterable generator which yields
individual resource instances. Example use::

    # Iterate through items
    >>> for queue in sqs.queues.filter(Param='foo'):
    ...     print(queue.url)
    'https://url1'
    'https://url2'

    # Convert to list
    >>> queues = list(sqs.queues.filter(Param='foo'))
    >>> len(queues)
    2

:rtype: :py:class:`ResourceCollection`
rF   rU   r   r   s     r   filterResourceCollection.filter   s    , {{$V$$r!   c                      U R                  US9$ )a!  
Return at most this many resources.

    >>> for bucket in s3.buckets.limit(5):
    ...     print(bucket.name)
    'bucket1'
    'bucket2'
    'bucket3'
    'bucket4'
    'bucket5'

:type count: int
:param count: Return no more than this many items
:rtype: :py:class:`ResourceCollection`
r2   rU   r   r5   s     r   r2   ResourceCollection.limit   s      {{{''r!   c                      U R                  US9$ )z
Fetch at most this many resources per service request.

    >>> for obj in s3.Bucket('boto3').objects.page_size(100):
    ...     print(obj.key)

:type count: int
:param count: Fetch this many items per request
:rtype: :py:class:`ResourceCollection`
rB   rU   r^   s     r   rB   ResourceCollection.page_size   s     {{U{++r!   )r   r   r   r   r   N)r(   
__module____qualname____firstlineno____doc__r   r.   r8   r?   r4   rV   rZ   r2   rB   __static_attributes__rF   r!   r   r   r      s6    "-
:0GR*%0($,r!   r   c                   Z   \ rS rSrSr\rS rS rS r	S r
\R                  R                  \
l        S r\R                  R                  \l        S r\R                  R                  \l        S	 r\R                  R                  \l        S
 r\R                  R                  \l        Srg)CollectionManageri  a  
A collection manager provides access to resource collection instances,
which can be iterated and filtered. The manager exposes some
convenience functions that are also found on resource collections,
such as :py:meth:`~ResourceCollection.all` and
:py:meth:`~ResourceCollection.filter`.

Get all items::

    >>> for bucket in s3.buckets.all():
    ...     print(bucket.name)

Get only some items via filtering::

    >>> for queue in sqs.queues.filter(QueueNamePrefix='AWS'):
    ...     print(queue.url)

Get whole pages of items:

    >>> for page in s3.Bucket('boto3').objects.pages():
    ...     for obj in page:
    ...         print(obj.key)

A collection manager is not iterable. You **must** call one of the
methods that return a :py:class:`ResourceCollection` before trying
to iterate, slice, or convert to a list.

See the :ref:`guide_collections` guide for a high-level overview
of collections, including when remote service requests are performed.

:type collection_model: :py:class:`~boto3.resources.model.Collection`
:param model: Collection model

:type parent: :py:class:`~boto3.resources.base.ServiceResource`
:param parent: The collection's parent resource

:type factory: :py:class:`~boto3.resources.factory.ResourceFactory`
:param factory: The resource factory to create new resources

:type service_context: :py:class:`~boto3.utils.ServiceContext`
:param service_context: Context about the AWS service
c                     Xl         U R                   R                  R                  nX l        UR                  R
                  n[        UUUR                  UUS9U l        g )N)search_pathfactoryresource_modelservice_contextoperation_name)r   r   r   r   r+   pathr
   r   )r   collection_modelr   rl   rn   ro   rk   s          r   r   CollectionManager.__init__6  sS    &,,66&//44'#+44+)
r!   c                     SR                  U R                  R                  U R                  U R                  R                  R
                   SU R                  R                  R                   35      $ r#   r%   r-   s    r   r.   CollectionManager.__repr__D  r0   r!   c                 h    U R                   " U R                  U R                  U R                  40 UD6$ )z
Get a resource collection iterator from this manager.

:rtype: :py:class:`ResourceCollection`
:return: An iterable representing the collection of resources
)_collection_clsr   r   r   rY   s     r   iteratorCollectionManager.iteratorK  s2     ##KKt}}
8>
 	
r!   c                 "    U R                  5       $ r   rw   r-   s    r   rV   CollectionManager.allW  s    }}r!   c                 &    U R                   " S0 UD6$ )NrF   rz   rY   s     r   rZ   CollectionManager.filter\  s    }}&v&&r!   c                      U R                  US9$ )Nr]   rz   r^   s     r   r2   CollectionManager.limita  s    }}5}))r!   c                      U R                  US9$ )Nra   rz   r^   s     r   rB   CollectionManager.page_sizef  s    }}u}--r!   c                 >    U R                  5       R                  5       $ r   )rw   r4   r-   s    r   r4   CollectionManager.pagesk  s    }}$$&&r!   )r   r   r   N)r(   rc   rd   re   rf   r   rv   r   r.   rw   rV   rZ   r2   rB   r4   rg   rF   r!   r   ri   ri     s    )X )O

	
 %((00CK' (..66FN* ',,44EM. +44<<I' ',,44EMr!   ri   c                   0    \ rS rSrSrS rS rS rS rSr	g)	CollectionFactoryiq  z
A factory to create new
:py:class:`CollectionManager` and :py:class:`ResourceCollection`
subclasses from a :py:class:`~boto3.resources.model.Collection`
model. These subclasses include methods to perform batch operations.
c           	         0 nUR                   nU R                  UUUUR                  U5        U R                  UUUUR                  U[        S9  UR
                  U:X  a  UR
                   SU S3nOUR
                   SU SU S3n[        [        U5      [        4U5      nU R                  UUUUR                  U[        S9  XS'   US-  n[        [        U5      [        4U5      $ )a  
Loads a collection from a model, creating a new
:py:class:`CollectionManager` subclass
with the correct properties and methods, named based on the service
and resource name, e.g. ec2.InstanceCollectionManager. It also
creates a new :py:class:`ResourceCollection` subclass which is used
by the new manager class.

:type resource_name: string
:param resource_name: Name of the resource to look up. For services,
                      this should match the ``service_name``.

:type service_context: :py:class:`~boto3.utils.ServiceContext`
:param service_context: Context about the AWS service

:type event_emitter: :py:class:`~botocore.hooks.HierarchialEmitter`
:param event_emitter: An event emitter

:rtype: Subclass of :py:class:`CollectionManager`
:return: The collection class.
)attrsresource_namerq   service_modelevent_emitter
base_classr$   
Collectionrv   Manager)	name_load_batch_actionsr   #_load_documented_collection_methodsr   r*   r,   strri   )	r   r   rq   rn   r   r   collection_namecls_namecollection_clss	            r   load_from_definition&CollectionFactory.load_from_definitiony  s%   0 *// 	  ))	
 	00'-)77') 	1 	
 ''=8"//0/1B*M  *667qqHYYcdHc(m.@-BEJ 	00'-)77'( 	1 	
 $2 ICM$5#7??r!   c           	          UR                    H0  n[        UR                  5      nU R                  UUUUUU5      X'   M2     g)z^
Batch actions on the collection become methods on both
the collection manager and iterators.
N)batch_actionsr   r   _create_batch_action)r   r   r   rq   r   r   action_modelsnake_caseds           r   r   %CollectionFactory._load_batch_actions  sI     -::L$\%6%67K!%!:!: "E ;r!   c           	      F  ^ U4S jn[         R                  " USUUUSS9Ul        XqS'   U4S jn[         R                  " USUUUSS9Ul        XS'   U4S jn	[         R                  " USUUUSS9U	l        XS'   U4S	 jn
[         R                  " US
UUUSS9U
l        XS
'   g )Nc                 &   > TR                  U 5      $ r   )rV   )r   r   s    r   rV   BCollectionFactory._load_documented_collection_methods.<locals>.all  s    >>$''r!   rV   F)r   action_namer   rq   r   include_signaturec                 *   > TR                   " U 40 UD6$ r   )rZ   )r   r   r   s     r   rZ   ECollectionFactory._load_documented_collection_methods.<locals>.filter  s    $$T4V44r!   rZ   c                 &   > TR                  X5      $ r   r]   r   r5   r   s     r   r2   DCollectionFactory._load_documented_collection_methods.<locals>.limit   s    ##D00r!   r2   c                 &   > TR                  X5      $ r   ra   r   s     r   rB   HCollectionFactory._load_documented_collection_methods.<locals>.page_size  s    ''44r!   rB   )r   CollectionMethodDocstringrf   )factory_selfr   r   rq   r   r   r   rV   rZ   r2   rB   s         `    r   r   5CollectionFactory._load_documented_collection_methods  s     	(  99''-'#
 e	5 #<<' '-'#
 !h	1 ";;''-'#
 g	5 &??'#'-'#
	 'kr!   c           	         ^ [        U5      mU4S jn[        U5      Ul        [        R                  " UUUUUSS9Ul        U$ )z[
Creates a new method which makes a batch operation request
to the underlying service API.
c                    > T" U /UQ70 UD6$ r   rF   )r   argsr   actions      r   batch_action<CollectionFactory._create_batch_action.<locals>.batch_action*  s    $0000r!   F)r   r   batch_action_modelr   rq   r   )r   r   r(   r   BatchActionDocstringrf   )	r   r   r   r   rq   r   r   r   r   s	           @r   r   &CollectionFactory._create_batch_action  sP     \*	1 !$K 0(==''+'-# 
 r!   rF   N)
r(   rc   rd   re   rf   r   r   r   r   rg   rF   r!   r   r   r   q  s     B@H.E'Nr!   r   )r   loggingbotocorer   botocore.utilsr   docsr   r   r   r=   r	   responser
   	getLoggerr(   rJ   r   ri   r   rF   r!   r   <module>r      sU       &   - %			8	$h, h,Vg5 g5TE Er!   