improve doc, improve codepage_tables.py
This commit is contained in:
parent
e904500312
commit
e4a21e94fc
|
@ -56,4 +56,5 @@ def print_codepage(printer, codepage):
|
|||
printer._raw(sep)
|
||||
printer._raw('\n')
|
||||
|
||||
main()
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -99,9 +99,10 @@ def clean(s):
|
|||
return str(s)
|
||||
|
||||
|
||||
# For users, who want to provide their profile
|
||||
class Profile(get_profile_class('default')):
|
||||
|
||||
"""
|
||||
For users, who want to provide their profile
|
||||
"""
|
||||
def __init__(self, columns=None, features=None):
|
||||
super(Profile, self).__init__()
|
||||
|
||||
|
|
|
@ -208,14 +208,20 @@ class MagicEncode(object):
|
|||
|
||||
If the printer does not support a suitable code page, it can
|
||||
insert an error character.
|
||||
"""
|
||||
def __init__(self, driver, encoding=None, disabled=False,
|
||||
defaultsymbol='?', encoder=None):
|
||||
"""
|
||||
|
||||
:param driver:
|
||||
:param encoding: If you know the current encoding of the printer
|
||||
when initializing this class, set it here. If the current
|
||||
encoding is unknown, the first character emitted will be a
|
||||
codepage switch.
|
||||
:param disabled:
|
||||
:param defaultsymbol:
|
||||
:param encoder:
|
||||
"""
|
||||
def __init__(self, driver, encoding=None, disabled=False,
|
||||
defaultsymbol='?', encoder=None):
|
||||
if disabled and not encoding:
|
||||
raise Error('If you disable magic encode, you need to define an encoding!')
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@ from escpos.exceptions import CharCodeError, Error
|
|||
|
||||
|
||||
class TestEncoder:
|
||||
"""
|
||||
Tests the single encoders.
|
||||
"""
|
||||
|
||||
def test_can_encode(self):
|
||||
assert not Encoder({'CP437': 1}).can_encode('CP437', u'€')
|
||||
|
@ -40,10 +43,21 @@ class TestEncoder:
|
|||
|
||||
|
||||
class TestMagicEncode:
|
||||
"""
|
||||
Tests the magic encode functionality.
|
||||
"""
|
||||
|
||||
class TestInit:
|
||||
"""
|
||||
Test initialization.
|
||||
"""
|
||||
|
||||
def test_disabled_requires_encoding(self, driver):
|
||||
"""
|
||||
Test that disabled without encoder raises an error.
|
||||
|
||||
:param driver:
|
||||
"""
|
||||
with pytest.raises(Error):
|
||||
MagicEncode(driver, disabled=True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue