1
0
mirror of https://github.com/python-escpos/python-escpos synced 2025-09-13 09:09:58 +00:00

improve platform independence (#296)

* add os.devnull for platform independence

fixes #288

* add test for soft_barcode

* open devnull as binary

* add version identifier to pickle
This commit is contained in:
Patrick Kanzler
2018-05-15 01:03:07 +02:00
committed by GitHub
parent 6fb23d6826
commit 6c94f88c24
3 changed files with 26 additions and 6 deletions

View File

@@ -24,6 +24,8 @@ from re import match as re_match
import barcode
from barcode.writer import ImageWriter
import os
from .constants import ESC, GS, NUL, QR_ECLEVEL_L, QR_ECLEVEL_M, QR_ECLEVEL_H, QR_ECLEVEL_Q
from .constants import QR_MODEL_1, QR_MODEL_2, QR_MICRO, BARCODE_TYPES, BARCODE_HEIGHT, BARCODE_WIDTH
from .constants import BARCODE_FONT_A, BARCODE_FONT_B, BARCODE_FORMATS
@@ -487,11 +489,12 @@ class Escpos(object):
barcode_class = barcode.get_barcode_class(barcode_type)
my_code = barcode_class(data, writer=image_writer)
my_code.write("/dev/null", {
'module_height': module_height,
'module_width': module_width,
'text_distance': text_distance
})
with open(os.devnull, "wb") as nullfile:
my_code.write(nullfile, {
'module_height': module_height,
'module_width': module_width,
'text_distance': text_distance
})
# Retrieve the Pillow image and print it
image = my_code.writer._image