Debian Codegraph @

brother_ql/devicedependent.py

raw ◀ ▶
1 Debian patch touch this file
1 """
2 Deprecated Module brother_ql.devicedependent
3
4 This module held constants and settings that were specific to
5 different QL-series printer models and to different label types.
6
7 The content is now split into two modules:
8
9 * brother_ql.models
10 * brother_ql.labels
11
12 Please import directly from them as this module will be removed in a future version.
13 """
14
15 import logging
16
17 logger = logging.getLogger(__name__)
18
•19 # logger.warn("deprecation warning: brother_ql.devicedependent is deprecated and will be removed in a future release")
20
21 ## These module level variables were available here before.
22 # Concerning labels
23 DIE_CUT_LABEL = None
24 ENDLESS_LABEL = None
25 ROUND_DIE_CUT_LABEL = None
26 label_type_specs = {}
27 label_sizes = []
28 # And concerning printer models
29 models = []
30 min_max_length_dots = {}
31 min_max_feed = {}
32 number_bytes_per_row = {}
33 right_margin_addition = {}
34 modesetting = []
35 cuttingsupport = []
36 expandedmode = []
37 compressionsupport = []
38 two_color_support = []
39
40 ## Let's recreate them using the improved data structures
41 ## in brother_ql.models and brother_ql.labels
42
43 def _populate_model_legacy_structures():
44 from brother_ql.models import ModelsManager
45 global models
46 global min_max_length_dots, min_max_feed, number_bytes_per_row, right_margin_addition
47 global modesetting, cuttingsupport, expandedmode, compressionsupport, two_color_support
48
49 for model in ModelsManager().iter_elements():
50 models.append(model.identifier)
51 min_max_length_dots[model.identifier] = model.min_max_length_dots
52 min_max_feed[model.identifier] = model.min_max_feed
53 number_bytes_per_row[model.identifier] = model.number_bytes_per_row
54 right_margin_addition[model.identifier] = model.additional_offset_r
55 if model.mode_setting: modesetting.append(model.identifier)
56 if model.cutting: cuttingsupport.append(model.identifier)
57 if model.expanded_mode: expandedmode.append(model.identifier)
58 if model.compression: compressionsupport.append(model.identifier)
59 if model.two_color: two_color_support.append(model.identifier)
60
61 def _populate_label_legacy_structures():
62 """
63 We contain this code inside a function so that the imports
64 we do in here are not visible at the module level.
65 """
66 global DIE_CUT_LABEL, ENDLESS_LABEL, ROUND_DIE_CUT_LABEL
67 global label_sizes, label_type_specs
68
69 from brother_ql.labels import FormFactor
70 DIE_CUT_LABEL = FormFactor.DIE_CUT
71 ENDLESS_LABEL = FormFactor.ENDLESS
72 ROUND_DIE_CUT_LABEL = FormFactor.ROUND_DIE_CUT
73
74 from brother_ql.labels import LabelsManager
75 lm = LabelsManager()
76 label_sizes = list(lm.iter_identifiers())
77 for label in lm.iter_elements():
78 l = {}
79 l['name'] = label.name
80 l['kind'] = label.form_factor
81 l['color'] = label.color
82 l['tape_size'] = label.tape_size
83 l['dots_total'] = label.dots_total
84 l['dots_printable'] = label.dots_printable
85 l['right_margin_dots'] = label.offset_r
86 l['feed_margin'] = label.feed_margin
87 l['restrict_printers'] = label.restricted_to_models
88 label_type_specs[label.identifier] = l
89
90 def _populate_all_legacy_structures():
91 _populate_label_legacy_structures()
92 _populate_model_legacy_structures()
93
94 _populate_all_legacy_structures()