o
    Ýîi‰7  ã                   @   sº  d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
 G dd„ deƒZG dd	„ d	eƒZG d
d„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZeZ	 G dd„ deƒZdd„ Zdd„ ZeddƒZ	 eZ	 eddƒZ	 eZ	 eddƒZ	 eZ	 eddƒZ	 eZ	 edd ƒZ	 eZ	 edd!ƒZ 	 e Z!	 edd"ƒZ"	 e"Z#	 edd#ƒZ$	 e$Z%	 e &e'eejei¡ e
j(sÅe &e)ei¡ dS e &e*ei¡ e+d$e*ƒr×eee)< dS eee)< dS )%é    N)Úwarn)ÚSimpleModel)Ú
NATIVE_MAP)Úsixc                   @   s   e Zd ZdS )ÚNumberLimitsWarningN)Ú__name__Ú
__module__Ú__qualname__© r
   r
   ú\/var/www/html/LicenciasMIG/venv/lib/python3.10/site-packages/spyne/model/primitive/number.pyr      s    r   c                       sl   e Zd ZdZdZejZG dd„ dej	ƒZ	dd„ Z
e‡ fdd„ƒZed	d
„ ƒZedd„ ƒZedd„ ƒZ‡  ZS )ÚDecimala€  The primitive that corresponds to the native python Decimal.

    This is also the base class for denoting numbers.

    Note that it is your responsibility to make sure that the scale and
    precision constraints set in this type is consistent with the values in the
    context of the decimal package. See the :func:`decimal.getcontext`
    documentation for more information.
    Údecimalc                   @   sz   e Zd ZdZe d¡Z	 e d¡Z	 e d¡Z	 e d¡Z		 dZ
	 dZ	 dZ	 dZ	 e d¡Z	 e d¡Z	 dZ	 dZdS )zDecimal.AttributeszSCustomizable attributes of the :class:`spyne.model.primitive.Decimal`
        type.ú-infÚinfi   N)r   r   r	   Ú__doc__r   r   ÚgtÚgeÚltÚleÚmax_str_lenÚformatÚ
str_formatÚpatternÚtotal_digitsÚfraction_digitsÚ	min_boundÚ	max_boundr
   r
   r
   r   Ú
Attributes2   s4    





