Skip to content

Commit c6a82af

Browse files
FMeinickejcgruenhage
authored andcommitted
Add --digits option
to allow configuring the number of digits in the ASN string. This argument is optional and defaults to 7 to keep backwards compatibility.
1 parent 278046a commit c6a82af

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ positional arguments:
2424
options:
2525
-h, --help show this help message and exit
2626
--format {averyL4731,avery5160,avery5161,avery5163,avery5167,avery5371}, -f {averyL4731,avery5160,avery5161,avery5163,avery5167,avery5371}
27+
--digits DIGITS, -d DIGITS
28+
Number of digits in the ASN (default: 7, produces 'ASN0000001')
2729
--border, -b Display borders around labels, useful for debugging the printer alignment
2830
```
2931

@@ -39,6 +41,7 @@ options:
3941

4042
- `-h`, `--help`: Shows the help message
4143
- `-f`, `--format`: Selects the format of the output sheet (see [Supported Sheets](#supported-sheets))
44+
- `-d`, `--digits`: Specifies the number of digits in the ASN (e.g. for the default number 7, the ASN will look like 'ASN0000001')
4245
- `-b`, `--border`: Generates the borders around the labels to help debug alignment issues (see [Tips & Tricks](#tips--tricks))
4346

4447
## Supported Sheets

paperless_asn_qr_codes/main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
def render(c, x, y):
1010
global startASN
11-
barcode_value = f"ASN{startASN:07d}"
11+
global digits
12+
barcode_value = f"ASN{startASN:0{digits}d}"
1213
startASN = startASN + 1
1314

1415
qr = QRCodeImage(barcode_value, size=y * 0.9)
@@ -27,6 +28,9 @@ def main():
2728
parser.add_argument(
2829
"--format", "-f", choices=avery_labels.labelInfo.keys(), default="averyL4731"
2930
)
31+
parser.add_argument(
32+
"--digits", "-d", default=7, help="Number of digits in the ASN (default: 7, produces 'ASN0000001')", type=int
33+
)
3034
parser.add_argument(
3135
"--border",
3236
"-b",
@@ -35,7 +39,9 @@ def main():
3539
)
3640
args = parser.parse_args()
3741
global startASN
42+
global digits
3843
startASN = int(args.start_asn)
44+
digits = int(args.digits)
3945
label = avery_labels.AveryLabel(args.format, args.border)
4046
label.open(args.output_file)
4147
# by default, we render all labels possible on a single sheet

0 commit comments

Comments
 (0)