@@ -82,40 +82,28 @@ def render(self, code: List[str]) -> Image.Image:
82
82
draw = ImageDraw .Draw (image )
83
83
84
84
ypos = vertical_margin
85
- for cc , line in enumerate (code ):
86
- mlist = _list_of_runs (line )
87
- # Left quiet zone is x startposition
88
- xpos = quiet_zone
89
- for mod in mlist :
90
- if mod < 1 :
91
- color = background
92
- else :
93
- color = foreground
94
- # remove painting for background colored tiles?
95
- _paint_module (
96
- xpos = xpos ,
97
- ypos = ypos ,
98
- width = module_width * abs (mod ),
99
- color = color ,
100
- dpi = dpi ,
101
- module_height = module_height ,
102
- draw = draw ,
103
- )
104
- xpos += module_width * abs (mod )
105
- # Add right quiet zone to every line, except last line,
106
- # quiet zone already provided with background,
107
- # should it be removed complety?
108
- if (cc + 1 ) != len (code ):
109
- _paint_module (
110
- xpos = xpos ,
111
- ypos = ypos ,
112
- width = quiet_zone ,
113
- color = background ,
114
- dpi = dpi ,
115
- module_height = module_height ,
116
- draw = draw ,
117
- )
118
- ypos += module_height
85
+ if len (code ) != 1 :
86
+ raise ValueError ("Barcode expected to have only one line" )
87
+ line = code [0 ]
88
+ mlist = _list_of_runs (line )
89
+ # Left quiet zone is x startposition
90
+ xpos = quiet_zone
91
+ for mod in mlist :
92
+ if mod < 1 :
93
+ color = background
94
+ else :
95
+ color = foreground
96
+ # remove painting for background colored tiles?
97
+ _paint_module (
98
+ xpos = xpos ,
99
+ ypos = ypos ,
100
+ width = module_width * abs (mod ),
101
+ color = color ,
102
+ dpi = dpi ,
103
+ module_height = module_height ,
104
+ draw = draw ,
105
+ )
106
+ xpos += module_width * abs (mod )
119
107
return _finish (image )
120
108
121
109
0 commit comments