| 1 |
import logging |
| 2 |
|
| 3 |
from brother_ql.devicedependent import label_type_specs |
| 4 |
from brother_ql.devicedependent import DIE_CUT_LABEL, ENDLESS_LABEL, ROUND_DIE_CUT_LABEL |
| 5 |
|
| 6 |
logger = logging.getLogger(__name__) |
| 7 |
|
| 8 |
def textual_label_description(labels_to_include): |
| 9 |
output = "Supported label sizes:\n" |
| 10 |
output = "" |
| 11 |
fmt = " {label_size:9s} {dots_printable:14s} {label_descr:26s}\n" |
| 12 |
output += fmt.format(label_size="Name", dots_printable="Printable px", label_descr="Description") |
| 13 |
#output += fmt.format(label_size="", dots_printable="width x height", label_descr="") |
| 14 |
for label_size in labels_to_include: |
| 15 |
s = label_type_specs[label_size] |
| 16 |
if s['kind'] in (DIE_CUT_LABEL, ROUND_DIE_CUT_LABEL): |
| 17 |
dp_fmt = "{0:4d} x {1:4d}" |
| 18 |
elif s['kind'] == ENDLESS_LABEL: |
| 19 |
dp_fmt = "{0:4d}" |
| 20 |
else: |
| 21 |
dp_fmt = " - unknown - " |
| 22 |
dots_printable = dp_fmt.format(*s['dots_printable']) |
| 23 |
label_descr = s['name'] |
| 24 |
output += fmt.format(label_size=label_size, dots_printable=dots_printable, label_descr=label_descr) |
| 25 |
return output |
| 26 |
|
| 27 |
def log_discovered_devices(available_devices, level=logging.INFO): |
| 28 |
for ad in available_devices: |
| 29 |
result = {'model': 'unknown'} |
| 30 |
result.update(ad) |
| 31 |
logger.log(level, " Found a label printer: {identifier} (model: {model})".format(**result)) |
| 32 |
|
| 33 |
def textual_description_discovered_devices(available_devices): |
| 34 |
output = "" |
| 35 |
for ad in available_devices: |
| 36 |
output += ad['identifier'] |
| 37 |
return output |