(args, parser)
| 26 | |
| 27 | |
| 28 | def create_barcode(args, parser) -> None: |
| 29 | args.type = args.type.upper() |
| 30 | if args.type != "SVG" and args.type not in IMG_FORMATS: |
| 31 | parser.error(f"Unknown type {args.type}. Try list action for available types.") |
| 32 | args.barcode = args.barcode.lower() |
| 33 | if args.barcode not in barcode.PROVIDED_BARCODES: |
| 34 | parser.error( |
| 35 | f"Unknown barcode {args.barcode}. Try list action for available barcodes." |
| 36 | ) |
| 37 | if args.type != "SVG": |
| 38 | assert ImageWriter is not None |
| 39 | opts = {"format": args.type} |
| 40 | writer: BaseWriter = ImageWriter() |
| 41 | else: |
| 42 | opts = {"compress": args.compress} |
| 43 | writer = SVGWriter() |
| 44 | out = os.path.normpath(os.path.abspath(args.output)) |
| 45 | name = barcode.generate(args.barcode, args.code, writer, out, opts, args.text) |
| 46 | print(f"New barcode saved as {name}.") |
| 47 | |
| 48 | |
| 49 | def main() -> None: |
nothing calls this directly
no test coverage detected