From cb30d7a8819abc258b2340dcf141e04798e3a3d0 Mon Sep 17 00:00:00 2001 From: Romain Porte Date: Mon, 7 Oct 2019 07:43:23 +0200 Subject: [PATCH] drop Python 2.7 support Python 2.7 EOL is arriving on 2020-01-01: https://pythonclock.org/ This will allow us to use Python 3 only libraries, like python-barcode, which can maintain a reduced, simpler codebase, due to only one version to support. Closes #371. Signed-off-by: Romain Porte --- CONTRIBUTING.rst | 19 ------------------- doc/user/usage.rst | 6 +++--- examples/codepage_tables.py | 1 - examples/weather.py | 1 - setup.cfg | 4 ---- setup.py | 4 ---- src/escpos/__init__.py | 4 ---- src/escpos/cli.py | 4 ---- src/escpos/config.py | 4 ---- src/escpos/constants.py | 4 ---- src/escpos/escpos.py | 4 ---- src/escpos/exceptions.py | 5 ----- src/escpos/image.py | 4 ---- src/escpos/katakana.py | 5 ----- src/escpos/magicencode.py | 4 ---- src/escpos/printer.py | 1 - test/test_abstract_base_class.py | 4 ---- test/test_cli.py | 4 ---- test/test_function_barcode.py | 4 ---- test/test_function_cashdraw.py | 4 ---- test/test_function_check_barcode.py | 4 ---- test/test_function_cut.py | 4 ---- test/test_function_image.py | 4 ---- test/test_function_linedisplay.py | 4 ---- test/test_function_panel_button.py | 4 ---- test/test_function_qr_native.py | 4 ---- test/test_function_qr_non-native.py | 4 ---- test/test_function_set.py | 4 ---- test/test_function_softbarcode.py | 4 ---- test/test_function_text.py | 4 ---- test/test_load_module.py | 4 ---- test/test_magicencode.py | 4 ---- test/test_printer_file.py | 4 ---- test/test_raise_arbitrary_error.py | 4 ---- test/test_with_statement.py | 4 ---- 35 files changed, 3 insertions(+), 147 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index f14bc2b..dd0bb9b 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -27,25 +27,6 @@ Style-Guide When writing code please try to stick to these rules. -Python 2 and 3 -^^^^^^^^^^^^^^ -We have rewritten the code in order to maintain compatibility with both Python 2 and Python 3. -In order to ensure that we do not miss any accidental degradation, please add these imports to the top -of every file of code: - -.. code-block:: Python - - from __future__ import absolute_import - 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 -that the :py:meth:`~escpos.escpos.Escpos._raw`-method only accepts byte-strings. -Often you can achieve compatibility quite easily with a tool from the `six`-package. - PEP8 ^^^^ The entire codebase adheres to the rules of PEP8. diff --git a/doc/user/usage.rst b/doc/user/usage.rst index 853484f..21537a8 100644 --- a/doc/user/usage.rst +++ b/doc/user/usage.rst @@ -84,7 +84,7 @@ to. :: p = printer.Serial("/dev/tty0") - + # on a Windows OS serial devices are typically accessible as COM p = printer.Serial("COM1") @@ -194,8 +194,8 @@ An USB-printer could be defined by:: Printing text right ------------------- -Python-escpos is designed to accept unicode. So make sure that you use ``u'strings'`` or import ``unicode_literals`` -from ``__future__`` if you are on Python 2. On Python 3 you should be fine. + +Python-escpos is designed to accept unicode. For normal usage you can simply pass your text to the printers ``text()``-function. It will automatically guess the right codepage and then send the encoded data to the printer. If this feature does not work, please try to diff --git a/examples/codepage_tables.py b/examples/codepage_tables.py index a071bf5..5a10ee4 100644 --- a/examples/codepage_tables.py +++ b/examples/codepage_tables.py @@ -1,7 +1,6 @@ """Prints code page tables. """ -from __future__ import print_function import six import sys diff --git a/examples/weather.py b/examples/weather.py index 31ef488..e03b19f 100644 --- a/examples/weather.py +++ b/examples/weather.py @@ -13,7 +13,6 @@ # Check out his github: https://github.com/AdamWhitcroft/climacons -from __future__ import print_function from datetime import datetime import calendar import urllib diff --git a/setup.cfg b/setup.cfg index bf55928..a2dcf83 100644 --- a/setup.cfg +++ b/setup.cfg @@ -63,10 +63,6 @@ tests_require = verbosity=3 with-doctest=1 -[bdist_wheel] -# This flag says that the code is written to work on both Python 2 and Python 3. -universal=1 - [flake8] exclude = .git,.tox,.github,.eggs,__pycache__,doc/conf.py,build,dist,capabilities-data,test,src/escpos/constants.py max-line-length = 120 diff --git a/setup.py b/setup.py index 0d98b58..898a51b 100755 --- a/setup.py +++ b/setup.py @@ -22,10 +22,6 @@ setuptools_scm_template = """\ # coding: utf-8 # file generated by setuptools_scm # don't change, don't track in version control -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals version = '{version}' """ diff --git a/src/escpos/__init__.py b/src/escpos/__init__.py index 3fbc808..73e7644 100644 --- a/src/escpos/__init__.py +++ b/src/escpos/__init__.py @@ -2,10 +2,6 @@ """ python-escpos enables you to manipulate escpos-printers """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals __all__ = ["constants", "escpos", "exceptions", "printer"] diff --git a/src/escpos/cli.py b/src/escpos/cli.py index 665e3b8..1b0db9e 100644 --- a/src/escpos/cli.py +++ b/src/escpos/cli.py @@ -9,10 +9,6 @@ It requires you to have a configuration file. See documentation for details. """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals import argparse try: diff --git a/src/escpos/config.py b/src/escpos/config.py index 7528934..e2dd789 100644 --- a/src/escpos/config.py +++ b/src/escpos/config.py @@ -4,10 +4,6 @@ This module contains the implentations of abstract base class :py:class:`Config` """ -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals import os import appdirs diff --git a/src/escpos/constants.py b/src/escpos/constants.py index 88b91f5..fc30bce 100644 --- a/src/escpos/constants.py +++ b/src/escpos/constants.py @@ -11,10 +11,6 @@ moved to `capabilities` as in `escpos-php by @mike42