mirror of
				https://github.com/python-escpos/python-escpos
				synced 2025-10-23 09:30:00 +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:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user