Ë
    Ã?Æi£  ã                  ó”   — d Z ddlmZ ddl­ ddlmZ ddlmZ dd„Zddd„Z	ddd„Z
dd	„Z	 	 	 d	 	 	 	 	 	 	 	 	 dd
„Zdd„Zdd„Zdd„Zy)a	  ISAN (International Standard Audiovisual Number).

The ISAN (International Standard Audiovisual Number) is used to identify
audiovisual works.

The number is hexadecimal and can consists of at least a root identifier,
and an episode or part. After that an optional check digit, optional
version and optionally another check digit can be provided. The check
digits are validated using the ISO 7064 Mod 37, 36 algorithm.

>>> validate('000000018947000000000000')
'000000018947000000000000'
>>> compact('0000-0000-D07A-0090-Q-0000-0000-X')
'00000000D07A009000000000'
>>> validate('0000-0001-8CFA-0000-I-0000-0000-K')
'000000018CFA0000I00000000K'
>>> validate('0000-0001-8CFA-0000-A-0000-0000-K')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> format('000000018947000000000000')
'0000-0001-8947-0000-8-0000-0000-D'

>>> to_urn('00000000D07A009000000000')
'URN:ISAN:0000-0000-D07A-0090-Q-0000-0000-X'
>>> to_xml('1881-66C7-3420-6541-Y-9F3A-0245-O')
'<ISAN root="1881-66C7-3420" episode="6541" version="9F3A-0245" />'
é    )Úannotations)Ú*)Ú	mod_37_36)Úcleanc                ó  — t        | d«      j                  «       j                  «       } t        | «      dk(  st        | «      dk(  r| dd | dd | d   | dd | dd fS t        | «      dkD  r| dd | dd d	| dd
 | d
d fS | dd | dd | dd d	d	fS )z§Split the number into a root, an episode or part, a check digit a
    version and another check digit. If any of the parts are missing an empty
    string is returned.z -é   é   r   é   é   é   NÚ é   )r   ÚstripÚupperÚlen©Únumbers    úR/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/isan.pyÚsplitr   9   s¾   € ô �6˜4Ó ×&Ñ&Ó(×.Ñ.Ó0€FÜ
ˆ6ƒ{�bÒœC ›K¨2Ò-Ø�a˜ˆ|˜V B r˜]¨F°2©J¸¸rÀ"¸ÀvÈbÈcÀ{ÐRÐRÜ	ˆV‹�rÒ	Ø�a˜ˆ|˜V B r˜]¨B°°r¸"°¸vÀbÀc¸{ÐJÐJà�a˜ˆ|˜V B r˜]¨F°2°3¨K¸¸RÐ?Ð?ó    c                ód   — t        t        | «      «      }|r
dx|d<   |d<   dj                  |«      S )z³Convert the ISAN to the minimal representation. This strips the number
    of any valid separators and removes surrounding whitespace. The check
    digits are removed by default.r   é   é   )Úlistr   Újoin)r   Ústrip_check_digitsÚpartss      r   Úcompactr   F   s5   € ô ”�v“Ó€EÙØ Ð ˆˆa‰�5˜‘8Ø�7‰7�5‹>Ðr   c                ó  — t        | «      \  }}}}}||z   |z   D ]  }|dvsŒt        «       ‚ t        |«      dk7  s5t        |«      dk7  s't        |«      dvst        |«      dvst        |«      dvr
t        «       ‚|rdx}}|rt	        j
                  ||z   |z   «       |rt	        j
                  ||z   |z   |z   «       |r|st	        j                  ||z   «      }|r|s|rt	        j                  ||z   |z   «      }||z   |z   |z   |z   S )a,  Check if the number provided is a valid ISAN. If check digits are
    present in the number they are validated. If strip_check_digits is True
    any existing check digits will be removed (after checking). If
    add_check_digits is True the check digit will be added if they are not
    present yet.Ú0123456789ABCDEFr
   r   )r   é   )r   é   r   )r   ÚInvalidFormatr   ÚInvalidLengthr   ÚvalidateÚcalc_check_digit)	r   r   Úadd_check_digitsÚrootÚepisodeÚcheck1ÚversionÚcheck2Úxs	            r   r%   r%   P   s  € ô 05°V«}Ñ,€Tˆ7�F˜G Và�G‰^˜gÑ%ò "ˆØÐ&Ò&Ü“/Ð!ð"ô ˆ4ƒy�B‚œ#˜g›,¨!Ò+¬s°6«{À&Ñ/HÜ
