mirror of
				https://github.com/python-escpos/python-escpos
				synced 2025-10-23 09:30:00 +00:00 
			
		
		
		
	Add an automatic newline for some methods
This commit is contained in:
		@@ -15,6 +15,9 @@ import sys
 | 
				
			|||||||
import six
 | 
					import six
 | 
				
			||||||
from . import config
 | 
					from . import config
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# A list of functions that work better with a newline to be sent after them.
 | 
				
			||||||
 | 
					REQUIRES_NEWLINE = ('qr', 'barcode', 'text', 'block_text')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Used in demo method
 | 
					# Used in demo method
 | 
				
			||||||
# Key: The name of escpos function and the argument passed on the CLI. Some
 | 
					# Key: The name of escpos function and the argument passed on the CLI. Some
 | 
				
			||||||
#   manual translation is done in the case of barcodes_a -> barcode.
 | 
					#   manual translation is done in the case of barcodes_a -> barcode.
 | 
				
			||||||
@@ -477,12 +480,13 @@ def main():
 | 
				
			|||||||
    if not printer:
 | 
					    if not printer:
 | 
				
			||||||
        raise Exception('No printers loaded from config')
 | 
					        raise Exception('No printers loaded from config')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    target_command = command_arguments.pop('func')
 | 
					    target_command = command_arguments.pop('func')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if hasattr(printer, target_command):
 | 
					    if hasattr(printer, target_command):
 | 
				
			||||||
        # print command with args
 | 
					        # print command with args
 | 
				
			||||||
        getattr(printer, target_command)(**command_arguments)
 | 
					        getattr(printer, target_command)(**command_arguments)
 | 
				
			||||||
 | 
					        if target_command in REQUIRES_NEWLINE:
 | 
				
			||||||
 | 
					            printer.text("\n")
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        command_arguments['printer'] = printer
 | 
					        command_arguments['printer'] = printer
 | 
				
			||||||
        globals()[target_command](**command_arguments)
 | 
					        globals()[target_command](**command_arguments)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user