o
    7D©iV  ã                   @   sf   d Z ddlmZ defdd„Zdefdd„Zedefd	d„ƒZedefd
d„ƒZedefdd„ƒZdS )zFinance.é   )Ú	validatorÚcusipc                 C   sì   d\}}t dƒD ]g}| | }|dkr|dkrt|ƒtdƒ }n>|dkr2|dkr2dt|ƒ tdƒ }n+|dkrE|d	krEdt|ƒ tdƒ }n|d
krLd}n|dkrSd}n
|dkrZd}n dS |d@ re||7 }||d  |d  }q|d dkS )N©é    Né	   Ú0Ú9ÚAÚZé
   ÚaÚzÚ*é$   ú@é%   ú#é&   Fr   r   ©ÚrangeÚord)r   ÚcheckÚvalÚidxÚc© r   úK/var/www/Datamplify/venv/lib/python3.10/site-packages/validators/finance.pyÚ_cusip_checksum   s(   r   Úvaluec                 C   s¶   d\}}t dƒD ]L}| | }|dkr#|dkr#|dkr#t|ƒtdƒ }n)|dkr6|dkr6dt|ƒ tdƒ }n|d	krI|d
krIdt|ƒ td	ƒ }n dS |d@ rT||7 }q|d dkS )Nr   é   r   r   r   r	   r
   r   r   r   Fr   r   )r   r   r   r   r   r   r   r   Ú_isin_checksum"   s   €r    c                 C   ó   t | ƒdko	t| ƒS )añ  Return whether or not given value is a valid CUSIP.

    Checks if the value is a valid [CUSIP][1].
    [1]: https://en.wikipedia.org/wiki/CUSIP

    Examples:
        >>> cusip('037833DP2')
        True
        >>> cusip('037833DP3')
        ValidationError(func=cusip, args={'value': '037833DP3'})

    Args:
        value: CUSIP string to validate.

    Returns:
        (Literal[True]): If `value` is a valid CUSIP string.
        (ValidationError): If `value` is an invalid CUSIP string.
    r   )Úlenr   ©r   r   r   r   r   6   ó   c                 C   r!   )aE  Return whether or not given value is a valid ISIN.

    Checks if the value is a valid [ISIN][1].
    [1]: https://en.wikipedia.org/wiki/International_Securities_Identification_Number

    Examples:
        >>> isin('037833DP2')
        ValidationError(func=isin, args={'value': '037833DP2'})
        >>> isin('037833DP3')
        ValidationError(func=isin, args={'value': '037833DP3'})

    Args:
        value: ISIN string to validate.

    Returns:
        (Literal[True]): If `value` is a valid ISIN string.
        (ValidationError): If `value` is an invalid ISIN string.
    r   )r"   r    r#   r   r   r   ÚisinM   r$   r%   c                 C   s®   t | ƒdkrdS g d¢}d}tdƒD ]>}| | }|dv r dS d}|dkr2|dkr2t|ƒtdƒ }n|d	krE|d
krEdt|ƒ td	ƒ }n dS ||||  7 }q|d dkS )aë  Return whether or not given value is a valid SEDOL.

    Checks if the value is a valid [SEDOL][1].
    [1]: https://en.wikipedia.org/wiki/SEDOL

    Examples:
        >>> sedol('2936921')
        True
        >>> sedol('29A6922')
        ValidationError(func=sedol, args={'value': '29A6922'})

    Args:
        value: SEDOL string to validate.

    Returns:
        (Literal[True]): If `value` is a valid SEDOL string.
        (ValidationError): If `value` is an invalid SEDOL string.
    é   F)r   é   r   r&   r'   r   r   r   ÚAEIOUNr   r   r	   r
   r   )r"   r   r   )r   Úweightsr   r   r   r   r   r   r   Úsedold   s    r*   N)	Ú__doc__Úutilsr   Ústrr   r    r   r%   r*   r   r   r   r   Ú<module>   s    