https://t.me/RX1948
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/boto/sdb/db/__pycache__/property.cpython-310.pyc
o

ckF[�a�@s�ddlZddlmZddlmZddlmZddlZddlZddl	Zddl
mZddlm
Z
mZGdd�de�Zd	d
�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd �d e�ZGd!d"�d"e�ZGd#d$�d$e�ZGd%d&�d&e�ZGd'd(�d(e�Z Gd)d*�d*e�Z!Gd+d,�d,e�Z"dS)-�N)�Key)�Password)�Query)�Blob)�six�	long_typec@szeZdZeZdZdZdZ		ddd�Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�Property�NFcCsH||_||_||_||_||_||_|jrd|j|_nd|_||_dS�N�_)�verbose_name�name�default�required�	validator�choices�	slot_name�unique��selfrr
rrrrr�r�6/usr/lib/python3/dist-packages/boto/sdb/db/property.py�__init__(s
zProperty.__init__cCs|r|��t||j�SdS�N)�load�getattrr�r�obj�objtyperrr�__get__6szProperty.__get__cCst|�|�z|jrt|d|j�rt|d|j�}||�}Wnty0tj�d|j�Ynwt	||j
|�dS)Nz	on_set_%szException running on_set_%s)�validate�_loaded�hasattrr
r�	Exception�boto�log�	exception�setattrr)rr�value�fncrrr�__set__=s
��zProperty.__set__cCs||_||_d|j|_dSr
)�model_classr
r�rr+�
property_namerrr�__property_config__JszProperty.__property_config__cCsLt|tj�s||��krdSt||j�s$td|jj|j|jt	|�f��dS)Nz,Validation Error, %s.%s expecting %s, got %s)
�
isinstancer�string_types�
default_value�	data_type�	TypeErrorr+�__name__r
�type�rr(rrr�default_validatorOs
 �zProperty.default_validatorcCs|jSr)r�rrrrr1U�zProperty.default_valuecCsj|jr|durtd|j��|jr$|r$||jvr$td||jj|jf��|jr.|�|�|S|�|�|S)N�%s is a required propertyz%s not a valid choice for %s.%s)r�
ValueErrorr
rr+r4rr7r6rrrr Xs

�zProperty.validatecCs|Srrr6rrr�emptycr9zProperty.emptycCst||j�Sr)rr
�r�model_instancerrr�get_value_for_datastorefsz Property.get_value_for_datastorecCs|Srrr6rrr�make_value_from_datastorei�z"Property.make_value_from_datastorecCst|j�r	|��S|jSr)�callablerr8rrr�get_choicesls
zProperty.get_choices�NNNFNNF)r4�
__module__�__qualname__�strr2�	type_namer
rrrr*r.r7r1r r<r?r@rCrrrrr!s$
�
rcCs@|durdSt|tj�rt|�dkrtd��dStdt|���)N��&Length of value greater than maxlengthzExpecting String, got %s)r/rr0�lenr;r3r5)r(rrr�validate_stringrs�rLcs0eZdZdZddddeddf�fdd�	Z�ZS)�StringProperty�StringNr	Fc	� tt|��|||||||�dSr)�superrMrr��	__class__rrr�s�zStringProperty.__init__)r4rErFrHrLr�
__classcell__rrrQrrM|s�rMcs4eZdZdZ			d	�fdd�	Z�fdd�Z�ZS)
�TextProperty�TextNr	Fc			s&tt|��|||||||�||_dSr)rPrTr�
max_length)	rrr
rrrrrrVrQrrr�s�
zTextProperty.__init__csVtt|��|�}t|tj�stdt|���|jr't	|�|jkr)t
d|j��dSdS)NzExpecting Text, got %sz)Length of value greater than maxlength %s)rPrTr r/rr0r3r5rVrKr;r6rQrrr �s�zTextProperty.validate�NNr	FNNFN)r4rErFrHrr rSrrrQrrT�s�rTcsfeZdZdZeZdZ		d�fdd�	Zdd	�Z�fd
d�Z	�fdd
�Z
�fdd�Z�fdd�Z�Z
S)�PasswordPropertya�

    Hashed property whose original value can not be
    retrieved, but still can be compared.

    Works by storing a hash of the original value instead
    of the original value.  Once that's done all that
    can be retrieved is the hash.

    The comparison

       obj.password == 'foo'

    generates a hash of 'foo' and compares it to the
    stored hash.

    Underlying data type for hashing, storing, and comparing
    is boto.utils.Password.  The default hash function is
    defined there ( currently sha512 in most cases, md5
    where sha512 is not available )

    It's unlikely you'll ever need to use a different hash
    function, but if you do, you can control the behavior
    in one of two ways:

      1) Specifying hashfunc in PasswordProperty constructor

         import hashlib

         class MyModel(model):
             password = PasswordProperty(hashfunc=hashlib.sha224)

      2) Subclassing Password and PasswordProperty

         class SHA224Password(Password):
             hashfunc=hashlib.sha224

         class SHA224PasswordProperty(PasswordProperty):
             data_type=MyPassword
             type_name="MyPassword"

         class MyModel(Model):
             password = SHA224PasswordProperty()

    rNr	Fc			s&tt|��|||||||�||_dS)z�
           The hashfunc parameter overrides the default hashfunc in boto.utils.Password.

           The remaining parameters are passed through to StringProperty.__init__N)rPrXr�hashfunc)	rrr
