a
    5Xh                     @   s2   d dl mZ d dlmZ d dlmZ d	ddZdS )
    )Decimal)settings)	mark_safeN Fc                 C   sv  | du s| dkrt | S |s*|du o.tjo.tj}|p6|}|oB|dk}t| tr^|s^|s^t | S d}t| trdt|  v rt	t| } t| t	r,|durt	dd
|d }	t| |	k rt	d} |  \}
}}t|t| dkr d	| } | d\}}t|||||||}d
||S d| }nt| }|d dkrRd}|dd }d|v r|d\}}|dur|d| }n
|d }}|dur|d|t|  7 }|o|| }|rjzt|}W n ty   |dg}Y n0 |d}d}d}|ddd D ]R}|rH||krH|r2|dp0|}||ddd 7 }d}||7 }|d7 }q|ddd }|| | S )aT  
    Get a number (as a number or string), and return it as a string,
    using formats defined as arguments:

    * decimal_sep: Decimal separator symbol (for example ".")
    * decimal_pos: Number of decimal positions
    * grouping: Number of digits in every group limited by thousand separator.
        For non-uniform digit grouping, it can be a sequence with the number
        of digit group sizes following the format used by the Python locale
        module in locale.localeconv() LC_NUMERIC grouping (e.g. (3, 2, 0)).
    * thousand_sep: Thousand separator symbol (for example ",")
    Nr   r   ez0.10   z{:e}z{}e{}z{:f}-   .)r   r   ZUSE_L10NZUSE_THOUSAND_SEPARATOR
isinstanceintfloatstrlowerr   rjustabsas_tuplelenformatsplitlist	TypeErrorpop)numberZdecimal_sepZdecimal_posgroupingZthousand_sepZforce_groupingZuse_l10nZuse_groupingsigncutoff_digitsexponentZcoefficientZ
str_numberZint_partZdec_partZ	intervalsZactive_intervalZint_part_gdZcntdigit r$   ^/var/www/viveiro_mudafortebrasil/venv/lib/python3.9/site-packages/django/utils/numberformat.pyr      s~    
	




r   )Nr   r   FN)decimalr   Zdjango.confr   Zdjango.utils.safestringr   r   r$   r$   r$   r%   <module>   s        