o
    &zh                     @   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 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   S/var/www/html/kangema/venv/lib/python3.10/site-packages/reportlab/lib/formatters.py__init__      
zFormatter.__init__c                 C   s
   | j | S r   r   )r   objr   r   r	   format   r   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__   r   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   zlets 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)_calcPlaces
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>,   s   ( z0DecimalFormatter._calcPlaces.<locals>.<listcomp>N)maxr   )r   Vr   r   r	   r   *   s   zDecimalFormatter._calcPlacesc                 C   s2  |dk }|r	| }| j | j}}|dk}|r|r| }dt| d | }|rO|d\}}|| }|rN|rN|d d|fv rN|d d }|rN|d d|fv s>nd}| jd ur}d}|r{|dd |dd  }	}
|	dkrp|
| }n| j|
 | }|	}|sZ|}|| }|rd	| }| jr| j| }| jr|| j }|S )
Nr   z%.fr   0r#   -)r   r   r(   splitr   r   r    )r   numsignr   sepstripstrIntstrFracstrNewleftrightstrBodyr   r   r	   r   .   s>   4



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   4rG   g33333G@z1,000.9   ,)r"   gG@z1,001.0z1,001r/   z1000.9z1001.01001g@@z1000.1gfffffD@z1000.6g;OC@z1000.4gC@1000r?   )__all____version__r   rer   compiler'   r%   r   r   rG   r   r   r   r	   <module>   s.   

B
