From 4d479337d3463aa5bd5fa9db82468f9969198a22 Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Wed, 16 May 2018 02:15:52 +0200 Subject: [PATCH] other minor problems --- src/escpos/escpos.py | 10 ++++------ src/escpos/image.py | 2 +- src/escpos/magicencode.py | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/escpos/escpos.py b/src/escpos/escpos.py index 84a7aa5..2444b95 100644 --- a/src/escpos/escpos.py +++ b/src/escpos/escpos.py @@ -421,8 +421,8 @@ class Escpos(object): "Barcode '{bc}' not valid for barcode function type " '{function_type}').format( bc=bc, - function_type=function_type, - )) + function_type=function_type,) + ) if check and not self.check_barcode(bc, code): raise BarcodeCodeError(( @@ -590,8 +590,7 @@ class Escpos(object): """ if custom_size: - if 1 <= width <= 8 and 1 <= height <= 8 and isinstance(width, int) and\ - isinstance(height, int): + if 1 <= width <= 8 and 1 <= height <= 8 and isinstance(width, int) and isinstance(height, int): size_byte = TXT_STYLE['width'][width] + TXT_STYLE['height'][height] self._raw(TXT_SIZE + six.int2byte(size_byte)) else: @@ -640,8 +639,7 @@ class Escpos(object): if divisor not in LINESPACING_FUNCS: raise ValueError('divisor must be either 360, 180 or 60') - if (divisor in [360, 180] - and (not(0 <= spacing <= 255))): + if (divisor in [360, 180] and (not(0 <= spacing <= 255))): raise ValueError('spacing must be a int between 0 and 255 when divisor is 360 or 180') if divisor == 60 and (not(0 <= spacing <= 85)): raise ValueError('spacing must be a int between 0 and 85 when divisor is 60') diff --git a/src/escpos/image.py b/src/escpos/image.py index 51edaf9..d121d3f 100644 --- a/src/escpos/image.py +++ b/src/escpos/image.py @@ -107,7 +107,7 @@ class EscposImage(object): :param fragment_height: height of fragment :return: list of PIL objects """ - passes = int(math.ceil(self.height/fragment_height)) + passes = int(math.ceil(self.height // fragment_height)) fragments = [] for n in range(0, passes): left = 0 diff --git a/src/escpos/magicencode.py b/src/escpos/magicencode.py index 29c05ff..8e67d9c 100644 --- a/src/escpos/magicencode.py +++ b/src/escpos/magicencode.py @@ -64,7 +64,7 @@ class Encoder(object): raise ValueError(( 'Encoding "{}" cannot be used for the current profile. ' 'Valid encodings are: {}' - ).format(encoding, ','.join(self.codepages.keys()))) + ).format(encoding, ','.join(self.codepages.keys()))) return encoding @staticmethod