From: Alvin Penner Date: Sun, 20 Dec 2009 22:09:40 +0000 (-0500) Subject: patch by mbeach for UPC-A checksum X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=10cc8184256af6c4ffb3c4829157667859346239;p=inkscape.git patch by mbeach for UPC-A checksum --- 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)