
|Gc        	   @   s  d  Z  d Z d d k Z y d d k l Z WnI e j
 o= y d d k Z Wqx e j
 o d d k l Z qx Xn Xd d k Z d Z	 d Z
 d Z d	 Z d
 Z d Z d Z d Z d Z d Z d Z d e f d     YZ d e f d     YZ d e f d     YZ d e i f d     YZ d e i f d     YZ d   Z d e i f d     YZ d   Z d e i f d      YZ d!   Z  d" e i! e f d#     YZ" d$   Z# d% e i$ e f d&     YZ% d'   Z& d( e i f d)     YZ' d*   Z( d+ e i f d,     YZ) d-   Z* d. e i f d/     YZ+ d0   Z, d1 e" f d2     YZ- d3   Z. d4 e i f d5     YZ/ d6   Z0 d7 e% f d8     YZ1 d9   Z2 d: e i f d;     YZ3 d<   Z4 d= e i f d>     YZ5 d?   Z6 d S(@   sr   Contains classes representing Google Data elements.

  Extends Atom classes to add Google Data specific elements.
s   api.jscudder (Jeffrey Scudder)iN(   t   cElementTree(   t   ElementTrees    http://schemas.google.com/g/2005s$   {http://schemas.google.com/g/2005}%ss'   http://a9.com/-/spec/opensearchrss/1.0/s+   {http://a9.com/-/spec/opensearchrss/1.0/}%ss%   http://schemas.google.com/gdata/batchs"   http://schemas.google.com/acl/2007s&   {http://schemas.google.com/acl/2007}%st   insertt   updatet   deletet   queryt   Errorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR   5   s   t   MissingRequiredParametersc           B   s   e  Z RS(    (   R   R   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR	   9   s   t   MediaSourcec           B   s/   e  Z d  Z d d d d d d  Z d   Z RS(   s   GData Entries can refer to media sources, so this class provides a
  place to store references to these objects along with some metadata.
  c         C   sc   | |  _  | |  _ | |  _ | |  _ | d j o. | d j	 o! | d j	 o |  i | |  n d S(   sr  Creates an object of type MediaSource.

    Args:
      file_handle: A file handle pointing to the file to be encapsulated in the
                   MediaSource
      content_type: string The MIME type of the file. Required if a file_handle
                    is given.
      content_length: int The size of the file. Required if a file_handle is
                      given.
      file_path: string (optional) A full path name to the file. Used in
                    place of a file_handle.
      file_name: string The name of the file without any path information.
                 Required if a file_handle is given.
    N(   t   file_handlet   content_typet   content_lengtht	   file_namet   Nonet   setFile(   t   selfR   R   R   t	   file_pathR   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   __init__B   s    				c         C   sI   t  | d  |  _ | |  _ t i i |  |  _ t i i |  |  _ d S(   s%  A helper function which can create a file handle from a given filename
    and set the content type and length all at once.

    Args:
      file_name: string The path and file name to the file containing the media
      content_type: string A MIME type representing the type of the media
    t   rbN(	   t   openR   R   t   ost   patht   getsizeR   t   basenameR   (   R   R   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR   \   s    		N(   R   R   t   __doc__R   R   R   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR
   =   s   	t
   LinkFinderc           B   sV   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   sX  An "interface" providing methods to find link elements

  GData Entry elements often contain multiple links which differ in the rel
  attribute or content type. Often, developers are interested in a specific
  type of link so this class provides methods to find specific classes of
  links.

  This class is used as a mixin in GData entries.
  c         C   s0   x) |  i  D] } | i d j o | Sq
 q
 Wd S(   s   Find the first link with rel set to 'self'

    Returns:
      An atom.Link or none if none of the links had rel equal to 'self'
    R   N(   t   linkt   relR   (   R   t   a_link(    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   GetSelfLinkv   s
    
 c         C   s0   x) |  i  D] } | i d j o | Sq
 q
 Wd  S(   Nt   edit(   R   R   R   (   R   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   GetEditLink   s
    
 c         C   sH   xA |  i  D]6 } | i d j o | Sn | i d j o | Sq
 q
 Wd S(   sg   The Picasa API mistakenly returns media-edit rather than edit-media, but
    this may change soon.
    s
   edit-medias
   media-editN(   R   R   R   (   R   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   GetEditMediaLink   s    
 c         C   s@   x9 |  i  D]. } | i d j o | i d j o | Sq
 q
 Wd S(   s   Find the first link with rel of alternate and type of text/html

    Returns:
      An atom.Link or None if no links matched
    t	   alternates	   text/htmlN(   R   R   t   typeR   (   R   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   GetHtmlLink   s
    
  c         C   s0   x) |  i  D] } | i d j o | Sq
 q
 Wd S(   s   Get a link containing the POST target URL.
    
    The POST target URL is used to insert new entries.

    Returns:
      A link object with a rel matching the POST type.
    s%   http://schemas.google.com/g/2005#postN(   R   R   R   (   R   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   GetPostLink   s
    
 c         C   s0   x) |  i  D] } | i d j o | Sq
 q
 Wd  S(   Ns4   http://schemas.google.com/acl/2007#accessControlList(   R   R   R   (   R   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt
   GetAclLink   s
    
 c         C   s0   x) |  i  D] } | i d j o | Sq
 q
 Wd  S(   Ns%   http://schemas.google.com/g/2005#feed(   R   R   R   (   R   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   GetFeedLink   s
    
 c         C   s0   x) |  i  D] } | i d j o | Sq
 q
 Wd  S(   Nt   next(   R   R   R   (   R   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   GetNextLink   s
    
 (   R   R   R   R   R!   R"   R%   R&   R'   R(   R*   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR   k   s   								t   TotalResultsc           B   sP   e  Z d  Z d Z e Z e i i i	   Z e i i
 i	   Z
 d d d d  Z RS(   s(   opensearch:TotalResults for a GData feedt   totalResultsc         C   s-   | |  _  | p g  |  _ | p h  |  _ d  S(   N(   t   textt   extension_elementst   extension_attributes(   R   R.   R/   R-   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR      s    	N(   R   R   R   t   _tagt   OPENSEARCH_NAMESPACEt
   _namespacet   atomt   AtomBaset	   _childrent   copyt   _attributesR   R   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR+      s   c         C   s   t  i t |   S(   N(   R3   t   CreateClassFromXMLStringR+   (   t
   xml_string(    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   TotalResultsFromString   s    t
   StartIndexc           B   sP   e  Z d  Z d Z e Z e i i i	   Z e i i
 i	   Z
 d d d d  Z RS(   s/   The opensearch:startIndex element in GData feedt
   startIndexc         C   s-   | |  _  | p g  |  _ | p h  |  _ d  S(   N(   R-   R.   R/   (   R   R.   R/   R-   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR      s    	N(   R   R   R   R0   R1   R2   R3   R4   R5   R6   R7   R   R   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR;      s   c         C   s   t  i t |   S(   N(   R3   R8   R;   (   R9   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   StartIndexFromString   s    t   ItemsPerPagec           B   sP   e  Z d  Z d Z e Z e i i i	   Z e i i
 i	   Z
 d d d d  Z RS(   s1   The opensearch:itemsPerPage element in GData feedt   itemsPerPagec         C   s-   | |  _  | p g  |  _ | p h  |  _ d  S(   N(   R-   R.   R/   (   R   R.   R/   R-   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR      s    	N(   R   R   R   R0   R1   R2   R3   R4   R5   R6   R7   R   R   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR>      s   c         C   s   t  i t |   S(   N(   R3   R8   R>   (   R9   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   ItemsPerPageFromString   s    t
   GDataEntryc           B   s}   e  Z d  Z e i i Z e i i Z e i i i   Z e i i	 i   Z	 d   Z
 d   Z e e
 e  Z d   Z d   Z RS(   s-   Extends Atom Entry to provide data processingc         C   s   |  i  S(   N(   t   _GDataEntry__id(   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   __GetId   s    c         C   s3   | |  _  | d  j	 o | i i   |  i  _ n d  S(   N(   RB   R   R-   t   strip(   R   t   id(    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   __SetId  s    	c         C   s   |  i    o t Sn t Sd S(   s?   Determines whether or not an entry is a GData Media entry.
    N(   R"   t   Truet   False(   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   IsMedia  s    c         C   s#   |  i    p d Sn |  i i Sd S(   se   Returns the URL to the media content, if the entry is a media entry.
    Otherwise returns None.
    N(   RI   R   t   contentt   src(   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   GetMediaURL  s    (   R   R   R   R3   t   EntryR0   R2   R5   R6   R7   t   _GDataEntry__GetIdt   _GDataEntry__SetIdt   propertyRE   RI   RL   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyRA      s   			c         C   s   t  i t |   S(   s8   Creates a new GDataEntry instance given a string of XML.(   R3   R8   RA   (   R9   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   GDataEntryFromString  s    t	   GDataFeedc           B   s  e  Z d  Z d Z e i Z e i i i	   Z e i i
 i	   Z
 d e f e d e <d e f e d e <d e f e d e <d e g f e d	 e i <d
   Z d   Z e e e  Z d   Z d   Z e e e  Z d d d d d d d d d d d d d d d d d d d d  Z RS(   s   A Feed from a GData servicet   feedt   total_resultss   {%s}totalResultst   start_indexs   {%s}startIndext   items_per_pages   {%s}itemsPerPaget   entrys	   {%s}entryc         C   s   |  i  S(   N(   t   _GDataFeed__id(   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyRC   3  s    c         C   s3   | |  _  | d  j	 o | i i   |  i  _ n d  S(   N(   RX   R   R-   RD   (   R   RE   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyRF   6  s    	c         C   s   |  i  S(   N(   t   _GDataFeed__generator(   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   __GetGenerator=  s    c         C   s3   | |  _  | d  j	 o | i i   |  i  _ n d  S(   N(   RY   R   R-   RD   (   R   t	   generator(    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   __SetGenerator@  s    	c         C   s   | p g  |  _  | p g  |  _ | p g  |  _ | |  _ | |  _ | |  _ | p g  |  _ | |  _ |	 |  _ |
 |  _	 | |  _
 | |  _ | p g  |  _ | |  _ | |  _ | |  _ | |  _ | p g  |  _ | p h  |  _ d S(   s  Constructor for Source
    
    Args:
      author: list (optional) A list of Author instances which belong to this
          class.
      category: list (optional) A list of Category instances
      contributor: list (optional) A list on Contributor instances
      generator: Generator (optional) 
      icon: Icon (optional) 
      id: Id (optional) The entry's Id element
      link: list (optional) A list of Link instances
      logo: Logo (optional) 
      rights: Rights (optional) The entry's Rights element
      subtitle: Subtitle (optional) The entry's subtitle element
      title: Title (optional) the entry's title element
      updated: Updated (optional) the entry's updated element
      entry: list (optional) A list of the Entry instances contained in the 
          feed.
      text: String (optional) The text contents of the element. This is the 
          contents of the Entry's XML text node. 
          (Example: <foo>This is the text</foo>)
      extension_elements: list (optional) A list of ExtensionElement instances
          which are children of this element.
      extension_attributes: dict (optional) A dictionary of strings which are 
          the values for additional XML attributes of this element.
    N(   t   authort   categoryt   contributorR[   t   iconRE   R   t   logot   rightst   subtitlet   titlet   updatedRW   RT   RU   RV   R-   R.   R/   (   R   R]   R^   R_   R[   R`   t   atom_idR   Ra   Rb   Rc   Rd   Re   RW   RT   RU   RV   R.   R/   R-   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR   G  s&     												N(   R   R   R   R0   R3   t   ATOM_NAMESPACER2   t   FeedR5   R6   R7   R+   R1   R;   R>   RA   t   _GDataFeed__GetIdt   _GDataFeed__SetIdRP   RE   t   _GDataFeed__GetGeneratort   _GDataFeed__SetGeneratorR[   R   R   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyRR   "  s.   							c         C   s   t  i t |   S(   N(   R3   R8   RR   (   R9   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   GDataFeedFromString|  s    t   BatchIdc           B   s8   e  Z d  Z e Z e i i i   Z e i i	 i   Z	 RS(   RE   (
   R   R   R0   t   BATCH_NAMESPACER2   R3   R4   R5   R6   R7   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyRn     s   c         C   s   t  i t |   S(   N(   R3   R8   Rn   (   R9   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   BatchIdFromString  s    t   BatchOperationc           B   sW   e  Z d  Z e Z e i i i   Z e i i	 i   Z	 d e	 d <d d d d d  Z RS(   t	   operationR$   c         C   s/   | |  _  t i i |  d | d | d | d  S(   NR.   R/   R-   (   R$   R3   R4   R   (   R   t   op_typeR.   R/   R-   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR     s
    	N(   R   R   R0   Ro   R2   R3   R4   R5   R6   R7   R   R   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyRq     s   
c         C   s   t  i t |   S(   N(   R3   R8   Rq   (   R9   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   BatchOperationFromString  s    t   BatchStatusc           B   sw   e  Z d  Z d Z e Z e i i i	   Z e i i
 i	   Z
 d e
 d <d e
 d <d e
 d <d d d d d d d  Z RS(   s  The batch:status element present in a batch response entry.
  
  A status element contains the code (HTTP response code) and 
  reason as elements. In a single request these fields would
  be part of the HTTP response, but in a batch request each
  Entry operation has a corresponding Entry in the response
  feed which includes status information.

  See http://code.google.com/apis/gdata/batch.html#Handling_Errors
  t   statust   codet   reasonR   s   content-typec         C   sA   | |  _  | |  _ | |  _ t i i |  d | d | d | d  S(   NR.   R/   R-   (   Rw   Rx   R   R3   R4   R   (   R   Rw   Rx   R   R.   R/   R-   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR     s    			N(   R   R   R   R0   Ro   R2   R3   R4   R5   R6   R7   R   R   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyRu     s   



	c         C   s   t  i t |   S(   N(   R3   R8   Ru   (   R9   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   BatchStatusFromString  s    t
   BatchEntryc           B   s   e  Z d  Z e i Z e i Z e i i   Z d e f e d e	 <d e
 f e d e	 <d e f e d e	 <e i i   Z d d d d d d d d d d d d d d d d d d d d  Z RS(	   s:  An atom:entry for use in batch requests.

  The BatchEntry contains additional members to specify the operation to be
  performed on this entry and a batch ID so that the server can reference
  individual operations in the response feed. For more information, see:
  http://code.google.com/apis/gdata/batch.html
  t   batch_operations   {%s}operationt   batch_ids   {%s}idt   batch_statuss
   {%s}statusc      "   C   s   | |  _  | |  _ | |  _ t i |  d | d | d | d | d | d | d | d | d	 |	 d
 |
 d | d | d | d | d | d | d  S(   NR]   R^   RJ   R_   Rf   R   t	   publishedRb   t   sourcet   summaryt   controlRd   Re   R.   R/   R-   (   R{   R|   R}   RA   R   (   R   R]   R^   RJ   R_   Rf   R   R~   Rb   R   R   R   Rd   Re   R{   R|   R}   R.   R/   R-   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR     s    			N(   R   R   R   RA   R0   R2   R5   R6   Rq   Ro   Rn   Ru   R7   R   R   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyRz     s   				c         C   s   t  i t |   S(   N(   R3   R8   Rz   (   R9   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   BatchEntryFromString  s    t   BatchInterruptedc           B   s   e  Z d  Z d Z e Z e i i i	   Z e i i
 i	   Z
 d e
 d <d e
 d <d e
 d <d e
 d <d d d d d d d d  Z RS(   s   The batch:interrupted element sent if batch request was interrupted.
  
  Only appears in a feed if some of the batch entries could not be processed.
  See: http://code.google.com/apis/gdata/batch.html#Handling_Errors
  t   interruptedRx   t   successt   failurest   parsedc         C   sJ   | |  _  | |  _ | |  _ | |  _ t i i |  d | d | d | d  S(   NR.   R/   R-   (   Rx   R   R   R   R3   R4   R   (   R   Rx   R   R   R   R.   R/   R-   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR     s    				N(   R   R   R   R0   Ro   R2   R3   R4   R5   R6   R7   R   R   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR     s   



c         C   s   t  i t |   S(   N(   R3   R8   R   (   R9   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   BatchInterruptedFromString  s    t	   BatchFeedc           B   s  e  Z d  Z e i Z e i Z e i i   Z e i i   Z d e	 g f e d e
 i <d e f e d e <d d d d d d d d d d d d d d d d d d d d d  Z d d d d d  Z d d  Z d d  Z d d d d	  Z d d d d
  Z d   Z RS(   s2   A feed containing a list of batch request entries.RW   s	   {%s}entryR   s   {%s}interruptedc      (   C   s   | |  _  t i |  d | d | d | d | d | d | d | d | d	 |	 d
 |
 d | d | d | d | d | d | d | d | d | d  S(   NR]   R^   R_   R[   R`   Rf   R   Ra   Rb   Rc   Rd   Re   RW   RT   RU   RV   R.   R/   R-   (   R   RR   R   (   R   R]   R^   R_   R[   R`   Rf   R   Ra   Rb   Rc   Rd   Re   RW   RT   RU   RV   R   R.   R/   R-   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR     s    	c         C   s  | d j o | d j o t d   n | d j o, | d j	 o t d t i d |   } n | d j	 o t d |  | _ nI | i d j p | i i d j o% t d t t	 |  i
    | _ n | d j	 o t d |  | _ n |  i
 i |  | S(   sL  Logic for populating members of a BatchEntry and adding to the feed.

    
    If the entry is not a BatchEntry, it is converted to a BatchEntry so
    that the batch specific members will be present. 

    The id_url_string can be used in place of an entry if the batch operation
    applies to a URL. For example query and delete operations require just
    the URL of an entry, no body is sent in the HTTP request. If an
    id_url_string is sent instead of an entry, a BatchEntry is created and
    added to the feed.

    This method also assigns the desired batch id to the entry so that it 
    can be referenced in the server's response. If the batch_id_string is
    None, this method will assign a batch_id to be the index at which this
    entry will be in the feed's entry list.
    
    Args:
      entry: BatchEntry, atom.Entry, or another Entry flavor (optional) The
          entry which will be sent to the server as part of the batch request.
          The item must have a valid atom id so that the server knows which 
          entry this request references.
      id_url_string: str (optional) The URL of the entry to be acted on. You
          can find this URL in the text member of the atom id for an entry.
          If an entry is not sent, this id will be used to construct a new
          BatchEntry which will be added to the request feed.
      batch_id_string: str (optional) The batch ID to be used to reference
          this batch operation in the results feed. If this parameter is None,
          the current length of the feed's entry array will be used as a
          count. Note that batch_ids should either always be specified or
          never, mixing could potentially result in duplicate batch ids.
      operation_string: str (optional) The desired batch operation which will
          set the batch_operation.type member of the entry. Options are
          'insert', 'update', 'delete', and 'query'
    
    Raises:
      MissingRequiredParameters: Raised if neither an id_ url_string nor an
          entry are provided in the request.

    Returns:
      The added entry.
    s$   supply either an entry or URL stringRf   R-   Rs   N(   R   R	   Rz   R3   t   IdRn   R|   R-   t   strt   lenRW   Rq   R{   t   append(   R   RW   t   id_url_stringt   batch_id_stringt   operation_string(    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   AddBatchEntry"  s    ,#%c         C   s"   |  i  d | d | d t  } d S(   s  Add an insert request to the operations in this batch request feed.

    If the entry doesn't yet have an operation or a batch id, these will
    be set to the insert operation and a batch_id specified as a parameter.

    Args:
      entry: BatchEntry The entry which will be sent in the batch feed as an
          insert request.
      batch_id_string: str (optional) The batch ID to be used to reference
          this batch operation in the results feed. If this parameter is None,
          the current length of the feed's entry array will be used as a
          count. Note that batch_ids should either always be specified or
          never, mixing could potentially result in duplicate batch ids.
    RW   R   R   N(   R   t   BATCH_INSERT(   R   RW   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt	   AddInsert^  s    c         C   s"   |  i  d | d | d t  } d S(   s  Add an update request to the list of batch operations in this feed.

    Sets the operation type of the entry to insert if it is not already set
    and assigns the desired batch id to the entry so that it can be 
    referenced in the server's response.

    Args:
      entry: BatchEntry The entry which will be sent to the server as an
          update (HTTP PUT) request. The item must have a valid atom id
          so that the server knows which entry to replace.
      batch_id_string: str (optional) The batch ID to be used to reference
          this batch operation in the results feed. If this parameter is None,
          the current length of the feed's entry array will be used as a
          count. See also comments for AddInsert.
    RW   R   R   N(   R   t   BATCH_UPDATE(   R   RW   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt	   AddUpdatep  s    c      	   C   s(   |  i  d | d | d | d t  } d S(   s  Adds a delete request to the batch request feed.

    This method takes either the url_string which is the atom id of the item
    to be deleted, or the entry itself. The atom id of the entry must be 
    present so that the server knows which entry should be deleted.

    Args:
      url_string: str (optional) The URL of the entry to be deleted. You can
         find this URL in the text member of the atom id for an entry. 
      entry: BatchEntry (optional) The entry to be deleted.
      batch_id_string: str (optional)

    Raises:
      MissingRequiredParameters: Raised if neither a url_string nor an entry 
          are provided in the request. 
    RW   R   R   R   N(   R   t   BATCH_DELETE(   R   t
   url_stringRW   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt	   AddDelete  s    c      	   C   s(   |  i  d | d | d | d t  } d S(   s  Adds a query request to the batch request feed.

    This method takes either the url_string which is the query URL 
    whose results will be added to the result feed. The query URL will
    be encapsulated in a BatchEntry, and you may pass in the BatchEntry
    with a query URL instead of sending a url_string.

    Args:
      url_string: str (optional)
      entry: BatchEntry (optional)
      batch_id_string: str (optional)

    Raises:
      MissingRequiredParameters
    RW   R   R   R   N(   R   t   BATCH_QUERY(   R   R   RW   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   AddQuery  s    c         C   s0   x) |  i  D] } | i d j o | Sq
 q
 Wd  S(   Ns&   http://schemas.google.com/g/2005#batch(   R   R   R   (   R   R   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   GetBatchLink  s
    
 N(   R   R   R   RR   R0   R2   R5   R6   R7   Rz   R3   Rg   R   Ro   R   R   R   R   R   R   R   R   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR     s(   				;c         C   s   t  i t |   S(   N(   R3   R8   R   (   R9   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   BatchFeedFromString  s    t	   EntryLinkc           B   s   e  Z d  Z d Z e Z e i i i	   Z e i i
 i	   Z
 d e f e d e i <d	 e
 d <d e
 d <d e
 d <d
 d
 d
 d
 d
 d
 d
 d  Z RS(   s   The gd:entryLink elementt	   entryLinkRW   s	   {%s}entryR   t	   read_onlyt   readOnlyt   hrefc         C   sQ   | |  _  | |  _ | |  _ | |  _ | |  _ | p g  |  _ | p h  |  _ d  S(   N(   R   R   R   RW   R-   R.   R/   (   R   R   R   R   RW   R.   R/   R-   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR     s    					(   s   relN(   R   R   R   R0   t   GDATA_NAMESPACER2   R3   R4   R5   R6   R7   RA   Rg   R   R   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR     s   


	c         C   s   t  i t |   S(   N(   R3   R8   R   (   R9   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   EntryLinkFromString  s    t   FeedLinkc        	   B   s   e  Z d  Z d Z e Z e i i i	   Z e i i
 i	   Z
 d e f e d e i <d e
 d <d e
 d <d e
 d <d	 e
 d	 <d d d d d d d d d
  Z RS(   s   The gd:feedLink elementt   feedLinkRS   s   {%s}feedR   R   R   t
   count_hintt	   countHintR   c	   	      C   sZ   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | p g  |  _ | p h  |  _ d  S(   N(   R   R   R   R   RS   R-   R.   R/   (	   R   R   R   R   R   RS   R.   R/   R-   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR     s    						N(   R   R   R   R0   R   R2   R3   R4   R5   R6   R7   RR   Rg   R   R   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyR     s   



	c         C   s   t  i t |   S(   N(   R3   R8   R   (   R9   (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pyt   FeedLinkFromString  s    (7   R   t
   __author__R   t	   xml.etreeR    R   t   ImportErrort   elementtreeR3   R   t   GDATA_TEMPLATER1   t   OPENSEARCH_TEMPLATERo   t   GACL_NAMESPACEt   GACL_TEMPLATER   R   R   R   t	   ExceptionR   R	   t   objectR
   R   R4   R+   R:   R;   R=   R>   R@   RM   RA   RQ   Rh   RR   Rm   Rn   Rp   Rq   Rt   Ru   Ry   Rz   R   R   R   R   R   R   R   R   R   (    (    (    sB   /afs/sipb.mit.edu/project/freeculture/lib/python/gdata/__init__.pys   <module>   sf   .S			&	Z				!				