rrrrrrYrQrrr�s�
zPasswordProperty.__init__cCs|j||jd�}|S�N)rY)r2rY)rr(�prrrr@�sz*PasswordProperty.make_value_from_datastorecs(tt|��|�}|rt|�rt|�SdSr)rPrXr?rKrG�rr>r(rQrrr?�sz(PasswordProperty.get_value_for_datastorecs>t||j�s|j|jd�}|�|�|}tt|��||�dSrZ)r/r2rY�setrPrXr*)rrr(r[rQrrr*�s

zPasswordProperty.__set__cs|jtt|��||�|jd�SrZ)r2rPrXrrYrrQrrr�szPasswordProperty.__get__csNtt|��|�}t||j�rt|�dkrtd��dStdt|j�t|�f��)NrIrJzExpecting %s, got %s)	rPrXr r/r2rKr;r3r5r6rQrrr �s�zPasswordProperty.validaterW)r4rErF�__doc__rr2rHrr@r?r*rr rSrrrQrrX�s-�rXcs$eZdZeZdZ�fdd�Z�ZS)�BlobProperty�blobcsZ||��kr"t|t�s"|�|t|��}d}|r|j}t||d�}|}tt|��||�dS)N)r(�id)	r1r/rrr5rarPr_r*)rrr(�oldbra�brQrrr*�s
zBlobProperty.__set__)r4rErFrr2rHr*rSrrrQrr_�sr_csXeZdZejjjZdZdZ			d
�fdd�	Z
�fdd�Z�fd	d
�Z�fdd�Z
�ZS)�
S3KeyProperty�S3Keyz^s3:\/\/([^\/]*)\/(.*)$NFc	rOr)rPrdrrrQrrrs�zS3KeyProperty.__init__csptt|��|�}||��ks|t|���kr|��St||j�r"dSt�|j	|�}|r-dSt
d|jt|�f���Nz&Validation Error, expecting %s, got %s)rPrdr r1rGr/r2�re�match�validate_regexr3r5)rr(rhrQrrr szS3KeyProperty.validatecs�tt|��||�}|rFt||j�r|St�|j|�}|rD|j�	�}|j
|�d�dd�}|�|�d��}|sB|�
|�d��}|�d�|SdS|S)N�F)r �r	)rPrdrr/r2rgrhri�_manager�get_s3_connection�
get_bucket�group�get_key�new_key�set_contents_from_string)rrrr(rh�s3�bucket�krQrrrs

�	zS3KeyProperty.__get__cs*tt|��|�}|rd|jj|jfSdS)Nz
s3://%s/%s)rPrdr?rtr
r\rQrrr?,sz%S3KeyProperty.get_value_for_datastorerD)r4rErFr$rs�keyrr2rHrirr rr?rSrrrQrrds
�rdcsJeZdZeZdZ		d�fdd�	Z�fd	d
�Zdd�Z�fd
d�Z	�Z
S)�IntegerProperty�IntegerNrF����c

	s,tt|��|||||||�||_|	|_dSr)rPrwr�max�min)
