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

Method _init

barcode/writer.py:445–454  ·  view source on GitHub ↗
(self, code: list[str])

Source from the content-addressed store, hash-verified

443 self._draw: T_ImageDraw
444
445 def _init(self, code: list[str]) -> None:
446 if ImageDraw is None:
447 raise RuntimeError("Pillow not found. Cannot create image.")
448 if len(code) != 1:
449 raise NotImplementedError("Only one line of code is supported")
450 line = code[0]
451 width, height = self.calculate_size(len(line), 1)
452 size = (int(mm2px(width, self.dpi)), int(mm2px(height, self.dpi)))
453 self._image = Image.new(self.mode, size, self.background)
454 self._draw = ImageDraw.Draw(self._image)
455
456 def _paint_module(self, xpos: float, ypos: float, width: float, color):
457 size = [

Callers

nothing calls this directly

Calls 2

mm2pxFunction · 0.85
calculate_sizeMethod · 0.80

Tested by

no test coverage detected