MCPcopy Index your code
hub / github.com/WhyNotHugo/python-barcode / _convert

Method _convert

barcode/codex.py:225–242  ·  view source on GitHub ↗
(self, char: str)

Source from the content-addressed store, hash-verified

223 return codes
224
225 def _convert(self, char: str):
226 if self._charset == "A":
227 return code128.A[char]
228 if self._charset == "B":
229 return code128.B[char]
230 if self._charset == "C":
231 if char in code128.C:
232 return code128.C[char]
233 if char.isdigit():
234 self._buffer += char
235 if len(self._buffer) == 2:
236 value = int(self._buffer)
237 self._buffer = ""
238 return value
239 return None
240 raise RuntimeError(
241 f"Character {char} could not be converted in charset {self._charset}."
242 )
243
244 def _try_to_optimize(self, encoded: list[int]) -> list[int]:
245 if encoded[1] in code128.TO:

Callers 3

_new_charsetMethod · 0.95
_maybe_switch_charsetMethod · 0.95
_buildMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected