o ckF[^#ã@sxddlmZdZdZdZdZdZdZdZd Z d Z d Z d Z eegZ ee e e e gZe gZGd d„deƒZGdd„deƒZdS)é)ÚInvalidLifecycleConfigErrorÚLifecycleConfigurationÚRuleÚActionÚDeleteÚSetStorageClassÚ ConditionÚAgeÚ CreatedBeforeÚNumberOfNewerVersionsÚIsLiveÚMatchesStorageClassc@sJeZdZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dS)rax A lifecycle rule for a bucket. :ivar action: Action to be taken. :ivar action_text: The text value for the specified action, if any. :ivar conditions: A dictionary of conditions that specify when the action should be taken. Each item in the dictionary represents the name and value (or a list of multiple values, if applicable) of a condition. NcCs ||_||_|p i|_t|_dS)N)ÚactionÚ action_textÚ conditionsÚRULEÚ current_tag)Úselfrrr©rú3/usr/lib/python3/dist-packages/boto/gs/lifecycle.pyÚ__init__:s  z Rule.__init__cCs |j|krtd||jfƒ‚dS)zVerify parent of the start tag.z"Invalid tag %s found inside %s tagN©rr)rÚtagÚparentrrrÚvalidateStartTagBs  ÿÿzRule.validateStartTagcCs ||jkrtd|j|fƒ‚dS)z%Verify end tag against the start tag.z%Mismatched start and end tags (%s/%s)Nr)rrrrrÚvalidateEndTagHs ÿÿÿzRule.validateEndTagcCs¤|tkr | |t¡nB|tvr"| |t¡|jdurtdƒ‚||_n+|tkr-| |t¡n |tvrG| |t¡||jvrF|t vrFtd|ƒ‚ntd|ƒ‚||_ dS)Nz+Only one action tag is allowed in each rulez,Found duplicate non-repeatable conditions %súUnsupported tag ) ÚACTIONrrÚ LEGAL_ACTIONSrrÚ CONDITIONÚLEGAL_CONDITIONSrÚLEGAL_REPEATABLE_CONDITIONSr)rÚnameÚattrsÚ connectionrrrÚ startElementOs*  ÿ  ÿ€  zRule.startElementcCsÎ| |¡|tkr| ¡dS|tkrt|_dS|tvr.|tkr)|dur)| ¡|_t|_dS|t kr7t|_dS|t vrat |_|t vrX||j vrLg|j |<|j |  | ¡¡dS| ¡|j |<dStd|ƒ‚©NzUnsupported end tag )rrÚvalidaterrrÚSET_STORAGE_CLASSÚstriprrr r!rÚappendr©rr"Úvaluer$rrrÚ endElementfs&         zRule.endElementcCs&|jstdƒ‚|jstd|jƒ‚dS)zValidate the rule.z#No action was specified in the rulez(No condition was specified for action %sN)rrr©rrrrr'€sÿÿÿz Rule.validatecCsdtdg}| dtd¡|jr'| d|jd|jd|jdg¡n | d|jd¡| dtd¡| dtd¡|jD],}|tvrMqF|t vrW|j|}n|j|g}|D]}| d|d|d|dg¡q_qF| dtd¡| dtd¡d  |¡S)z0Convert the rule into XML string representation.ú<ú>úÚ) rr*rrÚextendrrrr r!Újoin)rÚsÚcondition_nameÚcondition_valuesÚcondition_valuerrrÚto_xml‰s2 þ    þÿ z Rule.to_xml)NNN) Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrr%r-r'r9rrrrr-s  c@s8eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd S) ÚLifecycleConfigzI A container of rules associated with a lifecycle configuration. cCs d|_dS)NF)Ú has_root_tagr.rrrr«s zLifecycleConfig.__init__cCsZ|tkr|jr tdƒ‚d|_dS|tkr'|jstd|ƒ‚tƒ}| |¡|Std|ƒ‚)Nz'Only one root tag is allowed in the XMLTzInvalid root tag r)ÚLIFECYCLE_CONFIGr?rrrr*)rr"r#r$Úrulerrrr%¯sÿ    zLifecycleConfig.startElementcCs|tkrdStd|ƒ‚r&)r@rr+rrrr-¾s zLifecycleConfig.endElementcCsLdg}| dtd¡|D] }| | ¡¡q| dtd¡d |¡S)z>Convert LifecycleConfig object into XML string representation.z&r/r0r1r2)r*r@r9r4)rr5rArrrr9Äs  zLifecycleConfig.to_xmlcCst|||ƒ}| |¡dS)a’ Add a rule to this Lifecycle configuration. This only adds the rule to the local copy. To install the new rule(s) on the bucket, you need to pass this Lifecycle config object to the configure_lifecycle method of the Bucket object. :type action: str :param action: Action to be taken. :type action_text: str :param action_text: Value for the specified action. :type conditions: dict :param conditions: A dictionary of conditions that specify when the action should be taken. Each item in the dictionary represents the name and value of a condition. N)rr*)rrrrrArrrÚadd_ruleÍs zLifecycleConfig.add_ruleN) r:r;r<r=rr%r-r9rBrrrrr>¦s r>N)Úboto.exceptionrr@rrÚDELETEr(rÚAGEÚCREATED_BEFOREÚNUM_NEWER_VERSIONSÚIS_LIVEÚMATCHES_STORAGE_CLASSrr r!ÚobjectrÚlistr>rrrrÚs& ÿy