(self)
| 42 | return self.code |
| 43 | |
| 44 | def build(self) -> list[str]: |
| 45 | try: |
| 46 | data = ( |
| 47 | codabar.STARTSTOP[self.code[0]] + "n" |
| 48 | ) # Start with [A-D], followed by a narrow space |
| 49 | |
| 50 | except KeyError: |
| 51 | raise BarcodeError("Codabar should start with either A,B,C or D") from None |
| 52 | |
| 53 | try: |
| 54 | data += "n".join( |
| 55 | [codabar.CODES[c] for c in self.code[1:-1]] |
| 56 | ) # separated by a narrow space |
| 57 | except KeyError: |
| 58 | raise IllegalCharacterError( |
| 59 | "Codabar can only contain numerics or $:/.+-" |
| 60 | ) from None |
| 61 | |
| 62 | try: |
| 63 | data += "n" + codabar.STARTSTOP[self.code[-1]] # End with [A-D] |
| 64 | except KeyError: |
| 65 | raise BarcodeError("Codabar should end with either A,B,C or D") from None |
| 66 | |
| 67 | raw = "" |
| 68 | for e in data: |
| 69 | if e == "W": |
| 70 | raw += "1" * self.wide |
| 71 | if e == "w": |
| 72 | raw += "0" * self.wide |
| 73 | if e == "N": |
| 74 | raw += "1" * self.narrow |
| 75 | if e == "n": |
| 76 | raw += "0" * self.narrow |
| 77 | return [raw] |
nothing calls this directly
no test coverage detected