FRTc@sddlZddlmZddlmZddlmZddlmZmZm Z ddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl"m#Z#ddl$Zddl%Zddl&Z'ddl(Z'ddl)Z)ddl*Z*ddl+m,Z,ddl-m.Z.m/Z/m0Z0m1Z1de2fdYZ3dddddgZ4de2fdYZ5dS( iN(thandler(t ResultSet(tBotoClientError(tPolicytCannedACLStringstGrant(tKey(tPrefix(t DeleteMarker(tMultiPartUpload(tCompleteMultiPartUpload(tMultiDeleteResult(tError(tBucketListResultSet(tVersionedBucketListResultSet(tMultiPartUploadListResultSet(t Lifecycle(tTags(tCORSConfiguration(t BucketLogging(twebsite(t defaultdict(tBytesIOtsixtStringIOturllibtS3WebsiteEndpointTranslatecBsveZedZded:sss3-website-eu-west-1s eu-west-1ss3-website-us-west-1s us-west-1ss3-website-us-west-2s us-west-2ss3-website-sa-east-1s sa-east-1ss3-website-ap-northeast-1sap-northeast-1ss3-website-ap-southeast-1sap-southeast-1ss3-website-ap-southeast-2sap-southeast-2ss3-website.cn-north-1s cn-north-1cCs |j|S(N(t trans_region(tselftreg((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyttranslate_regionDs(t__name__t __module__RRt classmethodR(((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyR8s        tREADtWRITEtREAD_ACPt WRITE_ACPt FULL_CONTROLtBucketcBs[eZdZdZdZdZdZdWdWedZ dZ dZ dZ d Z d Zd ZdWd ZdWdWdWed ZdZddddWdWdZdddddWdWdZdddWdWdZddZddWdZdZdWdZdWdZdZdWdZdWdZddWedWedZ edWdWdZ!dWdWdWdZ"dWdWdWdWdZ#dWdWd eedWdWd!Z$ddWdWd"Z%ddWdWd#Z&ddWdWd$d%Z'ddWdWd&Z(ddWdWd'Z)ddWdWd(Z*ddWdWd)Z+edWd*Z,edWd+Z-edWdWd,Z.dWd-Z/d.Z0dWd/Z1ddWdWd0Z2dWd1Z3dWd2Z4dWd3Z5dWd4Z6d5dWd6Z7edWdWd7Z8dWd8Z9dWd9Z:dWd:Z;dWd;Z<dWdWdWdWdWd<Z=dWd=Z>dWd>Z?dWd?Z@dWd@ZAdWdAZBdWdBZCdWdCZDdDZEdWdEZFdWdFZGdWdGZHdWdHZIdWdIZJdWdJZKdWdKZLdWdLZMdWedWedWdMZNdWdNZOdWdOZPdWdPZQdQZRdRZSdWdSdTZTdWdUZUdWdVZVRS(Xs.http://acs.amazonaws.com/groups/s3/LogDeliverys %s s %s %s s([A-Za-z]+)s"([A-Za-z]+)cCs||_||_||_dS(N(tnamet connectiont key_class(RR*R)R+((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyt__init__]s  cCs d|jS(Ns (R)(R((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyt__repr__bscCstt|S(N(titerR (R((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyt__iter__escCs|j|dk S(N(tget_keytNone(Rtkey_name((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyt __contains__hscCsdS(N(R1(RR)tattrsR*((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyt startElementkscCsD|dkr||_n(|dkr0||_nt|||dS(NtNamet CreationDate(R)t creation_datetsetattr(RR)tvalueR*((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyt endElementns     cCs ||_dS(s  Set the Key class associated with this bucket. By default, this would be the boto.s3.key.Key class but if you want to subclass that for some reason this allows you to associate your new class with a bucket so that when you call bucket.new_key() or when you get a listing of keys in the bucket you will get an instances of your key class rather than the default. :type key_class: class :param key_class: A subclass of Key that can be more specific N(R+(RR+((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyt set_key_classvs cCs|j|d|S(s Deprecated: Please use get_key method. :type key_name: string :param key_name: The name of the key to retrieve :rtype: :class:`boto.s3.key.Key` :returns: A Key object from this bucket. theaders(R0(RR2R=((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pytlookups c Cs|tkr>|s|s|r1tddn|j|Sg}|r^|jd|n|rxCtj|D]/\}}|jd|tjj|fqtWn|j |||\} } | S(s Check to see if a particular key exists within the bucket. This method uses a HEAD request to check for the existence of the key. Returns: An instance of a Key object or None :param key_name: The name of the key to retrieve :type key_name: string :param headers: The headers to send when retrieving the key :type headers: dict :param version_id: :type version_id: string :param response_headers: A dictionary containing HTTP headers/values that will override any headers associated with the stored object in the response. See http://goo.gl/EWOPb for details. :type response_headers: dict :param validate: Verifies whether the key exists. If ``False``, this will not hit the service, constructing an in-memory object. Default is ``True``. :type validate: bool :rtype: :class:`boto.s3.key.Key` :returns: A Key object from this bucket. s1When providing 'validate=False', no other params s are allowed.s versionId=%ss%s=%s( tFalseRtnew_keytappendRt iteritemsRtparsetquotet_get_key_internal( RR2R=t version_idtresponse_headerstvalidatet query_args_ltrktrvtkeytresp((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyR0s   *c Csdj|pd}|jjd|j|d|d|}|j|jddkrQ|j|}|jj}t j j |j ||_ x9tjD].}|j||j|jjdduutrueiiit PrefixSkippedtInvalidArguments0Invalid. No delete action taken for this object.tcodetmessageiu%su%su u sutf-8s Content-MD5stext/xmls Content-Typet tPOSTR=RPtdatai('tnextt StopIterationR~RRR1ttupletlenRRR)RFRtreprR terrorsRARRtsaxutilstescapeR?RRRYRZt compute_md5RTt mfa_headerR*RURVRWRRRRRjRk(thdrsRtcountRLR2RFRRterrortfptmd5RlRR(tikeyst mfa_tokenRXRPtquiettresultR(s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyt delete_keys2sr     !'              (R.R R*RX(RtkeysRRR=R((RRRXRPRRRs;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyt delete_keyszs   !=c Cs:|stdn|j|d|d|d|ddS(s Deletes a key from the bucket. If a version_id is provided, only that version of the key will be deleted. :type key_name: string :param key_name: The key name to delete :type version_id: string :param version_id: The version ID (optional) :type mfa_token: tuple or list of strings :param mfa_token: A tuple or list consisting of the serial number from the MFA device and the current value of the six-digit token associated with the device. This value is required anytime you are deleting versioned objects from a bucket that has the MFADelete option on the bucket. :rtype: :class:`boto.s3.key.Key` or subclass :returns: A key object holding information on what was deleted. The Caller can see if a delete_marker was created or removed and what version_id the delete created or removed. sEmpty key names are not allowedR=RFRRIN(Rt_delete_key_internalR1(RR2R=RFR((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyt delete_keys c Cs|p g}|jj}|r2|jd|ndj|pDd}|ru|s\i}ndj|||jiiN(R1R*RUR)R?RVR)tfindRRYRRRWR RRR~RRRRRR+ReRfRFt encryptedRXRjRk( RR2t upload_idtxml_bodyR=RPRltcontains_errorRRMRRm((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pytcomplete_multipart_uploads4           cCsd|}|jjd|j|d|d|}|j}tjj||jdkr|jjj |j|j |ndS(s To verify that all parts have been removed, so you don't get charged for the part storage, you should call the List Parts operation and ensure the parts list is empty. s uploadId=%sRRPR=iN( R*RUR)RVRYRRRWRXRjRk(RR2R^R=RPRlR((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pytcancel_multipart_uploads    cCs|jj|jd|S(NR=(R*t delete_bucketR)(RR=((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyRscCs_|j}t}tj||}t|tsH|jd}ntjj |||S(Nsutf-8( t get_xml_tagsRRRR~RRRRR(RRlttagsR((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pytget_tags!s  cCsh|jjd|jdddd}|j}|jdkrC|S|jjj|j|j|dS(NRRPttaggingR=i( R*RUR)R1RVRWRXRjRk(RRlR((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyRd*s   Rgc Cs|dkri}ntjjt|}|d|dRR0RERtRwRyRRRRRRRR@R?RRRRRRRRRRRRRRRRRRR RRRRRR&R0R4R5R6R>R8R?RARDR@RBRHRMRNRORPRSRURVRWRXR[RaRbRRfRdRiRjRk(((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyR(Ks       2 %  2 /!    0 3 J  ` c    & $!'      /     !  !        N &    (6RYRtboto.resultsetRtboto.exceptionRt boto.s3.aclRRRt boto.s3.keyRtboto.s3.prefixRtboto.s3.deletemarkerRtboto.s3.multipartR R tboto.s3.multideleteR R tboto.s3.bucketlistresultsetR RRtboto.s3.lifecycleRtboto.s3.taggingRt boto.s3.corsRtboto.s3.bucketloggingRtboto.s3Rtboto.jsonresponset boto.utilstxml.saxRtxml.sax.saxutilsR*tbase64t collectionsRt boto.compatRRRRtobjectRRR((((s;/opt/freeware/lib/python2.7/site-packages/boto/s3/bucket.pyts<       "