Ë
    Ã?ÆiK  ã                  óF   — d Z ddlmZ ddl­ dZdZdd„Zdd„Zdd„Zdd	„Z	y
)a>  The Verhoeff algorithm.

The Verhoeff algorithm is a checksum algorithm that should catch most common
(typing) errors in numbers. The algorithm uses two tables for permutations
and multiplications and as a result is more complex than the Luhn algorithm.

More information:

* https://en.wikipedia.org/wiki/Verhoeff_algorithm
* https://en.wikibooks.org/wiki/Algorithm_Implementation/Checksums/Verhoeff_Algorithm

The module provides the checksum() function to calculate the Verhoeff
checksum a calc_check_digit() function to generate a check digit that can be
append to an existing number to result in a number with a valid checksum and
validation functions.

>>> validate('1234')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> checksum('1234')
1
>>> calc_check_digit('1234')
'0'
>>> validate('12340')
'12340'
é    )Úannotations)Ú*)
©
r   é   é   é   é   é   é   é   é   é	   )
r   r   r   r	   r   r   r   r   r   r
   )
r   r   r	   r   r   r   r   r   r
   r   )
r   r	   r   r   r   r   r   r
   r   r   )
r	   r   r   r   r   r   r
   r   r   r   )
r
   r   r   r   r   r   r	   r   r   r   )
r   r
   r   r   r   r   r   r	   r   r   )
r   r   r
   r   r   r   r   r   r	   r   )
r   r   r   r
   r   r   r   r   r   r	   )
r   r   r   r   r
   r	   r   r   r   r   )r   )
r   r
   r   r   r   r   r   r   r   r	   )
r
   r   r   r   r   r   r   r   r	   r   )
r   r   r   r   r   r	   r   r
   r   r   )
r   r	   r
   r   r   r   r   r   r   r   )
r	   r   r   r   r
   r   r   r   r   r   )
r   r   r   r   r   r   r   r	   r   r
   )
r   r   r	   r   r   r   r   r   r
   r   c                ó”   — d}t        d„ t        t        | «      «      D «       «      D ]  \  }}t        |   t        |dz     |      }Œ  |S )zŒCalculate the Verhoeff checksum over the provided number. The checksum
    is returned as an int. Valid numbers should have a checksum of 0.r   c              3  ó2   K  — | ]  }t        |«      –— Œ y ­w)N)Úint)Ú.0Úns     úV/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/verhoeff.pyú	<genexpr>zchecksum.<locals>.<genexpr>S   s   è ø€ Ò@ Qœ#˜aŸ&Ñ@ùs   ‚r   )Ú	enumerateÚreversedÚstrÚ_multiplication_tableÚ_permutation_table)ÚnumberÚcheckÚir   s       r   Úchecksumr   O   sU   € ð €EÜÑ@¬(´3°v³;Ó*?Ô@Ó@ò K‰ˆˆ1Ü% eÑ,Ô-?ÀÀAÁÑ-FÀqÑ-IÑJ‰ðKà€Ló    c                ó”   — t        | «      s
t        «       ‚	 t        | «      dk(  }|s
t	        «       ‚| S # t        $ r t        «       ‚w xY w)ú:Check if the number provided passes the Verhoeff checksum.r   )ÚboolÚInvalidFormatr   Ú	ExceptionÚInvalidChecksum)r   Úvalids     r   Úvalidater'   X   sQ   € ä�Œ<Ü‹oÐðÜ˜Ó  AÑ%ˆñ ÜÓÐØ€Møô	 ò Ü‹oÐðús	   —3 ³Ac                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)r!   F)r"   r'   ÚValidationError©r   s    r   Úis_validr+   e   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                ón   — t        t        t        t        | «      dz   «         j                  d«      «      S )z^Calculate the extra digit that should be appended to the number to
    make it a valid number.Ú0r   )r   r   r   Úindexr*   s    r   Úcalc_check_digitr/   m   s.   € ô Ô$¤X¬c°&«k¸CÑ.?Ó%@ÑA×GÑGÈÓJÓKÐKr   N)r   r   Úreturnr   )r   r   r0   r   )r   r   r0   r"   )
Ú__doc__Ú
__future__r   Ústdnum.exceptionsr   r   r   r'   r+   r/   © r   r   ú<module>r5      s7   ðñ(õ8 #ä ð
$Ð ð$Ð óó
óôLr   