
    j
                     L    d dl mZmZ d dlmZ e G d d                      ZdS )   )i18nImproperlyConfigured)str_coerciblec                   x    e Zd ZdZd Zed             Zed             Zed             Z	d Z
d Zd Zd	 Zd
 ZdS )Currencya  
    Currency class wraps a 3-letter currency code. It provides various
    convenience properties and methods.

    ::

        from babel import Locale
        from sqlalchemy_utils import Currency, i18n


        # First lets add a locale getter for testing purposes
        i18n.get_locale = lambda: Locale('en')


        Currency('USD').name  # US Dollar
        Currency('USD').symbol  # $

        Currency(Currency('USD')).code  # 'USD'

    Currency always validates the given code if you use at least the optional
    dependency list 'babel', otherwise no validation are performed.

    ::

        Currency(None)  # raises TypeError

        Currency('UnknownCode')  # raises ValueError


    Currency supports equality operators.

    ::

        Currency('USD') == Currency('USD')
        Currency('USD') != Currency('EUR')


    Currencies are hashable.


    ::

        len(set([Currency('USD'), Currency('USD')]))  # 1


    c                     t           j        t          d          t          |t                    r	|| _        d S t          |t                    r|                     |           || _        d S t          d          )Nz;'babel' package is required in order to use Currency class.zzFirst argument given to Currency constructor should be either an instance of Currency or valid three letter currency code.)	r   babelr   
isinstancer   codestrvalidate	TypeErrorselfr   s     n/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/sqlalchemy_utils/primitives/currency.py__init__zCurrency.__init__5   s    :&M   dH%% 
	DIIIc"" 	MM$DIII!      c                     	 t           j                            d          j        |          d S # t          $ r t          d| d          t          $ r Y d S w xY w)Nen'z' is not valid currency code.)r   r	   Locale
currenciesKeyError
ValueErrorAttributeErrorr   s     r   r   zCurrency.validateF   s|    	Jd##.t4444 	F 	F 	FDDDDEEE 	 	 	DD	s   *. &AAc                 x    t           j        j                            | j        t          j                              S N)r   r	   numbersget_currency_symbolr   
get_localer   s    r   symbolzCurrency.symbolP   s/    z!55IO
 
 	
r   c                 H    t          j                    j        | j                 S r   )r   r    r   r   r!   s    r   namezCurrency.nameW   s      +DI66r   c                     t          |t                    r| j        |j        k    S t          |t                    r| j        |k    S t          S r   )r
   r   r   r   NotImplementedr   others     r   __eq__zCurrency.__eq__[   sH    eX&& 	"9
**s## 	"9%%!!r   c                     | |k     S r    r'   s     r   __ne__zCurrency.__ne__c   s    EM""r   c                 *    t          | j                  S r   )hashr   r!   s    r   __hash__zCurrency.__hash__f   s    DIr   c                 0    | j         j         d| j        dS )N())	__class____name__r   r!   s    r   __repr__zCurrency.__repr__i   s     .)::DI::::r   c                     | j         S r   )r   r!   s    r   __unicode__zCurrency.__unicode__l   s
    yr   N)r4   
__module____qualname____doc__r   classmethodr   propertyr"   r$   r)   r,   r/   r5   r7   r+   r   r   r   r      s        - -\  "   [ 
 
 X
 7 7 X7" " "# # #  ; ; ;    r   r   N) r   r   utilsr   r   r+   r   r   <module>r?      sw    ) ) ) ) ) ) ) ) ! ! ! ! ! ! g g g g g g g g g gr   