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

The ISBN is the International Standard Book Number, used to identify
publications. An ISBN is used to identify books. Numbers can either have 10
digits (in ISBN-10 format) or 13 digits (in ISBN-13, EAN compatible format).
An ISBN has the following components:

* 3-digit (only in ISBN-13) Bookland code
* 1 to 5-digit group identifier (identifies country or language)
* 1 to 7-digit publisher code
* 1 to 8-digit item number (identifies the book)
* a check digit

More information:

* https://en.wikipedia.org/wiki/International_Standard_Book_Number
* https://www.isbn-international.org/range_file_generation

This module also offers functions for converting to ISBN-13 and formatting
based on how the number should be split into a bookland code, group
identifier, publisher code, item number and check digit.

>>> validate('978-9024538270')
'9789024538270'
>>> validate('978-9024538271')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> compact('1-85798-218-5')
'1857982185'
>>> format('9780471117094')
'978-0-471-11709-4'
>>> format('1857982185')
'1-85798-218-5'
>>> isbn_type('1-85798-218-5')
'ISBN10'
>>> isbn_type('978-0-471-11709-4')
'ISBN13'
>>> to_isbn13('1-85798-218-5')
'978-1-85798-218-3'
>>> to_isbn10('978-1-85798-218-3')
'1-85798-218-5'
é    )Úannotations)Úean)Ú*)ÚcleanÚisdigitsc                ó–   — t        | d«      j                  «       j                  «       } t        | «      dk(  rd| z   } |rt	        | «      S | S )zäConvert the ISBN to the minimal representation. This strips the number
    of any valid ISBN separators and removes surrounding whitespace. If the
    convert parameter is True the number is also converted to ISBN-13
    format.ú -é	   Ú0)r   ÚstripÚupperÚlenÚ	to_isbn13©ÚnumberÚconverts     úR/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/isbn.pyÚcompactr   G   sJ   € ô
 �6˜4Ó ×&Ñ&Ó(×.Ñ.Ó0€FÜ
ˆ6ƒ{�aÒØ�v‘ˆÙÜ˜Ó Ð Ø€Mó    c                ób   — t        d„ t        | «      D «       «      dz  }|dk(  rdS t        |«      S )ztCalculate the ISBN check digit for 10-digit numbers. The number passed
    should not have the check digit included.c              3  óD   K  — | ]  \  }}|d z   t        |«      z  –— Œ y­w)é   N)Úint)Ú.0ÚiÚns      r   ú	<genexpr>z+_calc_isbn10_check_digit.<locals>.<genexpr>W   s)   è ø€ ò /Ù�A�qð �Q‘œ#˜a›&Õ ñ /ùs   ‚ é   é
   ÚX)ÚsumÚ	enumerateÚstr)r   Úchecks     r   Ú_calc_isbn10_check_digitr%   T   s=   € ô ñ /Ü% fÓ-ô/ó /Ø13ñ4€Eà˜2’+ˆ3Ð-¤3 u£:Ð-r   c                ó>  — t        | d¬«      } t        | dd «      s
t        «       ‚t        | «      dk(  rt	        | dd «      | d   k7  rHt        «       ‚t        | «      dk(  r&t        j                  | «       | dd dvrt        «       ‚t        «       ‚|rt        | «      } | S )	úáCheck if the number provided is a valid ISBN (either a legacy 10-digit
    one or a 13-digit one). This checks the length and the check digit but does
    not check if the group and publisher are valid (use split() for that).F©r   Néÿÿÿÿr   é   é   )Ú978Ú979)r   r   ÚInvalidFormatr   r%   ÚInvalidChecksumr   ÚvalidateÚInvalidComponentÚInvalidLengthr   r   s     r   r0   r0   \   s›   € ô �V UÔ+€FÜ�F˜3˜B�KÔ Ü‹oÐÜ
ˆ6ƒ{�bÒÜ# F¨3¨B KÓ0°F¸2±JÒ>Ü!Ó#Ð#Ü	ˆV‹˜Ò	Ü�‰�VÔØ�"�1ˆ:˜^Ñ+Ü"Ó$Ð$ä‹oÐÙÜ˜6Ó"ˆØ€Mr   c                ó\   — 	 t        | d¬«      } t        | «      dk(  ryy# t        $ r Y yw xY w)zwCheck the passed number and return 'ISBN13', 'ISBN10' or None (for
    invalid) for checking the type of number passed.Fr(   Nr   ÚISBN10ÚISBN13)r0   ÚValidationErrorr   ©r   s    r   Ú	isbn_typer8   q   s;   € ðÜ˜&¨%Ô0ˆô ˆ6ƒ{�bÒØàøô ò Ùðús   ‚ Ÿ	+ª+c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)r'   F)Úboolr0   r6   r7   s    r   Úis_validr;   ~   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                óð   — | j                  «       } t        | d«      }t        |«      dk(  r| S t        |«      dk(  rd| z   } | dd t        j                  d|dd z   «      z   } d| v rd	| z   S d
