From 10cc8184256af6c4ffb3c4829157667859346239 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sun, 20 Dec 2009 17:09:40 -0500 Subject: [PATCH] patch by mbeach for UPC-A checksum --- share/extensions/Barcode/EAN13.py | 10 +++++----- share/extensions/Barcode/UPCA.py | 4 ++-- share/extensions/Barcode/UPCE.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/share/extensions/Barcode/EAN13.py b/share/extensions/Barcode/EAN13.py index 3450893fc..c79b7749d 100644 --- a/share/extensions/Barcode/EAN13.py +++ b/share/extensions/Barcode/EAN13.py @@ -42,8 +42,8 @@ class Object(Barcode): if len(number) == 12: number = number + self.getChecksum(number) else: - if not self.varifyChecksum(number): - sys.stderr.write("EAN13 Checksum not correct for this barcode, omit last charicter to generate new checksum.\n") + if not self.verifyChecksum(number): + sys.stderr.write("EAN13 Checksum not correct for this barcode, omit last character to generate new checksum.\n") return result = result + guardBar @@ -83,9 +83,9 @@ class Object(Barcode): return str(z) - def varifyChecksum(self, number): - new = self.getChecksum(number[:12]) - existing = number[12] + def verifyChecksum(self, number): + new = self.getChecksum(number[:-1]) + existing = number[-1] return new == existing def getStyle(self, index): diff --git a/share/extensions/Barcode/UPCA.py b/share/extensions/Barcode/UPCA.py index b67d0830b..89c97eed6 100644 --- a/share/extensions/Barcode/UPCA.py +++ b/share/extensions/Barcode/UPCA.py @@ -33,8 +33,8 @@ class Object(EAN13.Object): if len(number) == 11: number = number + self.getChecksum(number) else: - if not self.varifyChecksum(number): - sys.stderr.write("EAN13 Checksum not correct for this barcode, omit last charicter to generate new checksum.\n") + if not self.verifyChecksum(number): + sys.stderr.write("UPC-A Checksum not correct for this barcode, omit last character to generate new checksum.\n") return result = result + guardBar diff --git a/share/extensions/Barcode/UPCE.py b/share/extensions/Barcode/UPCE.py index 0ad518680..b41e94e8c 100644 --- a/share/extensions/Barcode/UPCE.py +++ b/share/extensions/Barcode/UPCE.py @@ -47,8 +47,8 @@ class Object(EAN13.Object): if not echeck: echeck = self.getChecksum(number) else: - if not self.varifyChecksum(number + echeck): - sys.stderr.write("UPC-E Checksum not correct for this barcode, omit last charicter to generate new checksum.\n") + if not self.verifyChecksum(number + echeck): + sys.stderr.write("UPC-E Checksum not correct for this barcode, omit last character to generate new checksum.\n") return number = self.ConvertAtoE(number) -- 2.30.2