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

Automatically choose correct barcode function.

Tests for barcode function.
This commit is contained in:
Michael Elsdörfer
2016-08-30 12:53:31 +02:00
parent a07f84a5bc
commit 5fa89ff685
3 changed files with 76 additions and 14 deletions

View File

@@ -15,6 +15,9 @@ class NotSupported(Exception):
pass
BARCODE_B = 'barcodeB'
class BaseProfile(object):
"""This respresents a printer profile.
@@ -43,6 +46,11 @@ class BaseProfile(object):
font = self.get_font(font)
return self.fonts[six.text_type(font)]['columns']
def supports(self, feature):
"""Return true/false for the given feature.
"""
return self.features.get(feature)
def get_profile(name=None, **kwargs):
"""Get the profile by name; if no name is given, return the
@@ -84,10 +92,11 @@ def clean(s):
# For users, who want to provide their profile
class Profile(get_profile_class('default')):
def __init__(self, columns=None):
super(Profile, self).__init()
def __init__(self, columns=None, features={}):
super(Profile, self).__init__()
self.columns = columns
self.features = features
def get_columns(self, font):
if self.columns is not None: