Ë
    Ã?Æi?  ã                  óz   — U d Z ddlmZ ddl­ dZerddlmZ eee      ZdZ	de
d<   ddd
„Zddd„Zddd„Zddd„Zy	)aÙ  The Damm algorithm.

The Damm algorithm is a check digit algorithm that should detect all
single-digit errors and all adjacent transposition errors. Based on
anti-symmetric quasigroup of order 10 it uses a substitution table.

This implementation uses the table from Wikipedia by default but a custom
table can be provided.

More information:

* https://en.wikipedia.org/wiki/Damm_algorithm

>>> validate('572')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> calc_check_digit('572')
'4'
>>> validate('5724')
'5724'
>>> table = (
...     (0, 2, 3, 4, 5, 6, 7, 8, 9, 1),
...     (2, 0, 4, 1, 7, 9, 5, 3, 8, 6),
...     (3, 7, 0, 5, 2, 8, 1, 6, 4, 9),
...     (4, 1, 8, 0, 6, 3, 9, 2, 7, 5),
...     (5, 6, 2, 9, 0, 7, 4, 1, 3, 8),
...     (6, 9, 7, 3, 1, 0, 8, 5, 2, 4),
...     (7, 5, 1, 8, 4, 2, 0, 9, 6, 3),
...     (8, 4, 6, 2, 9, 5, 3, 0, 1, 7),
...     (9, 8, 5, 7, 3, 1, 6, 4, 0, 2),
...     (1, 3, 9, 6, 8, 4, 2, 7, 5, 0))
>>> checksum('816', table=table)
9
é    )Úannotations)Ú*F)ÚSequence)
)
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   Ú	DammTableÚ_operation_tableNc                ó`   — |xs t         }d}t        | «      D ]  }||   t        |«         }Œ |S )z‚Calculate the Damm checksum over the provided number. The checksum is
    returned as an integer value and should be 0 when valid.r   )r   ÚstrÚint)ÚnumberÚtableÚiÚns       úR/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/damm.pyÚchecksumr   P   s>   € ð Ò%Ô%€EØ	€AÜ�‹[ò ˆØ�!‰H”S˜“VÑ‰ðà€Hó    c                ó˜   — t        | «      s
t        «       ‚	 t        | |¬«      dk(  }|s
t	        «       ‚| S # t        $ r t        «       ‚w xY w)ú7Check if the number provided passes the Damm algorithm.©r   r   )ÚboolÚInvalidFormatr   Ú	ExceptionÚInvalidChecksum)r   r   Úvalids      r   Úvalidater#   Z   sS   € ä�Œ<Ü‹oÐðÜ˜ uÔ-°Ñ2ˆñ ÜÓÐØ€Møô	 ò Ü‹oÐðús	   —5 µA	c                óN   — 	 t        t        | |¬«      «      S # t        $ r Y yw xY w)r   r   F)r   r#   ÚValidationError©r   r   s     r   Úis_validr'   g   s+   € ðÜ”H˜V¨5Ô1Ó2Ð2øÜò Ùðús   ‚ ˜	$£$c                ó.   — t        t        | |¬«      «      S )z^Calculate the extra digit that should be appended to the number to
    make it a valid number.r   )r   r   r&   s     r   Úcalc_check_digitr)   o   s   € ô Œx˜ eÔ,Ó-Ð-r   )N)r   r   r   úDammTable | NoneÚreturnr   )r   r   r   r*   r+   r   )r   r   r   r*   r+   r   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚTYPE_CHECKINGÚcollections.abcr   r   r   r   Ú__annotations__r   r#   r'   r)   © r   r   ú<module>r3      sQ   ðò("õH #ä ð €ÙÝ(Ø˜ #™Ñ'€Ið
$Ð �)ó 
$ôô
ôõ.r   