î

_ÝVß  ã            
   @   sa   d  Z  d g Z d d l Z d d l m Z d d l m Z e j d e ƒ d Z d d „  Z	 d S)z
Common checksum routines.
Úluhné    N)Úsix)ÚRemovedInDjango110Warningzvdjango.utils.checksums will be removed in Django 1.10. The luhn() function is now included in django-localflavor 1.1+.é   é   é   é   é   é   é   é   é	   c             C   s    t  |  t j ƒ s! t |  ƒ }  n  yb t d d „  |  d
 d d … Dƒ ƒ } t d d „  |  d d d … Dƒ ƒ } | | d d k SWn t k
 r› d	 SYn Xd S)z½
    Checks a candidate number for validity according to the Luhn
    algorithm (used in validation of, for example, credit cards).
    Both numeric and string candidates are accepted.
    c             s   s   |  ] } t  | ƒ Vq d  S)N)Úint)Ú.0Úc© r   ú8/tmp/pip-build-ghmbqnp_/Django/django/utils/checksums.pyú	<genexpr>   s    zluhn.<locals>.<genexpr>r	   Nr   c             s   s   |  ] } t  t | ƒ Vq d  S)N)ÚLUHN_ODD_LOOKUPr   )r   r   r   r   r   r      s    é
   r   Féÿÿÿÿéþÿÿÿr   r   )Ú
isinstancer   Ústring_typesÚstrÚsumÚ
ValueError)Ú	candidateZevensZoddsr   r   r   r      s    &&)
r   r   r   r   r   r	   r
   r   r   r   )
Ú__doc__Ú__all__ÚwarningsZdjango.utilsr   Zdjango.utils.deprecationr   Úwarnr   r   r   r   r   r   Ú<module>   s   	