From b29ef6df69401778a9c51ad7383bcb24c9e603c4 Mon Sep 17 00:00:00 2001 From: Curtis // mashedkeyboard Date: Thu, 1 Sep 2016 11:57:58 +0100 Subject: [PATCH 01/11] Corrected set() command documentation The documentation currently says that `printer.set(type="B")` is the way to bold text. It won't work - you need to use `printer.set(text_type="B")`. --- doc/user/methods.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/user/methods.rst b/doc/user/methods.rst index 12a076c..3edf37b 100644 --- a/doc/user/methods.rst +++ b/doc/user/methods.rst @@ -84,7 +84,7 @@ text("text") Prints raw text. Raises ``TextError`` exception. -set("align", "font", "type", width, height, invert, smooth, flip) +set("align", "font", "text_type", width, height, invert, smooth, flip) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Set text properties. @@ -96,7 +96,7 @@ Set text properties. * RIGHT > > *Default:* left * ``font`` type could be ``A`` or ``B``. *Default:* A -* ``type`` type could be ``B`` (Bold), ``U`` (Underline) or ``normal``. *Default:* normal +* ``text_type`` type could be ``B`` (Bold), ``U`` (Underline) or ``normal``. *Default:* normal * ``width`` is a numeric value, 1 is for regular size, and 2 is twice the standard size. *Default*: 1 * ``height`` is a numeric value, 1 is for regular size and 2 is twice the standard size. *Default*: 1 * ``invert`` is a boolean value, True enables white on black printing. *Default*: False From f5c706db34f3330293e7fba7a61236bfa5c5afd6 Mon Sep 17 00:00:00 2001 From: Curtis // mashedkeyboard Date: Thu, 1 Sep 2016 12:10:35 +0100 Subject: [PATCH 02/11] Extended underline to fit the wording of the new subtitle --- doc/user/methods.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/user/methods.rst b/doc/user/methods.rst index 3edf37b..228170f 100644 --- a/doc/user/methods.rst +++ b/doc/user/methods.rst @@ -85,7 +85,7 @@ text("text") Prints raw text. Raises ``TextError`` exception. set("align", "font", "text_type", width, height, invert, smooth, flip) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Set text properties. From f467cacdd81053f11ef765db88851c6a35ee3677 Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Fri, 2 Sep 2016 16:56:12 +0200 Subject: [PATCH 03/11] improve import capabilities from a submodule The capabilities are now imported as a submodule from mike42/escpos-printer-db fixes #174 --- .gitignore | 1 + .gitmodules | 3 +++ MANIFEST.in | 1 + capabilities-data | 1 + setup.py | 2 +- src/escpos/capabilities.json | 2 +- 6 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .gitmodules create mode 160000 capabilities-data mode change 100644 => 120000 src/escpos/capabilities.json diff --git a/.gitignore b/.gitignore index 944dcb3..932ff9b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ $~ .idea/ .directory +.cache/ # temporary data temp diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d474ac2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "capabilities-data"] + path = capabilities-data + url = https://github.com/mike42/escpos-printer-db.git diff --git a/MANIFEST.in b/MANIFEST.in index 997ee7b..eeed97e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,6 +3,7 @@ include *.txt include COPYING include INSTALL include tox.ini +include capabilities-data/dist/capabilities.json recursive-include doc *.bat recursive-include doc *.ico recursive-include doc *.py diff --git a/capabilities-data b/capabilities-data new file mode 160000 index 0000000..8744f93 --- /dev/null +++ b/capabilities-data @@ -0,0 +1 @@ +Subproject commit 8744f9397ef6b58aee502aa75ac1efad31c9f5d7 diff --git a/setup.py b/setup.py index ebc785d..d29d7b9 100755 --- a/setup.py +++ b/setup.py @@ -72,7 +72,7 @@ setup( author='Manuel F Martinez and others', author_email='manpaz@bashlinux.com', maintainer='Patrick Kanzler', - maintainer_email='patrick.kanzler@fablab.fau.de', + maintainer_email='dev@pkanzler.de', keywords=[ 'ESC/POS', 'thermoprinter', diff --git a/src/escpos/capabilities.json b/src/escpos/capabilities.json deleted file mode 100644 index 02ada55..0000000 --- a/src/escpos/capabilities.json +++ /dev/null @@ -1 +0,0 @@ -{"profiles": {"TM-T88III": {"vendor": "Epson", "features": {"starCommands": false, "highDensity": true, "barcodeB": true, "bitImageColumn": true, "graphics": true, "qrCode": true, "bitImageRaster": true}, "media": {"width": {"mm": "Unknown", "pixels": "Unknown"}}, "notes": "", "fonts": {"1": {"name": "Font B", "columns": 56}, "0": {"name": "Font A", "columns": 42}}, "colors": {"0": "black"}, "codePages": {"17": "CP866", "16": "CP1252", "19": "CP858", "18": "CP862", "1": "Unknown", "0": "CP437", "3": "CP860", "2": "CP850", "5": "CP865", "4": "CP863", "255": "Unknown"}, "name": "TM-T88III"}, "TM-P80": {"vendor": "Epson", "features": {"starCommands": false, "highDensity": true, "barcodeB": true, "bitImageColumn": true, "graphics": true, "qrCode": true, "bitImageRaster": true}, "media": {"width": {"mm": 72, "pixels": 576}}, "notes": "Portable printer (48-column mode)", "fonts": {"1": {"name": "Font B", "columns": 56}, "0": {"name": "Font A", "columns": 42}, "2": {"name": "Kanji", "columns": 24}}, "colors": {"0": "black"}, "codePages": {"51": "CP1257", "48": "CP1254", "50": "CP1256", "82": "Unknown", "49": "CP1255", "66": "Unknown", "67": "Unknown", "68": "Unknown", "69": "Unknown", "52": "CP1258", "53": "RK1048", "254": "Unknown", "255": "Unknown", "24": "Unknown", "25": "Unknown", "26": "Unknown", "20": "Unknown", "21": "CP874", "22": "Unknown", "23": "Unknown", "46": "CP1251", "47": "CP1253", "44": "CP1125", "45": "CP1250", "42": "CP774", "43": "CP772", "40": "ISO_8859-15", "41": "CP1098", "1": "CP932", "0": "CP437", "3": "CP860", "2": "CP850", "5": "CP865", "4": "CP863", "7": "Unknown", "6": "Unknown", "8": "Unknown", "39": "ISO_8859-2", "75": "Unknown", "38": "CP869", "73": "Unknown", "72": "Unknown", "71": "Unknown", "70": "Unknown", "11": "CP851", "13": "CP857", "12": "CP853", "15": "ISO_8859-7", "14": "CP737", "17": "CP866", "16": "CP1252", "19": "CP858", "18": "CP852", "31": "TCVN-3-2", "30": "TCVN-3-1", "37": "CP864", "36": "CP862", "35": "CP861", "34": "CP855", "33": "CP775", "74": "Unknown", "32": "CP720"}, "name": "TM-P80"}, "P822D": {"vendor": "PBM", "features": {"starCommands": false, "highDensity": true, "barcodeB": true, "bitImageColumn": true, "graphics": false, "qrCode": true, "bitImageRaster": true}, "media": {"width": {"mm": "Unknown", "pixels": "Unknown"}}, "notes": "", "fonts": {"1": {"name": "Font B", "columns": 56}, "0": {"name": "Font A", "columns": 42}}, "colors": {"0": "black"}, "codePages": {"56": "CP861", "81": "CP3848", "54": "CP852", "60": "CP855", "61": "CP857", "62": "CP862", "63": "CP864", "64": "CP737", "53": "CP858", "66": "CP869", "67": "CP928", "68": "CP772", "69": "CP774", "80": "CP3847", "52": "CP437", "86": "CP3011", "87": "CP3012", "84": "CP3001", "85": "CP3002", "24": "CP747", "25": "CP1257", "27": "Unknown", "20": "Unknown", "21": "Unknown", "22": "Unknown", "23": "Unknown", "82": "CP1001", "28": "CP864", "29": "CP1001", "1": "Unknown", "0": "CP437", "3": "CP860", "2": "CP850", "5": "CP865", "4": "CP863", "7": "Unknown", "6": "Unknown", "9": "Unknown", "8": "Unknown", "255": "Unknown", "83": "CP2001", "77": "CP3844", "76": "CP3843", "75": "CP3841", "74": "CP3840", "73": "CP1251", "72": "CP1250", "71": "CP1252", "70": "CP874", "79": "CP3846", "78": "CP3845", "10": "Unknown", "59": "CP866", "58": "CP865", "17": "CP866", "16": "CP1252", "19": "CP858", "18": "CP852", "31": "Unknown", "30": "Unknown", "51": "Unknown", "50": "CP437", "35": "CP1257", "34": "CP1256", "33": "CP720", "55": "CP860", "89": "CP3041", "88": "CP3021", "32": "CP1255", "57": "CP863", "65": "CP851"}, "name": "P822D"}, "TEP-200M": {"vendor": "EPOS", "features": {"starCommands": false, "highDensity": true, "barcodeB": true, "bitImageColumn": true, "graphics": true, "qrCode": true, "bitImageRaster": true}, "media": {"width": {"mm": "Unknown", "pixels": "Unknown"}}, "notes": "", "fonts": {"1": {"name": "Font B", "columns": 56}, "0": {"name": "Font A", "columns": 42}}, "colors": {"0": "black"}, "codePages": {"51": "CP1257", "48": "CP1254", "50": "CP1256", "82": "Unknown", "49": "CP1255", "66": "Unknown", "67": "Unknown", "68": "Unknown", "69": "Unknown", "52": "CP1258", "53": "RK1048", "254": "Unknown", "255": "Unknown", "24": "Unknown", "25": "Unknown", "26": "Unknown", "20": "Unknown", "21": "CP874", "22": "Unknown", "23": "Unknown", "46": "CP1251", "47": "CP1253", "44": "CP1125", "45": "CP1250", "42": "CP774", "43": "CP772", "40": "ISO_8859-15", "41": "CP1098", "1": "CP932", "0": "CP437", "3": "CP860", "2": "CP850", "5": "CP865", "4": "CP863", "7": "Unknown", "6": "Unknown", "8": "Unknown", "39": "ISO_8859-2", "75": "Unknown", "38": "CP869", "73": "Unknown", "72": "Unknown", "71": "Unknown", "70": "Unknown", "11": "CP851", "13": "CP857", "12": "CP853", "15": "ISO_8859-7", "14": "CP737", "17": "CP866", "16": "CP1252", "19": "CP858", "18": "CP852", "31": "TCVN-3-2", "30": "TCVN-3-1", "37": "CP864", "36": "CP862", "35": "CP861", "34": "CP855", "33": "CP775", "74": "Unknown", "32": "CP720"}, "name": "TEP200M Series"}, "TM-T88II": {"vendor": "Epson", "features": {"starCommands": false, "highDensity": true, "barcodeB": true, "bitImageColumn": true, "graphics": true, "qrCode": true, "bitImageRaster": true}, "media": {"width": {"mm": "Unknown", "pixels": "Unknown"}}, "notes": "", "fonts": {"1": {"name": "Font B", "columns": 56}, "0": {"name": "Font A", "columns": 42}}, "colors": {"0": "black"}, "codePages": {"16": "CP1252", "1": "Unknown", "0": "CP437", "3": "CP860", "2": "CP850", "5": "CP865", "4": "CP863", "255": "Unknown"}, "name": "TM-T88II"}, "TM-P80-42col": {"vendor": "Epson", "features": {"starCommands": false, "highDensity": true, "barcodeB": true, "bitImageColumn": true, "graphics": true, "qrCode": true, "bitImageRaster": true}, "media": {"width": {"mm": 63.6, "pixels": 546}}, "notes": "Portable printer (42-column mode)", "fonts": {"1": {"name": "Font B", "columns": 60}, "0": {"name": "Font A", "columns": 42}, "2": {"name": "Kanji", "columns": 21}}, "colors": {"0": "black"}, "codePages": {"51": "CP1257", "48": "CP1254", "50": "CP1256", "82": "Unknown", "49": "CP1255", "66": "Unknown", "67": "Unknown", "68": "Unknown", "69": "Unknown", "52": "CP1258", "53": "RK1048", "254": "Unknown", "255": "Unknown", "24": "Unknown", "25": "Unknown", "26": "Unknown", "20": "Unknown", "21": "CP874", "22": "Unknown", "23": "Unknown", "46": "CP1251", "47": "CP1253", "44": "CP1125", "45": "CP1250", "42": "CP774", "43": "CP772", "40": "ISO_8859-15", "41": "CP1098", "1": "CP932", "0": "CP437", "3": "CP860", "2": "CP850", "5": "CP865", "4": "CP863", "7": "Unknown", "6": "Unknown", "8": "Unknown", "39": "ISO_8859-2", "75": "Unknown", "38": "CP869", "73": "Unknown", "72": "Unknown", "71": "Unknown", "70": "Unknown", "11": "CP851", "13": "CP857", "12": "CP853", "15": "ISO_8859-7", "14": "CP737", "17": "CP866", "16": "CP1252", "19": "CP858", "18": "CP852", "31": "TCVN-3-2", "30": "TCVN-3-1", "37": "CP864", "36": "CP862", "35": "CP861", "34": "CP855", "33": "CP775", "74": "Unknown", "32": "CP720"}, "name": "TM-P80 (42 column mode)"}, "TSP600": {"vendor": "Star Micronics", "features": {"starCommands": true, "highDensity": true, "barcodeB": true, "bitImageColumn": true, "graphics": true, "qrCode": true, "bitImageRaster": true}, "media": {"width": {"mm": "Unknown", "pixels": "Unknown"}}, "notes": "Star TSP600 thermal printer series with ESC/POS emulation enabled", "fonts": {"1": {"name": "Font B", "columns": 56}, "0": {"name": "Font A", "columns": 42}}, "colors": {"0": "black"}, "codePages": {"98": "Unknown", "64": "CP3840", "65": "CP3841", "66": "CP3843", "67": "CP3844", "68": "CP3845", "69": "CP3846", "255": "Unknown", "20": "CP774", "21": "CP874", "1": "CP437", "0": "CP437", "3": "CP437", "2": "CP932", "5": "CP852", "4": "CP858", "7": "CP861", "6": "CP860", "9": "CP865", "8": "CP863", "96": "Unknown", "97": "Unknown", "77": "CP3012", "76": "CP3011", "75": "CP3002", "74": "CP3001", "73": "CP2001", "72": "CP1001", "71": "CP3848", "70": "CP3847", "102": "Unknown", "100": "Unknown", "101": "Unknown", "79": "CP3041", "78": "CP3021", "11": "CP855", "10": "CP866", "13": "CP862", "12": "CP857", "15": "CP737", "14": "CP864", "17": "CP869", "16": "CP851", "19": "CP772", "18": "CP928", "34": "CP1251", "99": "Unknown", "33": "CP1250", "32": "CP1252"}, "name": "TSP600 Series"}, "default": {"vendor": "Generic", "features": {"starCommands": false, "highDensity": true, "barcodeB": true, "bitImageColumn": true, "graphics": true, "qrCode": true, "bitImageRaster": true}, "media": {"width": {"mm": "Unknown", "pixels": "Unknown"}}, "notes": "Default ESC/POS profile, suitable for standards-compliant or Epson-branded printers. This profile allows the use of standard ESC/POS features, and can encode a variety of code pages.\n", "fonts": {"1": {"name": "Font B", "columns": 56}, "0": {"name": "Font A", "columns": 42}}, "colors": {"0": "black"}, "codePages": {"51": "CP1257", "48": "CP1254", "50": "CP1256", "82": "Unknown", "49": "CP1255", "66": "Unknown", "67": "Unknown", "68": "Unknown", "69": "Unknown", "52": "CP1258", "53": "RK1048", "254": "Unknown", "255": "Unknown", "24": "Unknown", "25": "Unknown", "26": "Unknown", "20": "Unknown", "21": "CP874", "22": "Unknown", "23": "Unknown", "46": "CP1251", "47": "CP1253", "44": "CP1125", "45": "CP1250", "42": "CP774", "43": "CP772", "40": "ISO_8859-15", "41": "CP1098", "1": "CP932", "0": "CP437", "3": "CP860", "2": "CP850", "5": "CP865", "4": "CP863", "7": "Unknown", "6": "Unknown", "8": "Unknown", "39": "ISO_8859-2", "75": "Unknown", "38": "CP869", "73": "Unknown", "72": "Unknown", "71": "Unknown", "70": "Unknown", "11": "CP851", "13": "CP857", "12": "CP853", "15": "ISO_8859-7", "14": "CP737", "17": "CP866", "16": "CP1252", "19": "CP858", "18": "CP852", "31": "TCVN-3-2", "30": "TCVN-3-1", "37": "CP864", "36": "CP862", "35": "CP861", "34": "CP855", "33": "CP775", "74": "Unknown", "32": "CP720"}, "name": "Default"}, "TUP500": {"vendor": "Star Micronics", "features": {"starCommands": true, "highDensity": true, "barcodeB": true, "bitImageColumn": true, "graphics": true, "qrCode": true, "bitImageRaster": true}, "media": {"width": {"mm": "Unknown", "pixels": "Unknown"}}, "notes": "Star TUP500 thermal printer series with ESC/POS emulation enabled", "fonts": {"1": {"name": "Font B", "columns": 56}, "0": {"name": "Font A", "columns": 42}}, "colors": {"0": "black"}, "codePages": {"98": "Unknown", "64": "CP3840", "65": "CP3841", "66": "CP3843", "67": "CP3844", "68": "CP3845", "69": "CP3846", "255": "Unknown", "20": "CP774", "21": "CP874", "1": "CP437", "0": "CP437", "3": "CP437", "2": "CP932", "5": "CP852", "4": "CP858", "7": "CP861", "6": "CP860", "9": "CP865", "8": "CP863", "96": "Unknown", "97": "Unknown", "77": "CP3012", "76": "CP3011", "75": "CP3002", "74": "CP3001", "73": "CP2001", "72": "CP1001", "71": "CP3848", "70": "CP3847", "102": "Unknown", "100": "Unknown", "101": "Unknown", "79": "CP3041", "78": "CP3021", "11": "CP855", "10": "CP866", "13": "CP862", "12": "CP857", "15": "CP737", "14": "CP864", "17": "CP869", "16": "CP851", "19": "CP772", "18": "CP928", "34": "CP1251", "99": "Unknown", "33": "CP1250", "32": "CP1252"}, "name": "TUP500 Series"}, "TM-U220": {"vendor": "Epson", "features": {"starCommands": false, "highDensity": false, "barcodeB": false, "bitImageColumn": true, "graphics": false, "qrCode": false, "bitImageRaster": false}, "media": {"width": {"mm": 80, "pixels": "Unknown"}}, "notes": "Two-color impact printer with 80mm output", "fonts": {"1": {"name": "Font B", "columns": 56}, "0": {"name": "Font A", "columns": 42}}, "colors": {"1": "alternate", "0": "black"}, "codePages": {"0": "CP437"}, "name": "TM-U220"}, "simple": {"vendor": "Generic", "features": {"starCommands": false, "highDensity": true, "barcodeB": false, "bitImageColumn": false, "graphics": false, "qrCode": false, "bitImageRaster": true}, "media": {"width": {"mm": "Unknown", "pixels": "Unknown"}}, "notes": "A profile for use in printers with unknown or poor compatibility. This profile indicates that a small number of features are supported, so that commands are not sent a printer that is unlikely to understand them.\n", "fonts": {"1": {"name": "Font B", "columns": 56}, "0": {"name": "Font A", "columns": 42}}, "colors": {"0": "black"}, "codePages": {"0": "CP437"}, "name": "Simple"}, "SP2000": {"vendor": "Star Micronics", "features": {"starCommands": true, "highDensity": true, "barcodeB": true, "bitImageColumn": true, "graphics": true, "qrCode": true, "bitImageRaster": true}, "media": {"width": {"mm": "Unknown", "pixels": "Unknown"}}, "notes": "Star SP2000 impact printer series with ESC/POS emulation enabled", "fonts": {"1": {"name": "Font B", "columns": 56}, "0": {"name": "Font A", "columns": 42}}, "colors": {"0": "black"}, "codePages": {"98": "Unknown", "64": "CP3840", "65": "CP3841", "66": "CP3843", "67": "CP3844", "68": "CP3845", "69": "CP3846", "255": "Unknown", "20": "CP774", "21": "CP874", "1": "CP437", "0": "CP437", "3": "CP437", "2": "CP932", "5": "CP852", "4": "CP858", "7": "CP861", "6": "CP860", "9": "CP865", "8": "CP863", "96": "Unknown", "97": "Unknown", "77": "CP3012", "76": "CP3011", "75": "CP3002", "74": "CP3001", "73": "CP2001", "72": "CP1001", "71": "CP3848", "70": "CP3847", "102": "Unknown", "100": "Unknown", "101": "Unknown", "79": "CP3041", "78": "CP3021", "11": "CP855", "10": "CP866", "13": "CP862", "12": "CP857", "15": "CP737", "14": "CP864", "17": "CP869", "16": "CP851", "19": "CP772", "18": "CP928", "34": "CP1251", "99": "Unknown", "33": "CP1250", "32": "CP1252"}, "name": "SP2000 Series"}}, "encodings": {"CP3041": {"name": "Unimplemented Star-specific CP3041"}, "RK1048": {"iconv": "RK1048", "name": "RK1048"}, "Unknown": {"notes": "Code page that has not yet been identified.", "name": "Unknown"}, "CP1252": {"iconv": "CP1252", "python_encode": "cp1252", "name": "CP1252"}, "CP1255": {"iconv": "CP1255", "python_encode": "cp1255", "name": "CP1255"}, "CP1254": {"iconv": "CP1254", "python_encode": "cp1254", "name": "CP1254"}, "CP1257": {"iconv": "CP1257", "python_encode": "cp1257", "name": "CP1257"}, "CP1256": {"iconv": "CP1256", "python_encode": "cp1256", "name": "CP1256"}, "CP1251": {"iconv": "CP1251", "python_encode": "cp1251", "name": "CP1251"}, "CP1250": {"iconv": "CP1250", "python_encode": "cp1250", "name": "CP1250"}, "CP1253": {"iconv": "CP1253", "python_encode": "cp1253", "name": "CP1253"}, "CP1098": {"name": "CP1098"}, "CP437": {"iconv": "CP437", "python_encode": "cp437", "name": "CP437"}, "CP3021": {"name": "Unimplemented Star-specific CP3021"}, "CP3002": {"name": "Unimplemented Star-specific CP3002"}, "CP1258": {"iconv": "CP1258", "python_encode": "cp1258", "name": "CP1258"}, "CP3001": {"name": "Unimplemented Star-specific CP3001"}, "CP928": {"name": "CP928"}, "TCVN-3-1": {"data": [" ", " ", " \u0103\u00e2\u00ea\u00f4\u01a1\u01b0\u0111 ", " \u00e0\u1ea3\u00e3\u00e1\u1ea1 \u1eb1\u1eb3\u1eb5\u1eaf ", " \u1eb7\u1ea7\u1ea9\u1eab\u1ea5\u1ead\u00e8 \u1ebb\u1ebd", "\u00e9\u1eb9\u1ec1\u1ec3\u1ec5\u1ebf\u1ec7\u00ec\u1ec9 \u0129\u00ed\u1ecb\u00f2", " \u1ecf\u00f5\u00f3\u1ecd\u1ed3\u1ed5\u1ed7\u1ed1\u1ed9\u1edd\u1edf\u1ee1\u1edb\u1ee3\u00f9", " \u1ee7\u0169\u00fa\u1ee5\u1eeb\u1eed\u1eef\u1ee9\u1ef1\u1ef3\u1ef7\u1ef9\u00fd\u1ef5 "], "name": "Vietnamese TCVN-3 1"}, "TCVN-3-2": {"data": [" ", " ", " \u0102\u00c2 \u00d0 \u00ca\u00d4\u01a0\u01af ", " \u00c0\u1ea2\u00c3\u00c1\u1ea0 \u1eb0\u1eb2\u1eb4\u1eae ", " \u1eb6\u1ea6\u1ea8\u1eaa\u1ea4\u1eac\u00c8 \u1eba\u1ebc", "\u00c9\u1eb8\u1ec0\u1ec2\u1ec4\u1ebe\u1ec6\u00cc\u1ec8 \u0128\u00cd\u1eca\u00d2", " \u1ece\u00d5\u00d3\u1ecc\u1ed2\u1ed4\u1ed6\u1ed0\u1ed8\u1edc\u1ede\u1ee0\u1eda\u1ee2\u00d9", " \u1ee6\u0168\u00da\u1ee4\u1eea\u1eec\u1eee\u1ee8\u1ef0\u1ef2\u1ef6\u1ef8\u00dd\u1ef4 "], "name": "Vietnamese TCVN-3 1"}, "CP737": {"iconv": "CP737", "python_encode": "cp737", "name": "CP737"}, "CP747": {"name": "CP747"}, "CP851": {"notes": "Not used, due to inconsistencies between implementations.", "name": "Greek CP851"}, "CP850": {"iconv": "CP850", "python_encode": "cp850", "name": "CP850"}, "CP853": {"name": "CP853"}, "CP852": {"iconv": "CP852", "python_encode": "cp852", "name": "CP852"}, "CP855": {"iconv": "CP855", "python_encode": "cp855", "name": "CP855"}, "CP857": {"iconv": "CP857", "python_encode": "cp857", "name": "CP857"}, "CP861": {"iconv": "CP861", "python_encode": "cp861", "name": "CP861"}, "CP774": {"iconv": "CP774", "name": "CP774"}, "CP775": {"iconv": "CP775", "python_encode": "cp775", "name": "CP775"}, "CP874": {"iconv": "CP874", "python_encode": "cp874", "name": "CP874"}, "CP866": {"iconv": "CP866", "python_encode": "cp866", "name": "CP866"}, "CP1125": {"iconv": "CP1125", "python_encode": "cp1125", "name": "CP1125"}, "CP1001": {"name": "Unimplemented Star-specific CP1001"}, "CP858": {"python_encode": "cp858", "name": "CP858"}, "CP932": {"iconv": "CP932", "python_encode": "cp932", "name": "CP932"}, "CP3011": {"data": ["\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5", "\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00a2\u00a3\u00a5\u20a7\u0192", "\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u2310\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb", "\u2591\u2592\u2593\u2502\u2524\u0100\u2562\u0146\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510", "\u2514\u2534\u252c\u251c\u2500\u253c\u0101\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567", "\u0160\u2564\u010d\u010c\u2558\u2552\u0123\u012a\u012b\u2518\u250c\u2588\u2584\u016b\u016a\u2580", "\u03b1\u00df\u0393\u03c0\u03a3\u03c3\u00b5\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u03c6\u03b5\u2229", "\u0112\u0113\u0122\u0137\u0136\u013c\u013b\u017e\u017d\u2219\u00b7\u221a\u0145\u0161\u25a0 "], "name": "CP3011 Latvian"}, "CP862": {"iconv": "CP862", "python_encode": "cp862", "name": "CP862"}, "CP3012": {"data": ["\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041a\u041b\u041c\u041d\u041e\u041f", "\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042a\u042b\u042c\u042d\u042e\u042f", "\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043a\u043b\u043c\u043d\u043e\u043f", "\u2591\u2592\u2593\u2502\u2524\u0100\u2562\u0146\u2555\u2563\u2551\u2557\u255d\u014c\u255b\u2510", "\u2514\u2534\u252c\u251c\u2500\u253c\u0101\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567", "\u0160\u2564\u010d\u010c\u2558\u2552\u0123\u012a\u012b\u2518\u250c\u2588\u2584\u016b\u016a\u2580", "\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044a\u044b\u044c\u044d\u044e\u044f", "\u0112\u0113\u0122\u0137\u0136\u013c\u013b\u017e\u017d\u2219\u00b7\u221a\u0145\u0161\u25a0 "], "name": "CP3012 Cyrillic"}, "ISO_8859-7": {"iconv": "ISO_8859-7", "python_encode": "iso8859_7", "name": "ISO_8859-7"}, "CP863": {"iconv": "CP863", "python_encode": "cp863", "name": "CP863"}, "CP720": {"python_encode": "cp720", "name": "CP720"}, "CP2001": {"name": "Unimplemented Star-specific CP2001"}, "CP864": {"iconv": "CP864", "python_encode": "cp864", "name": "CP864"}, "ISO_8859-2": {"iconv": "ISO_8859-2", "python_encode": "iso8859_2", "name": "ISO_8859-2"}, "CP865": {"iconv": "CP865", "python_encode": "cp865", "name": "CP865"}, "CP869": {"iconv": "CP869", "python_encode": "cp869", "name": "CP869"}, "CP3848": {"name": "Unimplemented Star-specific CP3848"}, "ISO_8859-15": {"iconv": "ISO_8859-15", "python_encode": "iso8859-15", "name": "ISO_8859-15"}, "CP772": {"iconv": "CP772", "name": "CP772"}, "CP860": {"iconv": "CP860", "python_encode": "cp860", "name": "CP860"}, "CP3843": {"name": "Unimplemented Star-specific CP3843"}, "CP3840": {"name": "Unimplemented Star-specific CP3840"}, "CP3841": {"name": "Unimplemented Star-specific CP3841"}, "CP3846": {"name": "Unimplemented Star-specific CP3846"}, "CP3847": {"name": "Unimplemented Star-specific CP3847"}, "CP3844": {"name": "Unimplemented Star-specific CP3844"}, "CP3845": {"name": "Unimplemented Star-specific CP3845"}}} diff --git a/src/escpos/capabilities.json b/src/escpos/capabilities.json new file mode 120000 index 0000000..fd2b9f4 --- /dev/null +++ b/src/escpos/capabilities.json @@ -0,0 +1 @@ +../../capabilities-data/dist/capabilities.json \ No newline at end of file From 57ed77e33251b0d4e3f1cb0e82bb8459b9af8ed1 Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Tue, 6 Sep 2016 23:15:54 +0200 Subject: [PATCH 04/11] update contributing.rst on resolving issues --- CONTRIBUTING.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index e68360f..9d5de8b 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -29,7 +29,7 @@ of every file of code: from __future__ import division from __future__ import print_function from __future__ import unicode_literals - + Furthermore please be aware of the differences between Python 2 and 3. For example `this guide `_ is helpful. Special care has to be taken when dealing with strings and byte-strings. Please note @@ -45,8 +45,7 @@ The checks by Landscape and QuantifiedCode that run on every PR will provide you GIT ^^^ The master-branch contains code that has been released to PyPi. A release is marked with a tag -corresponding to the version. Issues are closed when they have been resolved in a released version -of the package. +corresponding to the version. Issues are closed when they have been resolved in the development-branch. When you have a change to make, begin by creating a new branch from the HEAD of `python-escpos/development`. Name your branch to indicate what you are trying to achieve. Good branch names might From 95a84d3673b303fe5a3a52184a3f0abe25874d48 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 9 Sep 2016 18:26:25 +1000 Subject: [PATCH 05/11] update printer DB submodule path --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index d474ac2..8c16a8a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "capabilities-data"] path = capabilities-data - url = https://github.com/mike42/escpos-printer-db.git + url = https://github.com/receipt-print-hq/escpos-printer-db.git From b5bf1125dba6d4e5e13ff2892b5ff736eb50f7ce Mon Sep 17 00:00:00 2001 From: Michael Billington Date: Sun, 11 Sep 2016 17:17:22 +1000 Subject: [PATCH 06/11] reverse the lookup order to correct encoding issues --- src/escpos/magicencode.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/escpos/magicencode.py b/src/escpos/magicencode.py index b36b844..3a545b7 100644 --- a/src/escpos/magicencode.py +++ b/src/escpos/magicencode.py @@ -17,6 +17,7 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals +from builtins import bytes, chr from .constants import CODEPAGE_CHANGE from .exceptions import CharCodeError, Error from .capabilities import get_profile @@ -66,17 +67,22 @@ class Encoder(object): return encoding def can_encode(self, encoding, char): - try: - encoded = CodePages.encode(char, encoding) - assert type(encoded) is bytes - return encoded - except LookupError: - # We don't have this encoding - return False - except UnicodeEncodeError: - return False + # Compute the encodable characters in the upper half of this code page + encodable_chars = [u" "] * 128 + for i in range(0, 128): + codepoint = i + 128 + try: + encodable_chars[i] = bytes([codepoint]).decode(encoding) + except UnicodeDecodeError: + # Non-encodable character + pass + except LookupError: + # We don't have this encoding + return False - return True + # Decide whether this character is encodeable in this code page + is_ascii = ord(char) < 128 + return is_ascii or char in encodable_chars def __encoding_sort_func(self, item): key, index = item From d9a6960f070d4f8aadb82ea9041e63fd5d665c01 Mon Sep 17 00:00:00 2001 From: Michael Billington Date: Sun, 11 Sep 2016 20:21:30 +1000 Subject: [PATCH 07/11] efficiency improvements for backwards encoding --- src/escpos/magicencode.py | 51 +++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/src/escpos/magicencode.py b/src/escpos/magicencode.py index 3a545b7..5ecaf6c 100644 --- a/src/escpos/magicencode.py +++ b/src/escpos/magicencode.py @@ -17,7 +17,7 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals -from builtins import bytes, chr +from builtins import bytes from .constants import CODEPAGE_CHANGE from .exceptions import CharCodeError, Error from .capabilities import get_profile @@ -46,6 +46,7 @@ class Encoder(object): def __init__(self, codepage_map): self.codepages = codepage_map self.available_encodings = set(codepage_map.keys()) + self.available_characters = {} self.used_encodings = set() def get_sequence(self, encoding): @@ -66,8 +67,15 @@ class Encoder(object): ).format(encoding, ','.join(self.codepages.keys()))) return encoding - def can_encode(self, encoding, char): - # Compute the encodable characters in the upper half of this code page + def _get_codepage_char_list(self, encoding): + """Get codepage character list + + Gets characters 128-255 for a given code page, as an array. + + :param encoding: The name of the encoding. This must be a valid python encoding. + """ + # Compute the encodable characters as an array (this is the format + # that for non-standard codings come in) encodable_chars = [u" "] * 128 for i in range(0, 128): codepoint = i + 128 @@ -76,13 +84,42 @@ class Encoder(object): except UnicodeDecodeError: # Non-encodable character pass - except LookupError: - # We don't have this encoding - return False + return encodable_chars + + def _get_codepage_char_map(self, encoding): + """ Get codepage character map + + Process an encoding and return a map of UTF-characters to code points + in this encoding. + + This is generated once only, and returned from a cache. + + :param encoding: The name of the encoding. + """ + # Skip things that were loaded previously + if encoding in self.available_characters: + return self.available_characters[encoding] + codepage_char_list = self._get_codepage_char_list(encoding) + codepage_char_map = dict((utf8, i + 128) for (i, utf8) in enumerate(codepage_char_list)) + self.available_characters[encoding] = codepage_char_map + return codepage_char_map + + def can_encode(self, encoding, char): + """Determine if a character is encodeable in the given code page. + + :param encoding: The name of the encoding. + :param char: The character to attempt to encode. + """ + available_map = {} + try: + available_map = self._get_codepage_char_map(encoding) + except LookupError: + return False # Decide whether this character is encodeable in this code page is_ascii = ord(char) < 128 - return is_ascii or char in encodable_chars + is_encodable = char in available_map + return is_ascii or is_encodable def __encoding_sort_func(self, item): key, index = item From 9a65945fcd0c7a2d7a2a81f2212c0e138623640f Mon Sep 17 00:00:00 2001 From: Michael Billington Date: Sun, 11 Sep 2016 21:03:55 +1000 Subject: [PATCH 08/11] re-work encoder to consult the capabilities database and use custom code pages or python encoder as necessary --- src/escpos/capabilities.py | 2 +- src/escpos/codepages.py | 18 +++--------- src/escpos/magicencode.py | 60 ++++++++++++++++++++++++++++---------- test/test_magicencode.py | 2 +- 4 files changed, 50 insertions(+), 32 deletions(-) diff --git a/src/escpos/capabilities.py b/src/escpos/capabilities.py index e569ccc..4fa9664 100644 --- a/src/escpos/capabilities.py +++ b/src/escpos/capabilities.py @@ -58,7 +58,7 @@ class BaseProfile(object): def get_code_pages(self): """Return the support code pages as a {name: index} dict. """ - return {v.lower(): k for k, v in self.codePages.items()} + return {v: k for k, v in self.codePages.items()} diff --git a/src/escpos/codepages.py b/src/escpos/codepages.py index 9666fb2..05d5852 100644 --- a/src/escpos/codepages.py +++ b/src/escpos/codepages.py @@ -12,21 +12,11 @@ class CodePageManager: def get_all(self): return self.data.values() - def encode(self, text, encoding, errors='strict'): - """Adds support for Japanese to the builtin str.encode(). - - TODO: Add support for custom code page data from - escpos-printer-db. - """ - # Python has not have this builtin? - if encoding.upper() == 'KATAKANA': - return encode_katakana(text) - - return text.encode(encoding, errors=errors) + def get_encoding_name(self, encoding): + # TODO resolve the encoding alias + return encoding.upper() def get_encoding(self, encoding): - # resolve the encoding alias - return encoding.lower() - + return self.data[encoding] CodePages = CodePageManager(CAPABILITIES['encodings']) \ No newline at end of file diff --git a/src/escpos/magicencode.py b/src/escpos/magicencode.py index 5ecaf6c..764b05f 100644 --- a/src/escpos/magicencode.py +++ b/src/escpos/magicencode.py @@ -52,14 +52,14 @@ class Encoder(object): def get_sequence(self, encoding): return int(self.codepages[encoding]) - def get_encoding(self, encoding): + def get_encoding_name(self, encoding): """Given an encoding provided by the user, will return a canonical encoding name; and also validate that the encoding is supported. TODO: Support encoding aliases: pc437 instead of cp437. """ - encoding = CodePages.get_encoding(encoding) + encoding = CodePages.get_encoding_name(encoding) if not encoding in self.codepages: raise ValueError(( 'Encoding "{}" cannot be used for the current profile. ' @@ -72,19 +72,24 @@ class Encoder(object): Gets characters 128-255 for a given code page, as an array. - :param encoding: The name of the encoding. This must be a valid python encoding. + :param encoding: The name of the encoding. This must appear in the CodePage list """ - # Compute the encodable characters as an array (this is the format - # that for non-standard codings come in) - encodable_chars = [u" "] * 128 - for i in range(0, 128): - codepoint = i + 128 - try: - encodable_chars[i] = bytes([codepoint]).decode(encoding) - except UnicodeDecodeError: - # Non-encodable character - pass - return encodable_chars + codepage = CodePages.get_encoding(encoding) + if 'data' in codepage: + encodable_chars = list("".join(codepage['data'])) + assert(len(encodable_chars) == 128) + return encodable_chars + elif 'python_encode' in codepage: + encodable_chars = [u" "] * 128 + for i in range(0, 128): + codepoint = i + 128 + try: + encodable_chars[i] = bytes([codepoint]).decode(codepage['python_encode']) + except UnicodeDecodeError: + # Non-encodable character, just skip it + pass + return encodable_chars + raise LookupError("Can't find a known encoding for {}".format(encoding)) def _get_codepage_char_map(self, encoding): """ Get codepage character map @@ -121,6 +126,29 @@ class Encoder(object): is_encodable = char in available_map return is_ascii or is_encodable + def _encode_char(self, char, charmap): + """ Encode a single character with the given encoding map + + :param char: char to encode + :param charmap: dictionary for mapping characters in this code page + """ + if char in charmap: + return charmap[char] + if ord(char) < 128: + return ord(char) + return ord('?') + + def encode(self, text, encoding, defaultchar='?'): + """ Encode text under the given encoding + + :param text: Text to encode + :param encoding: Encoding name to use (must be defined in capabilities) + :param defaultchar: Fallback for non-encodable characters + """ + codepage_char_map = self.available_characters[encoding] + output_bytes = bytes([self._encode_char(char, codepage_char_map, defaultchar) for char in text]) + return output_bytes + def __encoding_sort_func(self, item): key, index = item return ( @@ -194,7 +222,7 @@ class MagicEncode(object): self.driver = driver self.encoder = encoder or Encoder(driver.profile.get_code_pages()) - self.encoding = self.encoder.get_encoding(encoding) if encoding else None + self.encoding = self.encoder.get_encoding_name(encoding) if encoding else None self.defaultsymbol = defaultsymbol self.disabled = disabled @@ -259,4 +287,4 @@ class MagicEncode(object): six.int2byte(self.encoder.get_sequence(encoding))) if text: - self.driver._raw(CodePages.encode(text, encoding, errors="replace")) + self.driver._raw(self.encoder.encode(text, encoding)) diff --git a/test/test_magicencode.py b/test/test_magicencode.py index d3d3121..665369e 100644 --- a/test/test_magicencode.py +++ b/test/test_magicencode.py @@ -36,7 +36,7 @@ class TestEncoder: @raises(ValueError) def test_get_encoding(self): - Encoder({}).get_encoding('latin1') + Encoder({}).get_encoding_name('latin1') class TestMagicEncode: From 83f926758cce83b081fc6b14026bf8bcd0baeeaf Mon Sep 17 00:00:00 2001 From: Michael Billington Date: Sun, 11 Sep 2016 21:06:44 +1000 Subject: [PATCH 09/11] adjust order in _encode_char to prioritise ASCII; ' ' is used in the character list to flag characters with no known UTF-8 code, better not encode as these --- src/escpos/magicencode.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/escpos/magicencode.py b/src/escpos/magicencode.py index 764b05f..d48d59d 100644 --- a/src/escpos/magicencode.py +++ b/src/escpos/magicencode.py @@ -132,10 +132,10 @@ class Encoder(object): :param char: char to encode :param charmap: dictionary for mapping characters in this code page """ - if char in charmap: - return charmap[char] if ord(char) < 128: return ord(char) + if char in charmap: + return charmap[char] return ord('?') def encode(self, text, encoding, defaultchar='?'): From 7a7ea23628c99790ba73c223906e49f0c2f42cc1 Mon Sep 17 00:00:00 2001 From: Michael Billington Date: Sun, 11 Sep 2016 21:08:04 +1000 Subject: [PATCH 10/11] fixes to arguments for _encode_char --- src/escpos/magicencode.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/escpos/magicencode.py b/src/escpos/magicencode.py index d48d59d..ded60b8 100644 --- a/src/escpos/magicencode.py +++ b/src/escpos/magicencode.py @@ -126,7 +126,7 @@ class Encoder(object): is_encodable = char in available_map return is_ascii or is_encodable - def _encode_char(self, char, charmap): + def _encode_char(self, char, charmap, defaultchar): """ Encode a single character with the given encoding map :param char: char to encode @@ -136,7 +136,7 @@ class Encoder(object): return ord(char) if char in charmap: return charmap[char] - return ord('?') + return ord(defaultchar) def encode(self, text, encoding, defaultchar='?'): """ Encode text under the given encoding From 7b68d97f5f4176bfbf24181ab96906874021f1b9 Mon Sep 17 00:00:00 2001 From: Michael Billington Date: Tue, 13 Sep 2016 20:28:54 +1000 Subject: [PATCH 11/11] test fixes - just case-changes to match code page names, seems to need 'future' pip module --- setup.py | 1 + src/escpos/magicencode.py | 2 +- test/test_function_text.py | 2 +- test/test_magicencode.py | 26 +++++++++++++------------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index d29d7b9..ef7b5b1 100755 --- a/setup.py +++ b/setup.py @@ -113,6 +113,7 @@ setup( 'pyyaml', 'argparse', 'argcomplete', + 'future' ], setup_requires=[ 'setuptools_scm', diff --git a/src/escpos/magicencode.py b/src/escpos/magicencode.py index ded60b8..770703c 100644 --- a/src/escpos/magicencode.py +++ b/src/escpos/magicencode.py @@ -145,7 +145,7 @@ class Encoder(object): :param encoding: Encoding name to use (must be defined in capabilities) :param defaultchar: Fallback for non-encodable characters """ - codepage_char_map = self.available_characters[encoding] + codepage_char_map = self._get_codepage_char_map(encoding) output_bytes = bytes([self._encode_char(char, codepage_char_map, defaultchar) for char in text]) return output_bytes diff --git a/test/test_function_text.py b/test/test_function_text.py index d4de426..7f3869c 100644 --- a/test/test_function_text.py +++ b/test/test_function_text.py @@ -20,7 +20,7 @@ from escpos.printer import Dummy def get_printer(): - return Dummy(magic_encode_args={'disabled': True, 'encoding': 'cp437'}) + return Dummy(magic_encode_args={'disabled': True, 'encoding': 'CP437'}) @given(text=st.text()) diff --git a/test/test_magicencode.py b/test/test_magicencode.py index 665369e..45b0d55 100644 --- a/test/test_magicencode.py +++ b/test/test_magicencode.py @@ -26,13 +26,13 @@ from escpos.exceptions import CharCodeError, Error class TestEncoder: def test_can_encode(self): - assert not Encoder({'cp437': 1}).can_encode('cp437', u'€') - assert Encoder({'cp437': 1}).can_encode('cp437', u'á') + assert not Encoder({'CP437': 1}).can_encode('CP437', u'€') + assert Encoder({'CP437': 1}).can_encode('CP437', u'á') assert not Encoder({'foobar': 1}).can_encode('foobar', 'a') def test_find_suitable_encoding(self): - assert not Encoder({'cp437': 1}).find_suitable_encoding(u'€') - assert Encoder({'cp858': 1}).find_suitable_encoding(u'€') == 'cp858' + assert not Encoder({'CP437': 1}).find_suitable_encoding(u'€') + assert Encoder({'CP858': 1}).find_suitable_encoding(u'€') == 'CP858' @raises(ValueError) def test_get_encoding(self): @@ -51,17 +51,17 @@ class TestMagicEncode: def test_init_from_none(self, driver): encode = MagicEncode(driver, encoding=None) - encode.write_with_encoding('cp858', '€ ist teuro.') + encode.write_with_encoding('CP858', '€ ist teuro.') assert driver.output == b'\x1bt\x13\xd5 ist teuro.' def test_change_from_another(self, driver): - encode = MagicEncode(driver, encoding='cp437') - encode.write_with_encoding('cp858', '€ ist teuro.') + encode = MagicEncode(driver, encoding='CP437') + encode.write_with_encoding('CP858', '€ ist teuro.') assert driver.output == b'\x1bt\x13\xd5 ist teuro.' def test_no_change(self, driver): - encode = MagicEncode(driver, encoding='cp858') - encode.write_with_encoding('cp858', '€ ist teuro.') + encode = MagicEncode(driver, encoding='CP858') + encode.write_with_encoding('CP858', '€ ist teuro.') assert driver.output == b'\xd5 ist teuro.' class TestWrite: @@ -72,14 +72,14 @@ class TestMagicEncode: assert driver.output == b'\x1bt\x0f\xa4 ist teuro.' def test_write_disabled(self, driver): - encode = MagicEncode(driver, encoding='cp437', disabled=True) + encode = MagicEncode(driver, encoding='CP437', disabled=True) encode.write('€ ist teuro.') assert driver.output == b'? ist teuro.' def test_write_no_codepage(self, driver): encode = MagicEncode( - driver, defaultsymbol="_", encoder=Encoder({'cp437': 1}), - encoding='cp437') + driver, defaultsymbol="_", encoder=Encoder({'CP437': 1}), + encoding='CP437') encode.write(u'€ ist teuro.') assert driver.output == b'_ ist teuro.' @@ -87,7 +87,7 @@ class TestMagicEncode: def test(self, driver): encode = MagicEncode(driver) - encode.force_encoding('cp437') + encode.force_encoding('CP437') assert driver.output == b'\x1bt\x00' encode.write('€ ist teuro.')