PageRenderTime 69ms CodeModel.GetById 65ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/django/contrib/localflavor/uy/util.py

https://code.google.com/p/mango-py/
Python | 12 lines | 7 code | 3 blank | 2 comment | 2 complexity | 18a78c1d70a1f22cc1ebac661b275cdf MD5 | raw file
 1# -*- coding: utf-8 -*-
 2
 3def get_validation_digit(number):
 4    """ Calculates the validation digit for the given number. """
 5    sum = 0
 6    dvs = [4, 3, 6, 7, 8, 9, 2]
 7    number = str(number)
 8
 9    for i in range(0, len(number)):
10        sum = (int(number[-1 - i]) * dvs[i] + sum) % 10
11
12    return (10-sum) % 10