rrr
rrrrrr{r|rQrrr9�
zIntegerProperty.__init__csLt|�}tt|��|�}||jkrtd|j��||jkr$td|j��|S)N�Maximum value is %d�Minimum value is %d)�intrPrwr r{r;r|r6rQrrr ?s

zIntegerProperty.validatecC�|duSrrr6rrrr<H�zIntegerProperty.emptycs&|dks|dur
d}tt|��||�S)Nr	r)rPrwr*�rrr(rQrrr*KszIntegerProperty.__set__)	NNrFNNFryrz)r4rErFr�r2rHrr r<r*rSrrrQrrw4s�	rwc�>eZdZeZdZ		d�fdd�	Z�fdd�Zd	d
�Z�Z	S)�LongProperty�LongNrFc	rOr)rPr�rrrQrrrV� zLongProperty.__init__csLt|�}tt|��|�}d}d}||krtd|��||kr$td|��|S)Nl����l����r~r)rrPr�r r;)rr(r|r{rQrrr ZszLongProperty.validatecCr�rrr6rrrr<er�zLongProperty.empty)NNrFNNF)
r4rErFrr2rHrr r<rSrrrQrr�Qs�r�cs2eZdZeZdZ		d�fdd�	Zdd�Z�ZS)	�BooleanProperty�BooleanNFc	rOr)rPr�rrrQrrrnr�zBooleanProperty.__init__cCr�rrr6rrrr<rr�zBooleanProperty.empty)NNFFNNF)	r4rErF�boolr2rHrr<rSrrrQrr�is�r�cr�)�
FloatProperty�FloatN�Fc	rOr)rPr�rrrQrrr{r�zFloatProperty.__init__cst|�}tt|��|�}|Sr)�floatrPr�r r6rQrrr szFloatProperty.validatecCr�rrr6rrrr<�r�zFloatProperty.empty)NNr�FNNF)
r4rErFr�r2rHrr r<rSrrrQrr�vs�r�cs\eZdZdZejZdZ		d�fdd�	Z�fdd�Z�fd	d
�Z	�fdd�Z
d
d�Z�ZS)�DateTimePropertyz�This class handles both the datetime.datetime object
    And the datetime.date objects. It can return either one,
    depending on the value stored in the database�DateTimeNFc

	�,tt|��|||||||	�||_||_dSr)rPr�r�auto_now�auto_now_add�
rrr�r�r
rrrrrrQrrr�r}zDateTimeProperty.__init__c�"|js|jr
|��Stt|���Sr)r�r��nowrPr�r1r8rQrrr1��zDateTimeProperty.default_valuecs,|durdSt|tj�r|Stt|��|�Sr)r/�datetime�daterPr�r r6rQrrr �s
zDateTimeProperty.validatecs(|jrt||j|���tt|��|�Sr)r�r'r
r�rPr�r?r=rQrrr?�sz(DateTimeProperty.get_value_for_datastorecCs
tj��Sr)r��utcnowr8rrrr���
zDateTimeProperty.now�	NFFNNFNNF)
r4rErFr^r�r2rHrr1r r?r�rSrrrQrr��s�r�csXeZdZejZdZ		d�fdd�	Z�fdd�Z�fdd	�Z	�fd
d�Z
dd
�Z�ZS)�DateProperty�DateNFc

	r�r)rPr�rr�r�r�rQrrr�r}zDateProperty.__init__cr�r)r�r�r�rPr�r1r8rQrrr1�r�zDateProperty.default_valuec�Btt|��|�}|durdSt||j�std|jt|�f��dSrf)rPr�r r/r2r3r5r6rQrrr ���zDateProperty.validatecs@|jrt||j|���tt|��|�}t|tj�r|�	�}|Sr)
r�r'r
r�rPr�r?r/r�r�)rr>�valrQrrr?�sz$DateProperty.get_value_for_datastorecCs
tj��Sr)r�r��todayr8rrrr��r�zDateProperty.nowr�)
r4rErFr�r�r2rHrr1r r?r�rSrrrQrr��s�r�cs8eZdZejZdZ		d�fdd�	Z�fdd�Z�Z	S)	�TimeProperty�TimeNFc	rOr)rPr�rrrQrrr�r�zTimeProperty.__init__cr�rf)rPr�r r/r2r3r5r6rQrrr �r�zTimeProperty.validaterD)
r4rErFr��timer2rHrr rSrrrQrr��s�r�csbeZdZeZdZ		d�fdd�	Zdd�Z�fdd	�Z�fd
d�Z	dd
�Z
dd�Zdd�Z�Z
S)�ReferenceProperty�	ReferenceNFc

	s,tt|��|||||||	�||_||_dSr)rPr�r�reference_class�collection_name)
rr�r�rr
rrrrrrQrrr�r}zReferenceProperty.__init__cCsL|r$t||j�}||��kr|St|tj�r"|�|�}t||j|�|SdSr)	rrr1r/rr0r�r'r
�rrrr(rrrr�s
�zReferenceProperty.__get__csB|dur|j|kst|d�r|j|jkrtd��tt|��||�S)z[Don't allow this object to be associated to itself
        This causes bad things to happenNraz(Can not associate an object with itself!)rar"r;rPr�r*r�rQrrr*�s(zReferenceProperty.__set__csltt|��||�|jdurd|j��|jf|_t|j|j�r't	d|j��t
|j|jt|||j��dS)Nz	%s_%s_setzduplicate property: %s)rPr�r.r�r4�lowerr
r"r�r;r'�_ReverseReferencePropertyr,rQrrr.�s

�z%ReferenceProperty.__property_config__cCs|�d�}t|�dkr
t�dS)N�-�)�splitrKr;)rr(�trrr�
check_uuids
�zReferenceProperty.check_uuidcCsFz|��}|j��}|�|�rWdStd||f��td|��)Nz%s not instance of %sz%s is not a Model)�get_lineager��
startswithr3r;)rr(�obj_lineage�cls_lineagerrr�check_instances

z ReferenceProperty.check_instancecCsZ|jr|�|�|jr|durtd|j��||��krdSt|tj�s+|�|�dSdS)Nr:)	rrr;r
r1r/rr0r�r6rrrr s
�zReferenceProperty.validate)	NNNNNFNNF)r4rErFrr2rHrrr*r.r�r�r rSrrrQrr��s�
	
