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

Method __init__

barcode/codex.py:103–113  ·  view source on GitHub ↗
(self, pzn, writer=None)

Source from the content-addressed store, hash-verified

101 digits = 6
102
103 def __init__(self, pzn, writer=None) -> None:
104 pzn = pzn[: self.digits]
105 if not pzn.isdigit():
106 raise IllegalCharacterError("PZN can only contain numbers.")
107 if len(pzn) != self.digits:
108 raise NumberOfDigitsError(
109 f"PZN must have {self.digits} digits, not {len(pzn)}."
110 )
111 self.pzn = pzn
112 self.pzn = f"{pzn}{self.calculate_checksum()}"
113 super().__init__(f"PZN-{self.pzn}", writer, add_checksum=False)
114
115 def get_fullcode(self):
116 return f"PZN-{self.pzn}"

Callers 1

__init__Method · 0.45

Calls 3

calculate_checksumMethod · 0.95
NumberOfDigitsErrorClass · 0.90

Tested by

no test coverage detected