File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77__docformat__ = "restructuredtext en"
88
9- from functools import reduce
109
1110from barcode .base import Barcode
1211from barcode .charsets import ean as _ean
@@ -83,13 +82,10 @@ def calculate_checksum(self) -> int:
8382 :returns: The checksum for ``self.ean``.
8483 """
8584
86- def sum_ (x , y ):
87- return int (x ) + int (y )
88-
8985 ean_without_checksum = self .ean [: self .digits ]
9086
91- evensum = reduce ( sum_ , ean_without_checksum [- 2 ::- 2 ])
92- oddsum = reduce ( sum_ , ean_without_checksum [- 1 ::- 2 ])
87+ evensum = sum ( int ( x ) for x in ean_without_checksum [- 2 ::- 2 ])
88+ oddsum = sum ( int ( x ) for x in ean_without_checksum [- 1 ::- 2 ])
9389 return (10 - ((evensum + oddsum * 3 ) % 10 )) % 10
9490
9591 def build (self ):
@@ -216,13 +212,10 @@ def calculate_checksum(self) -> int:
216212 :returns: The checksum for ``self.ean``.
217213 """
218214
219- def sum_ (x , y ):
220- return int (x ) + int (y )
221-
222215 ean_without_checksum = self .ean [: self .digits ]
223216
224- evensum = reduce ( sum_ , ean_without_checksum [::2 ])
225- oddsum = reduce ( sum_ , ean_without_checksum [1 ::2 ])
217+ evensum = sum ( int ( x ) for x in ean_without_checksum [::2 ])
218+ oddsum = sum ( int ( x ) for x in ean_without_checksum [1 ::2 ])
226219 return (10 - (((evensum * 3 ) + oddsum ) % 10 )) % 10
227220
228221
You can’t perform that action at this time.
0 commit comments