| v rd| z   S d| z   S )z%Convert the number to ISBN-13 format.r	   r*   r
   r   Nr)   r,   ú z978 ú-z978-)r   r   r   r   Úcalc_check_digit)r   Ú
min_numbers     r   r   r   ˆ   s‘   € à�\‰\‹^€FÜ�v˜tÓ$€JÜ
ˆ:ƒ˜"ÒØˆÜ
ˆ:ƒ˜!ÒØ�v‘ˆà�C�Rˆ[œ3×/Ñ/°¸
À3ÀB¸Ñ0GÓHÑH€Fà
ˆf�}Ø˜‰ÐØ	�‰Ø˜‰Ðà�v‰~Ðr   c                ó`  — | j                  «       } t        | d¬«      }t        |«      dk(  r| S t        |«      dk7  rt	        d«      ‚| j                  d«      st        d«      ‚| dd	 j                  «       j                  d
«      } t        |dd	 «      }d| v r| dz   |z   S d
| v r| d
z   |z   S | |z   S )z%Convert the number to ISBN-10 format.Fr(   r   r5   zNot a valid ISBN13.r,   z!Does not use 978 Bookland prefix.r+   r)   r>   r=   )r   r   r   r8   r.   Ú
startswithr1   r%   )r   r@   Údigits      r   Ú	to_isbn10rD   ›   sÃ   € à�\‰\‹^€FÜ˜¨Ô/€JÜ
ˆ:ƒ˜"ÒØˆÜ	�:Ó	 (Ò	*ÜÐ1Ó2Ð2Ø×Ñ˜uÔ%ÜÐBÓCÐCà�A�bˆ\×ÑÓ!×'Ñ'¨Ó,€FÜ$ Z°°"Ð%5Ó6€Eà
ˆf�}Ø˜‰|˜eÑ#Ð#Ø	�‰Ø˜‰|˜eÑ#Ð#à˜‰~Ðr   c                ó\  — t        | |«      } d}t        | «      dk(  rd| z   } d}ddlm} |j	                  d«      j                  | dd	 «      }|r|j                  «       nd
}|r|j                  d«      nd
}|r|j                  d«      nd
}|r|j                  d«      nd
}|rd
n||||| d	   fS )a  Split the specified ISBN into an EAN.UCC prefix, a group prefix, a
    registrant, an item number and a check digit. If the number is in ISBN-10
    format the returned EAN.UCC prefix is '978'. If the convert parameter is
    True the number is converted to ISBN-13 format first.Fr   r,   Tr   )ÚnumdbÚisbnNr)   Ú )r   r   ÚstdnumrF   ÚgetÚsplitÚpop)	r   r   Ú	delprefixrF   ÚresultÚitemnrÚprefixÚgroupÚ	publishers	            r   rK   rK   ±   s¬   € ô �V˜WÓ%€Fà€IÜ
ˆ6ƒ{�bÒØ˜‘ˆØˆ	åØ�Y‰Y�vÓ×$Ñ$ V¨C¨R [Ó1€FÙ#ˆV�Z‰ZŒ\¨€FÙ$ˆV�Z‰Z˜Œ]¨"€FÙ#ˆF�J‰J�qŒM¨€EÙ!'�—
‘
˜1”¨R€Iá‰B ¨°	¸6À6È"Á:ÐNÐNr   c                óF   — |j                  d„ t        | |«      D «       «      S )aŠ  Reformat the number to the standard presentation format with the
    EAN.UCC prefix (if any), the group prefix, the registrant, the item
    number and the check digit separated (if possible) by the specified
    separator. Passing an empty separator should equal compact() though this
    is less efficient. If the convert parameter is True the number is
    converted to ISBN-13 format first.c              3  ó&   K  — | ]	  }|sŒ|–— Œ y ­w)N© )r   Úxs     r   r   zformat.<locals>.<genexpr>Ï   s   è ø€ ÒA ºqœ!ÑAùs   ‚Š)ÚjoinrK   )r   Ú	separatorr   s      r   ÚformatrY   È   s    € ð �>‰>ÑA¤U¨6°7Ó%;ÔAÓAÐAr   N)F)r   r#   r   r:   Úreturnr#   )r   r#   rZ   r#   )r   r#   rZ   z
str | None)r   r#   rZ   r:   )r   r#   r   r:   rZ   ztuple[str, str, str, str, str])r>   F)r   r#   rX   r#   r   r:   rZ   r#   )Ú__doc__Ú
__future__r   rI   r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r%   r0   r8   r;   r   rD   rK   rY   rU   r   r   ú<module>r_      sH   ðñ(*õX #å Ü ß 'ô
ó.ôó*
óóó&ô,Oõ.Br   