ó
Òbc           @@ sa  d  d l  m Z m Z d  d l Z d d l m Z d d l m Z d d l m	 Z	 m
 Z
 d d l m Z y d  d l j j Z Wn  e k
 r  d  d l j Z n Xe j d k Z g  Z d	 e f d
 „  ƒ  YZ e j d	 ƒ e d k r]e ƒ  Z e e ƒ e j e j d ƒ ƒ e e ƒ e j e ƒ e e ƒ e j e ƒ e e ƒ e j  ƒ  e e ƒ n  d S(   i    (   t   absolute_importt   print_functionNi   (   t   S3Uri(   t   ParameterError(   t   getTreeFromXmlt   decode_from_s3(   t   GranteeAnonReadi   t	   AccessLogc           B@ sh   e  Z d  Z d Z d d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z RS(   s+   <BucketLoggingStatus></BucketLoggingStatus>s[   <LoggingEnabled><TargetBucket></TargetBucket><TargetPrefix></TargetPrefix></LoggingEnabled>c         C@ s5   | s |  j  } n  t | ƒ |  _ d |  j j d <d  S(   Ns&   http://doc.s3.amazonaws.com/2006-03-01t   xmlns(   t   LOG_DISABLEDR   t   treet   attrib(   t   selft   xml(    (    sL   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/AccessLog.pyt   __init__   s    c         C@ s   |  j  j d ƒ d  k	 S(   Ns   .//LoggingEnabled(   R
   t   findt   None(   R   (    (    sL   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/AccessLog.pyt   isLoggingEnabled$   s    c         C@ s/   |  j  j d ƒ } | r+ |  j  j | ƒ n  d  S(   Ns   .//LoggingEnabled(   R
   R   t   remove(   R   t   el(    (    sL   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/AccessLog.pyt   disableLogging'   s    c         C@ sn   |  j  j d ƒ } | s: t |  j ƒ } |  j  j | ƒ n  | j ƒ  | j d ƒ _ | j ƒ  | j d ƒ _ d  S(   Ns   .//LoggingEnableds   .//TargetBuckets   .//TargetPrefix(   R
   R   R   t   LOG_TEMPLATEt   appendt   buckett   textt   object(   R   t   target_prefix_uriR   (    (    sL   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/AccessLog.pyt   enableLogging,   s    c         C@ sO   |  j  ƒ  rG d |  j j d ƒ j |  j j d ƒ j f } t j | ƒ Sd Sd  S(   Nu
   s3://%s/%ss   .//LoggingEnabled//TargetBuckets   .//LoggingEnabled//TargetPrefixt    (   R   R
   R   R   R   (   R   t   target_prefix(    (    sL   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/AccessLog.pyt   targetPrefix4   s    c         C@ s—   |  j  j d ƒ } | d  k r- t d ƒ ‚ n  | j d ƒ } | s\ | sL d  S| j | ƒ n7 t ƒ  j ƒ  } | s† t j | d ƒ } n  | j	 | ƒ d  S(   Ns   .//LoggingEnableds3   Logging not enabled, can't set default ACL for logss   .//TargetGrantst   TargetGrants(
   R
   R   R   R   R   R   t
   getElementt   ETt
   SubElementR   (   R   t
   acl_publict   let   tgt	   anon_read(    (    sL   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/AccessLog.pyt   setAclPublic=   s    c         C@ s   t  ƒ  ‚ d  S(   N(   t   NotImplementedError(   R   (    (    sL   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/AccessLog.pyt   isAclPublicP   s    c         C@ s   t  t j |  j ƒ ƒ S(   N(   R   R!   t   tostringR
   (   R   (    (    sL   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/AccessLog.pyt   __unicode__S   s    c         C@ s0   t  r t j |  j d d ƒSt j |  j ƒ Sd  S(   Nt   encodingt   unicode(   t   PY3R!   R*   R
   (   R   (    (    sL   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/AccessLog.pyt   __str__V   s    N(   t   __name__t
   __module__R	   R   R   R   R   R   R   R   R'   R)   R+   R/   (    (    (    sL   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/AccessLog.pyR      s   								t   __main__u   s3://targetbucket/prefix/log-(   i   i    (!   t
   __future__R    R   t   sysR   R   t
   ExceptionsR   t	   BaseUtilsR   R   t   ACLR   t   xml.etree.ElementTreet   etreet   ElementTreeR!   t   ImportErrort   elementtree.ElementTreet   version_infoR.   t   __all__R   R   R   R0   t   logt   printR   R'   t   Truet   FalseR   (    (    (    sL   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/AccessLog.pyt   <module>	   s0   D	




