
                  
       L    S r SSKJr  SSKrS/rS rS rSSSSS	SS
SS\4
S jrg)zGA helper function that executes a series of List queries for many APIs.    )encodingNYieldFromListc                     [        U[        R                  5      (       a  [        X5      $ [	        U5      S:X  a  U $ [        [        XS   5      USS 5      $ )a  Gets a possibly nested attribute.

Same as getattr() if attribute is a string;
if attribute is a tuple, returns the nested attribute referred to by
the fields in the tuple as if they were a dotted accessor path.

(ex _GetattrNested(msg, ('foo', 'bar', 'baz')) gets msg.foo.bar.baz
r      N)
isinstancesixstring_typesgetattrlen_GetattrNested)message	attributes     .lib/third_party/apitools/base/py/list_pager.pyr   r      sO     )S--..w**	Y1	gg|<imLL    c                     [        U[        R                  5      (       a  [        XU5      $ [	        U5      S:  a  [        S5      e[	        U5      S:X  a  [        XS   U5      $ [        [        XSS 5      US   U5      $ )a"  Sets a possibly nested attribute.

Same as setattr() if attribute is a string;
if attribute is a tuple, sets the nested attribute referred to by
the fields in the tuple as if they were a dotted accessor path.

(ex _SetattrNested(msg, ('foo', 'bar', 'baz'), 'v') sets msg.foo.bar.baz
to 'v'
r   zNeed an attribute to setr   N)r   r   r	   setattrr   
ValueErrorr   )r   r   values      r   _SetattrNestedr   ,   s|     )S--..w511	Y!	344	Y1	w!e44~g"~> }e- 	-r   d   Listitems	pageTokennextPageToken
maxResultsc              #     #    [         R                  " U5      n[        XS5        Ub  U(       a  U
(       a&  Uc  SnO[        XC=(       d    U5      n[        XU5        [	        X5      " UUS9nU" X5      nU(       a  [        [        X~5      5      nU H  nUv   Uc  M  US-  nU(       a  M    g   [        X5      nU(       d  g[        XU5        Uc  M  U(       a  M  gg7f)ak  Make a series of List requests, keeping track of page tokens.

Args:
  service: apitools_base.BaseApiService, A service with a .List() method.
  request: protorpc.messages.Message, The request message
      corresponding to the service's .List() method, with all the
      attributes populated except the .maxResults and .pageToken
      attributes.
  global_params: protorpc.messages.Message, The global query parameters to
       provide when calling the given method.
  limit: int, The maximum number of records to yield. None if all available
      records should be yielded.
  batch_size: int, The number of items to retrieve per request.
  method: str, The name of the method used to fetch resources.
  field: str, The field in the response that will be a list of items.
  predicate: lambda, A function that returns true for items to be yielded.
  current_token_attribute: str or tuple, The name of the attribute in a
      request message holding the page token for the page being
      requested. If a tuple, path to attribute.
  next_token_attribute: str or tuple, The name of the attribute in a
      response message holding the page token for the next page. If a
      tuple, path to the attribute.
  batch_size_attribute: str or tuple, The name of the attribute in a
      response message holding the maximum number of results to be
      returned. None if caller-specified batch size is unsupported.
      If a tuple, path to the attribute.
  get_field_func: Function that returns the items to be yielded. Argument
      is response message, and field.

Yields:
  protorpc.message.Message, The resources listed by the service.

N)global_paramsr   )r   CopyProtoMessager   minr
   listfilterr   )servicerequestr   limit
batch_sizemethodfield	predicatecurrent_token_attributenext_token_attributebatch_size_attributeget_field_funcrequest_batch_sizeresponser   itemtokens                    r   r   r   A   s     P ''0G7T:
-5 !%)"%(5Hj%I"7:LM7+G:GIx/	12EDJ}QJE5  x>w?9 -55s   B%C+&CCC)__doc__apitools.base.pyr   r   __all__r   r   r    r   r   <module>r6      sK   " N % 
 
M"-, )-DSW +,)%F@r   