o
    i                     @   sX   d dl mZmZ G dd deZG dd deZG dd deZG dd	 d	eeeZd
S )    )Iterator	iteritemsc                   @   s4   e Zd ZdZdd ZdddZdd Zdd	d
ZdS )ApiAttributez/A data descriptor that sets and returns values.c                 C   s
   || _ dS )zgCreate an instance of ApiAttribute.

    :param name: name of this attribute.
    :type name: str.
    N)name)selfr    r   J/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/pydrive/apiattr.py__init__   s   
zApiAttribute.__init__Nc                 C   s   |j | jS )z!Accesses value of this attribute.)attrgetr   )r   objtyper   r   r   __get__   s   zApiAttribute.__get__c                 C   s2   ||j | j< |j| jdurd|j| j< dS dS )zWrite value of this attribute.NTr
   r   dirtyr   )r   r   valuer   r   r   __set__   s   zApiAttribute.__set__c                 C   s6   |sdS |j | j= |j| jdur|j| j= dS dS )zDelete value of this attribute.Nr   )r   r   r   r   r   __del__   s   
zApiAttribute.__del__N)__name__
__module____qualname____doc__r	   r   r   r   r   r   r   r   r      s    
r   c                   @   s   e Zd ZdZdd ZdS )ApiAttributeMixinzBMixin to initialize required global variables to use ApiAttribute.c                 C   s   i | _ i | _d | _d S r   )r
   r   httpr   r   r   r   r	   $   s   
zApiAttributeMixin.__init__N)r   r   r   r   r	   r   r   r   r   r   !   s    r   c                       sZ   e Zd ZdZedZ fddZdd Zdd Zd	d
 Z	dd Z
dddZdd Z  ZS )ApiResourcezSuper class of all api resources.

  Inherits and behaves as a python dictionary to handle api resources.
  Save clean copy of metadata in self.metadata as a dictionary.
  Provides changed metadata elements to efficiently update api resources.
  authc                    s,   t t|   | j|i | t| | _dS )z"Create an instance of ApiResource.N)superr   r	   updatedictmetadata)r   argskwargs	__class__r   r   r	   4   s   zApiResource.__init__c                 C   s   t | |S )zOverwritten method of dictionary.

    :param key: key of the query.
    :type key: str.
    :returns: value of the query.
    )r    __getitem__)r   keyr   r   r   r&   :   s   zApiResource.__getitem__c                 C   s   t | || dS )zOverwritten method of dictionary.

    :param key: key of the query.
    :type key: str.
    :param val: value of the query.
    N)r    __setitem__)r   r'   valr   r   r   r(   C   s   zApiResource.__setitem__c                 C   s   t | }dt| j|f S )!Overwritten method of dictionary.z%s(%s))r    __repr__r   r   )r   dict_representationr   r   r   r+   L   s   
zApiResource.__repr__c                 O   s(   t t|i |D ]\}}|| |< q	dS )r*   N)r   r    )r   r"   r#   kvr   r   r   r   Q   s   
zApiResource.updateNc                 C   s   |r|  | t| | _dS )z1Update metadata and mark all of them to be clean.N)r   r    r!   )r   r!   r   r   r   UpdateMetadataV   s   
zApiResource.UpdateMetadatac                 C   sN   i }| D ] }| j |du r| | ||< q| j | | | kr$| | ||< q|S )z}Returns changed metadata elements to update api resources efficiently.

    :returns: dict -- changed metadata elements.
    N)r!   r   )r   r   r'   r   r   r   
GetChanges\   s   zApiResource.GetChangesr   )r   r   r   r   r   r   r	   r&   r(   r+   r   r/   r0   __classcell__r   r   r$   r   r   +   s    		
r   c                   @   sJ   e Zd ZdZedZdddZdd Zdd	 Zd
d Z	dd Z
dd ZdS )ApiResourceListzrAbstract class of all api list resources.

  Inherits ApiResource and builds iterator to list any API resource.
  r!   Nc                 C   s8   t |  t|  || _|   |r| | dS dS )zCreate an instance of ApiResourceList.

    :param auth: authorized GoogleAuth instance.
    :type auth: GoogleAuth.
    :param metadata: parameter to send to list command.
    :type metadata: dict.
    N)r   r	   r   r   r/   r   )r   r   r!   r   r   r   r	   q   s   

zApiResourceList.__init__c                 C   s   | S )zDReturns iterator object.

    :returns: ApiResourceList -- self
    r   r   r   r   r   __iter__   s   zApiResourceList.__iter__c                 C   s4   d| v r| d du rt |  }| jd| d< |S )zMake API call to list resources and return them.

    Auto updates 'pageToken' every time it makes API call and
    raises StopIteration when it reached the end of iteration.

    :returns: list -- list of API resources.
    :raises: StopIteration
    	pageTokenNnextPageToken)StopIteration_GetListr!   r   )r   resultr   r   r   __next__   s
   	zApiResourceList.__next__c                 C   s@   |  ddu rd| d< g }| D ]}|| q| d= |S t| S )zGet list of API resources.

    If 'maxResults' is not specified, it will automatically iterate through
    every resources available. Otherwise, it will make API call once and
    update 'pageToken'.

    :returns: list -- list of API resources.
    
maxResultsNi  )r   extendnext)r   r8   xr   r   r   GetList   s   	zApiResourceList.GetListc                 C   s   t )zqHelper function which actually makes API call.

    Should be overwritten.

    :raises: NotImplementedError
    )NotImplementedErrorr   r   r   r   r7      s   zApiResourceList._GetListc                 C   s   d| v r	| d= dS dS )zResets current iterationr4   Nr   r   r   r   r   Reset   s   
zApiResourceList.Reset)NN)r   r   r   r   r   r!   r	   r3   r9   r>   r7   r@   r   r   r   r   r2   j   s    
	r2   N)	sixr   r   objectr   r   r    r   r2   r   r   r   r   <module>   s
    
?