Update of /cvsroot/pythonreports/PythonReports/PythonReports
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14324
Modified Files:
barcode.py
Log Message:
sweep pylint warnings
Index: barcode.py
===================================================================
RCS file: /cvsroot/pythonreports/PythonReports/PythonReports/barcode.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** barcode.py 7 Nov 2006 13:16:42 -0000 1.2
--- barcode.py 6 Dec 2006 15:49:57 -0000 1.3
***************
*** 1,4 ****
--- 1,5 ----
"""BarCode routines"""
"""History:
+ 05-dec-2006 [als] sweep pylint warnings
07-nov-2006 [als] fix doctests (no quet zones encoded)
22-sep-2006 [als] encoding calls return sequences w/o quiet zones;
***************
*** 6,10 ****
12-sep-2006 [als] created
"""
-
__version__ = "$Revision$"[11:-2]
__date__ = "$Date$"[7:-2]
--- 7,10 ----
***************
*** 21,24 ****
--- 21,26 ----
class InvalidLiteral(ValueError):
+ """Error raised when a character cannot be encoded"""
+
def __init__(self, text, barcode):
ValueError.__init__(self, text, barcode)
***************
*** 200,203 ****
--- 202,206 ----
"""
+ super(Code2of5i, self).__init__()
if w2n is None:
self.w2n = self.W2N
***************
*** 222,232 ****
def __call__(self, text, errors="stict"):
# ensure that the text contains only digits
! text = self._clean(text, errors)
# pad with zero if necessary
! if len(text) & 1:
! text = "0" + text
# encode text
_seq = []
! for _pair in zip(text[::2], text[1::2]):
_seq.extend(itertools.chain(
*zip(*[self.PATTERNS[int(_digit)] for _digit in _pair])))
--- 225,235 ----
def __call__(self, text, errors="stict"):
# ensure that the text contains only digits
! _text = self._clean(text, errors)
# pad with zero if necessary
! if len(_text) & 1:
! _text = "0" + _text
# encode text
_seq = []
! for _pair in zip(_text[::2], _text[1::2]):
_seq.extend(itertools.chain(
*zip(*[self.PATTERNS[int(_digit)] for _digit in _pair])))
***************
*** 238,245 ****
def check_digit(self, text, errors="strict"):
! text = self._clean(text, errors)
! _odd = (len(text) & 1)
! _sum = sum([(int(_digit) * 3) for _digit in text[1-_odd::2]]) \
! + sum([int(_digit) for _digit in text[_odd::2]])
return str(10 -(_sum %10))[-1]
--- 241,249 ----
def check_digit(self, text, errors="strict"):
! """Return the check character for given code text"""
! _text = self._clean(text, errors)
! _odd = (len(_text) & 1)
! _sum = sum([(int(_digit) * 3) for _digit in _text[1-_odd::2]]) \
! + sum([int(_digit) for _digit in _text[_odd::2]])
return str(10 -(_sum %10))[-1]
***************
*** 278,282 ****
"""
! CHARS ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"
# default wide-to-narrow multiple
--- 282,286 ----
"""
! CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"
# default wide-to-narrow multiple
***************
*** 353,356 ****
--- 357,361 ----
"""
+ super(Code39, self).__init__()
if w2n is None:
self.w2n = self.W2N
***************
*** 392,395 ****
--- 397,401 ----
def check_digit(self, text, errors="strict"):
+ """Return the check character for given code text"""
_sum = sum(self._encode_chars(text, errors))
return self.CHARS[_sum % 43]
***************
*** 448,451 ****
--- 454,461 ----
# 4. Code C, switch to Code A
+ # pylint: disable-msg=W0223
+ # W0223: Method 'check_digit' is abstract in class 'BarCode'
+ # but is not overridden - that's intentional (see docstring)
+
CHARS_A =" !\"#$%&\'()*+,-./0123456789:;<=>?@" \
"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" \
***************
*** 455,459 ****
CHARS_B =" !\"#$%&\'()*+,-./0123456789:;<=>?@" \
"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" \
! "`abcdefghijklmnopqrstuvwxyz{|}~\177";
CHARS_C ="0123456789" # not used
--- 465,469 ----
CHARS_B =" !\"#$%&\'()*+,-./0123456789:;<=>?@" \
"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" \
! "`abcdefghijklmnopqrstuvwxyz{|}~\177"
CHARS_C ="0123456789" # not used
***************
*** 516,520 ****
return text
! def _encode_ab(self, text, chars):
"""Encode text with character set A or B"""
_rv = []
--- 526,531 ----
return text
! @staticmethod
! def _encode_ab(text, chars):
"""Encode text with character set A or B"""
_rv = []
***************
*** 597,600 ****
--- 608,612 ----
def _test():
+ """Run doctests"""
import doctest
# textwrap is used in tests to wrap output
|