lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.13-17-gf7b968c

[Date Prev][Date Next] [Thread Prev][Thread Next]

python-stdnum branch master updated. 1.13-17-gf7b968c



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".

The branch, master has been updated
       via  f7b968c986ad6163f92e1c72da20050f961f8954 (commit)
       via  d09ed521f68c60c7a28948c5fcbf9faa4fcc073e (commit)
      from  60139a8f862f8a40bed2ed746c4402366f238aff (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=f7b968c986ad6163f92e1c72da20050f961f8954

commit f7b968c986ad6163f92e1c72da20050f961f8954
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Mon Mar 9 21:05:59 2020 +0100

    Fix typo
    
    Thanks @unho

diff --git a/stdnum/by/unp.py b/stdnum/by/unp.py
index f7f144a..14b7a0e 100644
--- a/stdnum/by/unp.py
+++ b/stdnum/by/unp.py
@@ -18,7 +18,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301 USA
 
-"""УНП, UNP (Учетный номер плательщика, the Bellarus VAT number).
+"""УНП, UNP (Учетный номер плательщика, the Belarus VAT number).
 
 The УНП (UNP) or Учетный номер плательщика (Uchetniy nomer platel'shika,
 Payer account number) is issued to organisations and individuals for tax

https://arthurdejong.org/git/python-stdnum/commit/?id=d09ed521f68c60c7a28948c5fcbf9faa4fcc073e

commit d09ed521f68c60c7a28948c5fcbf9faa4fcc073e
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Sun Mar 8 18:40:25 2020 +0100

    Use zip() for applying weights in check algorithms

diff --git a/stdnum/lv/pvn.py b/stdnum/lv/pvn.py
index 03db0f4..006b5c0 100644
--- a/stdnum/lv/pvn.py
+++ b/stdnum/lv/pvn.py
@@ -70,7 +70,7 @@ def calc_check_digit_pers(number):
     should not have the check digit included."""
     # note that this algorithm has not been confirmed by an independent source
     weights = (10, 5, 8, 4, 2, 1, 6, 3, 7, 9)
-    check = 1 + sum(weights[i] * int(n) for i, n in enumerate(number))
+    check = 1 + sum(w * int(n) for w, n in zip(weights, number))
     return str(check % 11 % 10)
 
 
diff --git a/stdnum/ru/inn.py b/stdnum/ru/inn.py
index db30806..58cc216 100644
--- a/stdnum/ru/inn.py
+++ b/stdnum/ru/inn.py
@@ -51,18 +51,15 @@ def compact(number):
 def calc_company_check_digit(number):
     """Calculate the check digit for the 10-digit ИНН for organisations."""
     weights = (2, 4, 10, 3, 5, 9, 4, 6, 8)
-    return str(sum(weights[i] * int(n)
-                   for i, n in enumerate(number[:9])) % 11 % 10)
+    return str(sum(w * int(n) for w, n in zip(weights, number)) % 11 % 10)
 
 
 def calc_personal_check_digits(number):
     """Calculate the check digits for the 12-digit personal ИНН."""
     weights = (7, 2, 4, 10, 3, 5, 9, 4, 6, 8)
-    d1 = str(sum(weights[i] * int(n)
-                 for i, n in enumerate(number[:10])) % 11 % 10)
+    d1 = str(sum(w * int(n) for w, n in zip(weights, number)) % 11 % 10)
     weights = (3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8)
-    d2 = str(sum(weights[i] * int(n)
-                 for i, n in enumerate(number[:10] + d1)) % 11 % 10)
+    d2 = str(sum(w * int(n) for w, n in zip(weights, number[:10] + d1)) % 11 % 
10)
     return d1 + d2
 
 

-----------------------------------------------------------------------

Summary of changes:
 stdnum/by/unp.py | 2 +-
 stdnum/lv/pvn.py | 2 +-
 stdnum/ru/inn.py | 9 +++------
 3 files changed, 5 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
python-stdnum