r   c                 O   sv   t |ƒdksJ ‚t |ƒdkr0|d d ur0|d |d< d|d< t |ƒdkr0|d d ur0|d |d< tj| fi |¤Ž}|S )Né   é   r   r   r   )Úlenr   Ú__new__)ÚclsÚargsÚkwargsÚretvalr
   r
   r   r!   `   s   zDecimal.__new__c                    sì  |  dd ¡}|  dd ¡}|d ur(|d ur(|dksJ dƒ‚||ks(J d||f ƒ‚|  dd ¡}|d u r;| jjd |d< n||d< | jj}| jj}|  dd ¡}|  d	d ¡}|  d
d ¡}	|  dd ¡}
|d ur¥|d urt||k rttd||f tƒ |d ur…||k r…td||f tƒ |	d ur•|	|k r•td|	|f ƒ‚|
d ur¥|
|kr¥td|
|f ƒ‚|d urë|	d urº|	|krºtd|	|f tƒ |
d urË|
|krËtd|
|f tƒ |d urÛ||krÛtd||f ƒ‚|d urë||krëtd||f ƒ‚tt	| ƒj
di |¤ŽS )Nr   r   r   z 'total_digits' must be positive.zM'total_digits' must be greater than or equal to 'fraction_digits'. %r ! <= %rr   r   r   r   r   r   z:'Greater than or equal value' %d smaller than min_bound %dz1'Greater than' value %d smaller than min_bound %dz9'Little than or equal' value %d smaller than min_bound %dz0'Little than' value %d smaller than min_bound %dz9'Little than or equal' value %d greater than max_bound %dz0'Little than' value %d greater than max_bound %dz:'Greater than or equal' value %d greater than max_bound %dz1'Greater than' value %d greater than max_bound %dr
   )Úgetr   r   r   r   r   r   Ú
ValueErrorÚsuperr   Ú_s_customize)r"   r$   ÚtdÚfdÚmslÚminbÚmaxbr   r   r   r   ©Ú	__class__r
   r   r)   m   sŒ   
þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿzDecimal._s_customizec                 C   sj   t  | ¡o4| jjtjjko4| jjtjjko4| jjtjjko4| jjtjjko4| jjtjjko4| jj	tjj	kS ©N)
r   Ú
is_defaultr   r   r   r   r   r   r   r   ©r"   r
   r
   r   r2   °   s"   
ÿþýüÿûÿùzDecimal.is_defaultc                 C   s$   t  | |¡o|d u pt|ƒ| jjkS r1   )r   Úvalidate_stringr    r   r   ©r"   Úvaluer
   r
   r   r4   ½   s   ÿzDecimal.validate_stringc                 C   sD   t  | |¡o!|d u p!|| jjko!|| jjko!|| jjk o!|| jjkS r1   )r   Úvalidate_nativer   r   r   r   r   r5   r
   r
   r   r7   Ã   s   
ÿ
þ
ûzDecimal.validate_native)r   r   r	   r   Ú__type_name__r   r   ÚValuer   r   r!   Úclassmethodr)   Ústaticmethodr2   r4   r7   Ú__classcell__r
   r
   r/   r   r   "   s    
.B

r   c                   @   sN   e Zd ZdZdZeZe ¡ dd… dkr%G dd„ de	j
ƒZ
edd	„ ƒZdS dS )
ÚDoublea“  As this type is serialized as the python ``float`` type, it comes with
    its gotchas. Unless you know what you're doing, you should use a
    :class:`Decimal` with a pre-defined number of integer and decimal digits
    because the string representation of a floating-point number translates
    better to or from the Decimal type.

    .. NOTE::
        This class is not compatible with :class:`spyne.model.Decimal`. You can
        get strange results if you're using a `decimal.Decimal` instance for a
        field denoted as `Double` or `Float` and vice versa. Make sure you only
        return instances of types compatible with designated types.
    ÚdoubleNr   )Ú2Ú6c                   @   s6   e Zd ZdZedƒZ	 edƒZ	 edƒZ	 edƒZdS )zDouble.AttributeszÛCustomizable attributes of the :class:`spyne.model.primitive.Double`
            type. This class is only here for Python 2.6: See this bug report
            for more info: http://bugs.python.org/issue2531
            r   r   N)	r   r   r	   r   Úfloatr   r   r   r   r
   r
   r
   r   r   à   s    r   c                 C   sJ   t  | ¡o$| jjtjjko$| jjtjjko$| jjtjjko$| jjtjjkS r1   )r   r2   r   r   r=   r   r   r   r3   r
   r
   r   r2   ò   s   
ÿþýüzDouble.is_default)r   r   r	   r   r8   rA   r9   ÚplatformÚpython_version_tupler   r   r;   r2   r
   r
   r
   r   r=   Î   s    ìr=   c                   @   s   e Zd ZdZdZdS )ÚFloatzlSynonym for Double (as far as python side of things are concerned).
    It's here for compatibility reasons.rA   N)r   r   r	   r   r8   r
   r
   r
   r   rD   ü   s    rD   c                   @   s$   e Zd ZdZdZeZedd„ ƒZdS )ÚIntegerz"The arbitrary-size signed integer.Úintegerc                 C   s    t  | |¡o|d u pt|ƒ|kS r1   )r   r7   Úintr5   r
   r
   r   r7   	  s   ÿzInteger.validate_nativeN)	r   r   r	   r   r8   rG   r9   r;   r7   r
   r
   r
   r   rE     s    rE   c                   @   ó    e Zd ZdZdZedd„ ƒZdS )ÚUnsignedIntegerzFThe arbitrary-size unsigned integer, also known as nonNegativeInteger.ÚnonNegativeIntegerc                 C   s   t  | |¡o|d u p|dkS ©Nr   ©rE   r7   r5   r
   r
   r   r7     ó   ÿzUnsignedInteger.validate_nativeN©r   r   r	   r   r8   r;   r7   r
   r
   r
   r   rI     s
    rI   c                   @   rH   )ÚPositiveIntegerz5The arbitrary-size positive integer (natural number).ÚpositiveIntegerc                 C   s   t  | |¡o|d u p|dkS rK   rL   r5   r
   r
   r   r7   &  rM   zPositiveInteger.validate_nativeNrN   r
   r
   r
   r   rO      s
    rO   c                    s<   dˆd >  ‰dˆd > d ‰ G ‡ ‡‡‡fdd„dt ƒ}|S )Né   é   r   c                       ó<   e Zd Z”ZG ‡ ‡‡fdd„dejƒZe‡ ‡fdd„ƒZdS )z(TBoundedInteger.<locals>._BoundedIntegerc                       ó*   e Zd Ze e d” d¡¡Z”Z” ZdS )z3TBoundedInteger.<locals>._BoundedInteger.Attributesr   é
   N©	r   r   r	   ÚmathÚceilÚlogr   r   r   r
   ©Ú_max_bÚ_min_bÚnum_bitsr
   r   r   3  ó    r   c                    s,   t  | |¡o|d u pˆ|  koˆ kS   S r1   rL   r5   ©r[   r\   r
   r   r7   8  ó
   þþz8TBoundedInteger.<locals>._BoundedInteger.validate_nativeN)r   r   r	   r8   rE   r   r;   r7   r
   ©r[   r\   r]   Ú	type_namer
   r   Ú_BoundedInteger0  ó
    rc   )rE   )r]   rb   rc   r
   ra   r   ÚTBoundedInteger,  s   re   c                    s.   d‰dˆ d ‰ G ‡ ‡‡‡fdd„dt ƒ}|S )Nr   r   r   c                       rS   )z8TBoundedUnsignedInteger.<locals>._BoundedUnsignedIntegerc                       rT   )zCTBoundedUnsignedInteger.<locals>._BoundedUnsignedInteger.Attributesr   rU   NrV   r
   rZ   r
   r   r   I  r^   r   c                    s,   t  | |¡o|d u pˆ|  koˆ k S   S r1   )rI   r7   r5   r_   r
   r   r7   N  r`   zHTBoundedUnsignedInteger.<locals>._BoundedUnsignedInteger.validate_nativeN)r   r   r	   r8   rI   r   r;   r7   r
   ra   r
   r   Ú_BoundedUnsignedIntegerF  rd   rf   )rI   )r]   rb   rf   r
   ra   r   ÚTBoundedUnsignedIntegerB  s   rg   é@   Úlongé    rG   é   ÚshortrQ   ÚbyteÚunsignedLongÚunsignedIntÚunsignedShortÚunsignedBytel        ),rW   r   rB   Ú	_warningsr   Úspyne.modelr   Úspyne.model.primitiver   Ú
spyne.utilr   ÚWarningr   r   r=   rD   rE   rI   ÚNonNegativeIntegerrO   re   rg   Ú	Integer64ÚLongÚ	Integer32ÚIntÚ	Integer16ÚShortÚInteger8ÚByteÚUnsignedInteger64ÚUnsignedLongÚUnsignedInteger32ÚUnsignedIntÚUnsignedInteger16ÚUnsignedShortÚUnsignedInteger8ÚUnsignedByteÚupdaterA   ÚPY2rG   ri   Ú
isinstancer
   r
   r
   r   Ú<module>   s‚    -.







þ
ÿÿ
