Ë
    Ã?ÆiÏ  ã                  óV   — d Z ddlmZ ddl­ ddlmZmZ dd„Zdd„Zdd„Z	dd„Z
dd	„Zy
)u­  CUI (CÃ©dula Ãšnica de Identidad, Peruvian identity number).

The CÃ©dula Ãšnica de Identidad (CUI) is the unique identifier for persons that
appears on the Documento Nacional de Identidad (DNI), the national identity
document of Peru. The number consists of 8 digits and an optional extra check
digit.

More information:

* https://www.gob.pe/235-documento-nacional-de-identidad-dni
* https://es.wikipedia.org/wiki/Documento_Nacional_de_Identidad_(PerÃº)

>>> validate('10117410')
'10117410'
>>> validate('10117410-2')
'101174102'
>>> validate('10117410-3')  # invalid check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> to_ruc('10117410-2')
'10101174102'
é    )Úannotations)Ú*)ÚcleanÚisdigitsc                óR   — t        | d«      j                  «       j                  «       S )zˆConvert the number to the minimal representation. This strips the
    number of any valid separators and removes surrounding whitespace.z -)r   ÚstripÚupper©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/pe/cui.pyÚcompactr   3   s#   € ô �˜Ó×$Ñ$Ó&×,Ñ,Ó.Ð.ó    c                óp   — t        | «      } d}t        d„ t        || «      D «       «      dz  }d|   d|   z   S )z0Calculate the possible check digits for the CUI.)é   é   é   é   é   é   r   r   c              3  ó>   K  — | ]  \  }}|t        |«      z  –— Œ y ­w)N)Úint)Ú.0ÚwÚns      r   ú	<genexpr>z$calc_check_digits.<locals>.<genexpr>=   s   è ø€ Ò8™4˜1˜aˆA”�A“�JÑ8ùs   ‚é   Ú65432110987ÚKJIHGFEDCBA)r   ÚsumÚzip)r   ÚweightsÚcs      r   Úcalc_check_digitsr#   9   sA   € ä�V‹_€FØ&€GÜÑ8¤3 w°Ó#7Ô8Ó8¸2Ñ=€AØ˜Ñ˜m¨AÑ.Ñ.Ð.r   c                óX   — ddl m} dt        | «      dd z   } | |j                  | «      z   S )z"Convert the number to a valid RUC.r   )ÚrucÚ10Né   )Ú	stdnum.per%   r   Úcalc_check_digit)r   r%   s     r   Úto_rucr*   A   s0   € åØ”G˜F“O B QÐ'Ñ'€FØ�C×(Ñ(¨Ó0Ñ0Ð0r   c                óÊ   — t        | «      } t        | «      dvr
t        «       ‚t        | dd «      s
t	        «       ‚t        | «      dkD  r| d   t        | «      vr
t        «       ‚| S )údCheck if the number provided is a valid CUI. This checks the length,
    formatting and check digit.)r'   é	   Nr'   éÿÿÿÿ)r   ÚlenÚInvalidLengthr   ÚInvalidFormatr#   ÚInvalidChecksumr
   s    r   Úvalidater3   H   sa   € ô �V‹_€FÜ
ˆ6ƒ{˜&Ñ Ü‹oÐÜ�F˜2˜A�JÔÜ‹oÐÜ
ˆ6ƒ{�Q‚˜6 "™:Ô->¸vÓ-FÑFÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)r,   F)Úboolr3   ÚValidationErrorr
   s    r   Úis_validr7   U   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"N)r   ÚstrÚreturnr8   )r   r8   r9   r5   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r#   r*   r3   r7   © r   r   ú<module>r?      s.   ðñ*õ0 #ä ß 'ó/ó/ó1ó
ôr   