~ubuntu-branches/ubuntu/saucy/python-django/saucy-updates

« back to all changes in this revision

Viewing changes to django/utils/checksums.py

  • Committer: Package Import Robot
  • Author(s): Luke Faraone, Jakub Wilk, Luke Faraone
  • Date: 2013-05-09 15:10:47 UTC
  • mfrom: (1.1.21) (4.4.27 sid)
  • Revision ID: package-import@ubuntu.com-20130509151047-aqv8d71oj9wvcv8c
Tags: 1.5.1-2
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Luke Faraone ]
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
__all__ = ['luhn',]
6
6
 
 
7
from django.utils import six
 
8
 
7
9
LUHN_ODD_LOOKUP = (0, 2, 4, 6, 8, 1, 3, 5, 7, 9) # sum_of_digits(index * 2)
8
10
 
9
11
def luhn(candidate):
12
14
    algorithm (used in validation of, for example, credit cards).
13
15
    Both numeric and string candidates are accepted.
14
16
    """
15
 
    if not isinstance(candidate, basestring):
 
17
    if not isinstance(candidate, six.string_types):
16
18
        candidate = str(candidate)
17
19
    try:
18
20
        evens = sum([int(c) for c in candidate[-1::-2]])