ó FRTc@s‰ddlmZddlmZdefd„ƒYZd d d„Zd d d„Zddd „Z ed ƒZ d efd „ƒYZ d S(iÿÿÿÿ(tSDBResponseError(tsixtSequenceGeneratorcBs5eZdZdZed„Zdd„Zd„ZRS(séGeneric Sequence Generator object, this takes a single string as the "sequence" and uses that to figure out what the next value in a string is. For example if you give "ABC" and pass in "A" it will give you "B", and if you give it "C" it will give you "AA". If you set "rollover" to True in the above example, passing in "C" would give you "A" again. The Sequence string can be a string or any iterable that has the "index" function and is indexable. RcCsO||_t|dƒ|_||_|d|_d|jj|f|_dS(s“Create a new SequenceGenerator using the sequence_string as how to generate the next item. :param sequence_string: The string or list that explains how to generate the next item in the sequence :type sequence_string: str,iterable :param rollover: Rollover instead of incrementing when we hit the end of the sequence :type rollover: bool iiÿÿÿÿs%s('%s')N(tsequence_stringtlentsequence_lengthtrollovert last_itemt __class__t__name__(tselfRR((sA/opt/freeware/lib/python2.7/site-packages/boto/sdb/db/sequence.pyt__init__(s   cCs¢|dks!t|ƒ|jkr,|jdS||j }|j r}||jkr}d|||j ƒ|j|ƒf}n!d||j |j|ƒf}|S(s"Get the next value in the sequenceis%s%sN(tNoneRRRRRt_inc(R tvaltlastt last_value((sA/opt/freeware/lib/python2.7/site-packages/boto/sdb/db/sequence.pyt__call__:s! *!cCsCt|ƒ|jkst‚|j|jj|ƒdt|jƒS(sIncrement a single valuei(RRtAssertionErrorRtindex(R R((sA/opt/freeware/lib/python2.7/site-packages/boto/sdb/db/sequence.pyR HsN(R t __module__t__doc__tFalseR R RR (((sA/opt/freeware/lib/python2.7/site-packages/boto/sdb/db/sequence.pyRs    cCs|dkrdS|dS(Nii(R (tcvtlv((sA/opt/freeware/lib/python2.7/site-packages/boto/sdb/db/sequence.pytincrement_by_oneQs cCs|dkrdS|dS(Nii(R (RR((sA/opt/freeware/lib/python2.7/site-packages/boto/sdb/db/sequence.pytdoubleVs iicCs2|dkrd}n|dkr*d}n||S(s@The fibonacci sequence, this incrementer uses the last valueiiN(R (RR((sA/opt/freeware/lib/python2.7/site-packages/boto/sdb/db/sequence.pytfib[s     tABCDEFGHIJKLMNOPQRSTUVWXYZtSequencecBsteZdZddedd„Zd„Zd„ZeeeƒZ d„Z d„Z ee ƒZ d„Z d„ZRS( s¾A simple Sequence using the new SDB "Consistent" features Based largly off of the "Counter" example from mitch garnaat: http://bitbucket.org/mitch/stupidbototricks/src/tip/counter.pycCsìd|_d|_d|_||_||_|dkrH||ƒ}n|jdkr{ddl}t|jƒƒ|_nt |dƒƒ|_ d|_ t |t jƒrÊddlm}||ƒ}n||_|jsè||_ndS(snCreate a new Sequence, using an optional function to increment to the next number, by default we just increment by one. Every parameter here is optional, if you don't specify any options then you'll get a new SequenceGenerator with a random ID stored in the default domain that increments by one and uses the default botoweb environment :param id: Optional ID (name) for this counter :type id: str :param domain_name: Optional domain name to use, by default we get this out of the environment configuration :type domain_name:str :param fnc: Optional function to use for the incrementation, by default we just increment by one There are several functions defined in this module. Your function must accept "None" to get the initial value :type fnc: function, str :param init_val: Initial value, by default this is the first element in your sequence, but you can pass in any value, even a string if you pass in a function that uses strings instead of ints to increment iÿÿÿÿN(t find_class(R t_dbt_valueRt domain_nametidtuuidtstrtuuid4ttypet item_typet timestampt isinstanceRt string_typest boto.utilsRtfncR(R R"R!R,tinit_valR#R((sA/opt/freeware/lib/python2.7/site-packages/boto/sdb/db/sequence.pyR ls$          cCsÔddl}|jƒ}g}i}||d<|jdk rb|j|ds8