Ë
    Ã?Æ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
)uZ  CUPS (CÃ³digo Unificado de Punto de Suministro, Spanish meter point number).

CUPS codes are used in Spain as unique identifier for energy supply points.
They are used both for electricity and pipelined gas.

The format is set by the Energy Ministry, and individual codes are issued by
each local distribution company. The number consist or 20 or 22 digits and is
built up as follows:

* LL: (letters) country (always 'ES' since it is a national code)
* DDDD: (numbers) distribution company code (numeric)
* CCCC CCCC CCCC: identifier within the distribution company (numeric)
* EE: (letters) check digits
* N: (number) border point sequence
* T: (letter) kind of border point

More information:

* https://es.wikipedia.org/wiki/CÃ³digo_Unificado_de_Punto_de_Suministro

>>> validate('ES 1234-123456789012-JY')
'ES1234123456789012JY'
>>> validate('ES 1234-123456789012-JY 1T')
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> validate('ES 1234-123456789012-XY 1F')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> format('ES1234123456789012JY1F')
'ES 1234 1234 5678 9012 JY 1F'
é    )Ú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    úU/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/es/cups.pyÚcompactr   >   s#   € ô �˜Ó×$Ñ$Ó&×,Ñ,Ó.Ð.ó    c                óŽ   — t        | «      } dj                  | dd | dd | dd | dd | dd | dd | dd f«      j                  «       S )	z8Reformat the number to the standard presentation format.ú Né   é   é
   é   é   é   )r   Újoinr   r
   s    r   Úformatr   D   si   € ä�V‹_€FØ�8‰8Øˆr�ˆ
Øˆq�ˆØˆq�ˆØˆr�"ˆØˆr�"ˆØˆr�"ˆØˆrˆsˆðó ÷ �uƒwðr   c                óX   — d}t        t        | dd «      dz  d«      \  }}||   ||   z   S )z*Calculate the check digits for the number.ÚTRWAGMYFPDXBNJZSQVHLCKEr   r   i  é   )ÚdivmodÚint)r   ÚalphabetÚcheck0Úcheck1s       r   Úcalc_check_digitsr!   R   s<   € à(€HÜœC  q¨ Ó-°Ñ3°RÓ8�N€FˆFØ�FÑ˜h vÑ.Ñ.Ð.r   c                óJ  — t        | «      } t        | «      dvr
t        «       ‚| dd dk7  r
t        «       ‚t	        | dd «      s
t        «       ‚t        | «      dk(  r-| d   | d   }}t	        |«      s
t        «       ‚|d	vr
t        «       ‚t        | «      | dd k7  r
t        «       ‚| S )
zbCheck if the number provided is a valid CUPS. This checks length,
    formatting and check digits.)r   é   Nr   ÚESr   r#   r   é   ÚFPRCXYZ)r   ÚlenÚInvalidLengthÚInvalidComponentr   ÚInvalidFormatr!   ÚInvalidChecksum)r   ÚpnumberÚptypes      r   Úvalidater.   Y   s¬   € ô �V‹_€FÜ
ˆ6ƒ{˜(Ñ"Ü‹oÐØˆbˆq€z�TÒÜÓ Ð Ü�F˜1˜R�LÔ!Ü‹oÐÜ
ˆ6ƒ{�bÒØ ™ V¨B¡Z�ˆÜ˜Ô Ü“/Ð!Ø˜	Ñ!Ü“/Ð!Ü˜Ó  F¨2¨b MÒ1ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z-Check if the number provided is a valid CUPS.F)Úboolr.   ÚValidationErrorr
   s    r   Úis_validr2   n   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"N)r   ÚstrÚreturnr3   )r   r3   r4   r0   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r   r!   r.   r2   © r   r   ú<module>r:      s/   ðñ, õD #ä ß 'ó/óó/óô*r   