MCPcopy Create free account
hub / github.com/WhyNotHugo/python-barcode / __init__

Method __init__

barcode/codex.py:47–59  ·  view source on GitHub ↗

r""" :param code: Code 39 string without \* and without checksum. :param writer: A ``barcode.writer`` instance used to render the barcode (default: SVGWriter). :param add_checksum: Add the checksum to code or not

(self, code: str, writer=None, add_checksum: bool = True)

Source from the content-addressed store, hash-verified

45 name = "Code 39"
46
47 def __init__(self, code: str, writer=None, add_checksum: bool = True) -> None:
48 r"""
49 :param code: Code 39 string without \* and without checksum.
50 :param writer: A ``barcode.writer`` instance used to render the barcode
51 (default: SVGWriter).
52 :param add_checksum: Add the checksum to code or not
53 """
54
55 self.code = code.upper()
56 if add_checksum:
57 self.code += self.calculate_checksum()
58 self.writer = writer or self.default_writer()
59 check_code(self.code, self.name, code39.REF)
60
61 def __str__(self) -> str:
62 return self.code

Callers

nothing calls this directly

Calls 2

calculate_checksumMethod · 0.95
check_codeFunction · 0.85

Tested by

no test coverage detected