r�c@s,eZdZeZdZdd�Zdd�Zdd�ZdS)	r��querycCs"||_||_||_||_||_dSr)� _ReverseReferenceProperty__model�#_ReverseReferenceProperty__propertyr�r
�	item_type)r�model�propr
rrrr%s

z"_ReverseReferenceProperty.__init__cCs^|dur-t|j�}t|jt�r$g}|jD]	}|�d|�q|�||�S|�|jd|�S|S)zBFetches collection of model instances of this collection property.Nz%s =z =)rr�r/r��list�append�filter)rr>r+r��propsr�rrrr,s

z!_ReverseReferenceProperty.__get__cCstd��)z%Not possible to set a new collection.zVirtual property is read-only)r;r\rrrr*:sz!_ReverseReferenceProperty.__set__N)	r4rErFrr2rHrrr*rrrrr�!sr�c	sPeZdZddddddeddf	�fdd�	Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)
�CalculatedPropertyNFc

	s,tt|��|||||||�||_|	|_dSr)rPr�r�calculated_type�
use_method)
rrr
rrrrr�rr�rQrrrAs
�
zCalculatedProperty.__init__cCsJ|��}|r#zt||j�}|jr|�}W|SW|Sty"Y|Sw|Sr)r1rrr��AttributeErrorr�rrrrIs���zCalculatedProperty.__get__cCsdS)z!Not possible to set a new AutoID.Nrr�rrrr*TszCalculatedProperty.__set__cCs|jst||j|�dSdSr)r�r'rr�rrr�_set_directXs�zCalculatedProperty._set_directcCs&|jtttfvr|�||j�}|SdSr)r�rGr�r�rrRr\rrrr?\sz*CalculatedProperty.get_value_for_datastore)
r4rErFr�rrr*r�r?rSrrrQrr�?s�r�csNeZdZeZdZd
�fdd�	Zdd�Zdd�Z�fd	d
�Z	�fdd�Z
�ZS)�ListProperty�ListNcs6|durg}||_tt|�j||f|dd�|��dS�NT)rr)r�rPr�r�rr�rr
r�kwdsrQrrri�$zListProperty.__init__cCs�|jr|�|�|durt|t�s|g}|jtjvrtj}n
|jtjvr(tj}n|j}|D]}t||�sK|tjkr@td|j��td|j|jj	f��q-|S)Nz*Items in the %s list must all be integers.z-Items in the %s list must all be %s instances)
rr/r�r�r�
integer_typesr0r;r
r4)rr(r��itemrrrr os&



��zListProperty.validatecCr�rrr6rrrr<�r�zListProperty.emptycsttt|����Sr)r�rPr�r1r8rQrrr1�szListProperty.default_valuecs^|jtjvr
tj}n
|jtjvrtj}n|j}t||�r |g}n|dur&g}tt|��||�S)z�Override the set method to allow them to set the property to an instance of the item_type instead of requiring a list to be passed inN)r�rr�r0r/rPr�r*)rrr(r�rQrrr*�s
zListProperty.__set__)NNN)r4rErFr�r2rHrr r<r1r*rSrrrQrr�dsr�csJeZdZeZdZedddf�fdd�	Z�fdd�Zdd�Z	d	d
�Z
�ZS)�MapProperty�MapNcs6|duri}||_tt|�j||f|dd�|��dSr�)r�rPr�rr�rQrrr�r�zMapProperty.__init__cs�tt|��|�}|durt|t�std��|jtjvrtj}n
|jtj	vr)tj	}n|j}|D] }t|||�sN|tjkrCtd|j
��td|j
|jjf��q.|S)NzValue must of type dictz*Values in the %s Map must all be integers.z-Values in the %s Map must all be %s instances)rPr�r r/�dictr;r�rr�r0r
r4)rr(r�rvrQrrr �s$

��zMapProperty.validatecCr�rrr6rrrr<�r�zMapProperty.emptycCsiSrrr8rrrr1�rAzMapProperty.default_value)r4rErFr�r2rHrGrr r<r1rSrrrQrr��sr�)#r��boto.sdb.db.keyr�
boto.utilsr�boto.sdb.db.queryrrgr$�boto.s3.key�boto.sdb.db.blobr�boto.compatrr�objectrrLrMrTrXr_rdrwr�r�r�r�r�r�r�r�r�r�r�rrrr�<module>s8Q
[/
##C%7

https://t.me/RX1948 - 2025