Server : Apache System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64 User : dh_edsupp ( 6597262) PHP Version : 8.2.26 Disable Function : NONE Directory : /lib/python3/dist-packages/boto/sdb/db/__pycache__/ |
Upload File : |
o ckF[ � @ sb d dl mZ d dlmZ G dd� de�Zddd�Zddd �Zddd�Zed �Z G dd� de�Z dS )� )�SDBResponseError)�sixc @ s0 e Zd ZdZd Z d dd�Zddd�Zdd � ZdS )�SequenceGeneratora� 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. Fc C s: || _ t|d �| _|| _|d | _d| jj|f | _dS )a� 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 r ���z%s('%s')N)�sequence_string�len�sequence_length�rollover� last_item� __class__�__name__)�selfr r � r �6/usr/lib/python3/dist-packages/boto/sdb/db/sequence.py�__init__( s zSequenceGenerator.__init__Nc C s� |du st |�| jk r| jd S || j d� }| js3|| jkr3d| |d| j � �| �|�f }|S d|d| j � | �|�f }|S )z"Get the next value in the sequenceNr z%s%s)r r r r r �_inc)r �val�last� last_valuer r r �__call__: s "�zSequenceGenerator.__call__c C s2 t |�| jks J �| j| j�|�d t | j� S )zIncrement a single value� )r r r �index�r r r r r r H s zSequenceGenerator._inc)F�N)r � __module__�__qualname__�__doc__r r r r r r r r s r Nc C s | d u rdS | d S )Nr r r ��cv�lvr r r �increment_by_oneQ � r c C s | d u rdS | d S )Nr � r r r r r �doubleV r! r# r c C s | du rd} |du rd}| | S )z@The fibonacci sequence, this incrementer uses the last valueNr r r r r r r �fib[ s r$ �ABCDEFGHIJKLMNOPQRSTUVWXYZc @ sd e Zd ZdZddedfdd�Zdd� Zdd� Zeee�Z d d � Z dd� Zee�Zd d� Z dd� ZdS )�Sequencez�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.pyNc C s� d| _ d| _d| _|| _|| _|du r||�}| jdu r'ddl}t|�� �| _t|d��| _ d| _ t|tj �rAddlm} ||�}|| _| jsL|| _dS dS )an Create 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 Nr )� find_class)�_db�_valuer �domain_name�id�uuid�str�uuid4�type� item_type� timestamp� isinstancer �string_types� boto.utilsr'