a
    ¦¾deÜ  ã                   @   sþ   d Z dZdZddlZG dd„ dƒZe d¡Ze d¡ZG d	d
„ d
eƒZe	dk� rúd$dd„Z
e
ddddd� e
ddddd� e
ddddd� e
ddddd� e
dddƒ e
dddƒ e
dddƒ e
dddƒ e
dddƒ e
dddƒ e
d d!dƒ e
d"d#dƒ dS )%)Ú	FormatterÚDecimalFormatterz3.3.0z]
These help format numbers and dates in a user friendly way.
Used by the graphics framework.
é    Nc                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )r   z5Base formatter - simply applies python format stringsc                 C   s
   || _ d S ©N©Úpattern)Úselfr   © r   úQ/var/www/sistema_ama/venv/lib/python3.9/site-packages/reportlab/lib/formatters.pyÚ__init__   s    zFormatter.__init__c                 C   s
   | j | S r   r   )r   Úobjr   r   r	   Úformat   s    zFormatter.formatc                 C   s   d| j j| jf S )Nz%s('%s'))Ú	__class__Ú__name__r   ©r   r   r   r	   Ú__repr__   s    zFormatter.__repr__c                 C   s
   |   |¡S r   )r   )r   Úxr   r   r	   Ú__call__   s    zFormatter.__call__N)r   Ú
__module__Ú__qualname__Ú__doc__r
   r   r   r   r   r   r   r	   r      s
   r   z^\d*\.z0+$c                   @   s2   e Zd ZdZddd„Zdd„ Zd	d
„ Zdd„ ZdS )r   z¢lets you specify how to build a decimal.

    A future NumberFormatter class will take Microsoft-style patterns
    instead - "$#,##0.00" is WAY easier than this.é   Ú.Nc                 C   s4   |dkr| j | _n|| _|| _|| _|| _|| _d S )NÚauto)Ú_calcPlacesZ
calcPlacesÚplacesÚdotÚcommaÚprefixÚsuffix)r   r   Ú
decimalSepÚthousandSepr   r   r   r   r	   r
       s    
zDecimalFormatter.__init__c                 C   s   t dd„ |D ƒƒ| _dS )zMcalled with the full set of values to be formatted so we can calculate placesc                 S   s(   g | ] }t t d t d t|ƒ¡¡ƒ‘qS )Ú )ÚlenÚ_tz_reÚsubÚ_ld_reÚstr)Ú.0Úvr   r   r	   Ú
<listcomp>,   ó    z0DecimalFormatter._calcPlaces.<locals>.<listcomp>N)Úmaxr   )r   ÚVr   r   r	   r   *   s    zDecimalFormatter._calcPlacesc                 C   s"  |dk }|r| }| j | j }}|dk}|r6|r6| }dt|ƒ d | }|rŒ| d¡\}}|| }|r�|r�|d d|fv r�|d d… }qhnd}| jd uræd}|râ|dd… |dd …  }	}
|	dkrÎ|
| }n| j|
 | }|	}qž|}|| }|rúd	| }| j�r| j| }| j�r|| j }|S )
Nr   z%.Úfr   éÿÿÿÿÚ0r!   éýÿÿÿú-)r   r   r&   Úsplitr   r   r   )r   ÚnumÚsignr   ÚsepÚstripZstrIntZstrFracZstrNewÚleftÚrightZstrBodyr   r   r	   r   .   s:    $



zDecimalFormatter.formatc                 C   s2   d| j j| jt| jƒt| jƒt| jƒt| jƒf S )NzB%s(places=%d, decimalSep=%s, thousandSep=%s, prefix=%s, suffix=%s))r   r   r   Úreprr   r   r   r   r   r   r   r	   r   S   s    úzDecimalFormatter.__repr__)r   r   NNN)r   r   r   r   r
   r   r   r   r   r   r   r	   r      s
   

%r   Ú__main__r   r   c           	   
   C   sL   t |||||ƒ}|| ƒ}td|j|j|j|j|j|||kr>dp@df ƒ d S )NzEplaces=%2d dot=%-4s comma=%-4s prefix=%-4s suffix=%-4s result=%10s %sÚOKÚBAD)r   Úprintr   r   r   r   r   )	ÚnÚsr   r   r    r   r   r-   Úrr   r   r	   Út^   s    rA   g33333G�@z1,000.9é   ú,)r    gš™™™™G�@z1,001.0z1,001r.   z1000.9z1001.0Z1001gÍÌÌÌÌ@�@z1000.1gfffffD�@z1000.6g;ßO�—C�@z1000.4gš™™™™C�@Z1000)r   r   NNN)Ú__all__Ú__version__r   Úrer   Úcompiler%   r#   r   r   rA   r   r   r   r	   Ú<module>   s*   

B

