-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblocks.py
More file actions
88 lines (60 loc) · 2.21 KB
/
Copy pathblocks.py
File metadata and controls
88 lines (60 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"""Block primitives. Receipt composers return lists of these; `printer.py` renders them."""
from dataclasses import dataclass
# ── List rows ────────────────────────────────────────────────────────────────
@dataclass
class Item:
"""Receipt row: name left, value right. `bold=True` for the column header.
`name` and `value` are coerced to str, so a provider can return a number
(e.g. Item("CPU TEMP", 47)) without breaking the receipt.
"""
name: str
value: str
bold: bool = False
def __post_init__(self):
self.name = str(self.name)
self.value = str(self.value)
@dataclass
class Checkbox:
"""Checklist item: '[ ] text' with hanging indent on wrap."""
text: str
# ── Receipt accents ──────────────────────────────────────────────────────────
@dataclass
class Banner:
"""Black bar with white text, snug-fit around the text."""
text: str
@dataclass
class Total:
"""Right-aligned 'LABEL: value'. `big=True` for the final TOTAL line."""
label: str
value: str
big: bool = False
@dataclass
class Underline:
"""Centered text with thin lines hugging it top and bottom."""
text: str
@dataclass
class Footer:
"""Final centered bold footer line."""
text: str
@dataclass
class UpsideDown:
"""Text rasterized and rotated 180° — 'secret message from below'."""
text: str
@dataclass
class Barcode:
"""Code128 barcode encoding `text`, centered."""
text: str
# ── Structural ───────────────────────────────────────────────────────────────
@dataclass
class Divider:
"""Horizontal divider: 'dash', 'dot', or 'solid'."""
style: str = "dash"
@dataclass
class Spacer:
"""Vertical gap in body-line heights."""
lines: int = 1
Block = (
Item | Checkbox |
Banner | Total | Underline | Footer | UpsideDown | Barcode |
Divider | Spacer
)