ˆ7ƒ|˜6Ñ!¤S¨£[¸Ñ%>Ü‹oÐáØÐˆ�áÜ×Ñ˜4 '™>¨FÑ2Ô3ÙÜ×Ñ˜4 '™>¨GÑ3°fÑ<Ô=á¡Ü×+Ñ+¨D°7©NÓ;ˆÙ¡©7Ü×+Ñ+¨D°7©N¸WÑ,DÓEˆØ�'‰>˜FÑ" WÑ,¨vÑ5Ð5r   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)zoCheck if the number provided is a valid ISAN. If check digits are
    present in the number they are validated.F)Úboolr%   ÚValidationErrorr   s    r   Úis_validr1   o   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                ó¢  — t        | «      \  }}}}}|rdx}}|r|st        j                  ||z   «      }|r|s|rt        j                  ||z   |z   «      }t        ddd«      D �	cg c]
  }	||	|	dz    ‘Œ c}	|gz   }
|r|
j	                  |«       |r|
j                  |dd |dd f«       |r|
j	                  |«       |j                  |
«      S c c}	w )zûReformat the number to the standard presentation format. If
    add_check_digits is True the check digit will be added if they are not
    present yet. If both strip_check_digits and add_check_digits are True the
    check digits will be recalculated.r   r   r
   r   N)r   r   r&   ÚrangeÚappendÚextendr   )r   Ú	separatorr   r'   r(   r)   r*   r+   r,   Úir   s              r   Úformatr8   x   sÙ   € ô 05°V«}Ñ,€Tˆ7�F˜G VÙØÐˆ�Ù¡Ü×+Ñ+¨D°7©NÓ;ˆÙ¡©7Ü×+Ñ+¨D°7©N¸WÑ,DÓEˆÜ$)¨!¨R°£OÖ4˜qˆT�!�A˜‘EŠ]Ò4¸°yÑ@€EÙØ�‰�VÔÙØ�‰�g˜a �l G¨A¨B KÐ0Ô1ÙØ�‰�VÔØ�>‰>˜%Ó Ð ùò 5s   Á$Cc                ó4   — ddl m}  |t        | d¬«      «      S )zOConvert the number to its binary representation (without the check
    digits).r   )Úa2b_hexT)r   )Úbinasciir:   r   )r   r:   s     r   Ú	to_binaryr<   “   s   € õ !Ù”7˜6°dÔ;Ó<Ð<r   c                óH   — t        | dd¬«      } d| dd ›d| dd	 ›d
| dd ›d�S )z,Return the XML form of the ISAN as a string.TF)r   r'   z<ISAN root="r   é   z" episode="é   é   z" version="é   Nz" />©r8   r   s    r   Úto_xmlrC   š   s3   € ä�F¨tÀeÔL�Fàˆq�Š�f˜R ’m V¨B¨C¢[ð2ð 2r   c                ó"   — dt        | d¬«      z   S )z*Return the URN representation of the ISAN.z	URN:ISAN:T)r'   rB   r   s    r   Úto_urnrE   ¡   s   € àœ ¸Ô>Ñ>Ð>r   N)r   ÚstrÚreturnztuple[str, str, str, str, str])T)r   rF   r   r/   rG   rF   )FF)r   rF   r   r/   r'   r/   rG   rF   )r   rF   rG   r/   )ú-FT)
r   rF   r6   rF   r   r/   r'   r/   rG   rF   )r   rF   rG   Úbytes)r   rF   rG   rF   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.iso7064r   Ústdnum.utilr   r   r   r%   r1   r8   r<   rC   rE   © r   r   ú<module>rP      sz   ðñ*õ: #ä Ý $Ý ó
@ôô6ó>ð Ø$Ø!ð	!Øð!àð!ð ð!ð ð	!ð
 	ó!ó6=ó2ô?r   