lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.11-10-g8292779

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

python-stdnum branch master updated. 1.11-10-g8292779



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  82927799f0b9cc828eda671289dc7d760f2a6264 (commit)
      from  4ac84c50b240a1c9a41f04761c49547a07ebe856 (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=82927799f0b9cc828eda671289dc7d760f2a6264

commit 82927799f0b9cc828eda671289dc7d760f2a6264
Author: Sergi Almacellas Abellana <sergi@koolpi.com>
Date:   Thu May 23 11:38:36 2019 +0200

    Add GTIN (EAN-14) validation

diff --git a/stdnum/ean.py b/stdnum/ean.py
index 306474c..f7e4b63 100644
--- a/stdnum/ean.py
+++ b/stdnum/ean.py
@@ -20,12 +20,14 @@
 """EAN (International Article Number).
 
 Module for handling EAN (International Article Number) codes. This
-module handles numbers EAN-13, EAN-8 and UPC (12-digit) format.
+module handles numbers EAN-13, EAN-8, UPC (12-digit) and GTIN (EAN-14) format.
 
 >>> validate('73513537')
 '73513537'
 >>> validate('978-0-471-11709-4') # EAN-13 format
 '9780471117094'
+>>> validate('98412345678908') # GTIN format
+'98412345678908'
 """
 
 from stdnum.exceptions import *
@@ -52,7 +54,7 @@ def validate(number):
     number = compact(number)
     if not isdigits(number):
         raise InvalidFormat()
-    if len(number) not in (13, 12, 8):
+    if len(number) not in (14, 13, 12, 8):
         raise InvalidLength()
     if calc_check_digit(number[:-1]) != number[-1]:
         raise InvalidChecksum()

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

Summary of changes:
 stdnum/ean.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
python-stdnum