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 <microjoe@microjoe.org>
This commit is contained in:
Romain Porte 2019-10-07 07:43:23 +02:00
parent 142fc4af71
commit cb30d7a881
35 changed files with 3 additions and 147 deletions

View File

@ -27,25 +27,6 @@ Style-Guide
When writing code please try to stick to these rules. 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 <https://docs.python.org/3/howto/pyporting.html>`_ 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 PEP8
^^^^ ^^^^
The entire codebase adheres to the rules of PEP8. The entire codebase adheres to the rules of PEP8.

View File

@ -194,8 +194,8 @@ An USB-printer could be defined by::
Printing text right 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 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 the right codepage and then send the encoded data to the printer. If this feature does not work, please try to

View File

@ -1,7 +1,6 @@
"""Prints code page tables. """Prints code page tables.
""" """
from __future__ import print_function
import six import six
import sys import sys

View File

@ -13,7 +13,6 @@
# Check out his github: https://github.com/AdamWhitcroft/climacons # Check out his github: https://github.com/AdamWhitcroft/climacons
from __future__ import print_function
from datetime import datetime from datetime import datetime
import calendar import calendar
import urllib import urllib

View File

@ -63,10 +63,6 @@ tests_require =
verbosity=3 verbosity=3
with-doctest=1 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] [flake8]
exclude = .git,.tox,.github,.eggs,__pycache__,doc/conf.py,build,dist,capabilities-data,test,src/escpos/constants.py exclude = .git,.tox,.github,.eggs,__pycache__,doc/conf.py,build,dist,capabilities-data,test,src/escpos/constants.py
max-line-length = 120 max-line-length = 120

View File

@ -22,10 +22,6 @@ setuptools_scm_template = """\
# coding: utf-8 # coding: utf-8
# file generated by setuptools_scm # file generated by setuptools_scm
# don't change, don't track in version control # 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}' version = '{version}'
""" """

View File

@ -2,10 +2,6 @@
""" """
python-escpos enables you to manipulate escpos-printers 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"] __all__ = ["constants", "escpos", "exceptions", "printer"]

View File

@ -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 import argparse
try: try:

View File

@ -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 os
import appdirs import appdirs

View File

@ -11,10 +11,6 @@ moved to `capabilities` as in `escpos-php by @mike42 <https://github.com/mike42/
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import six import six

View File

@ -10,10 +10,6 @@ This module contains the abstract base class :py:class:`Escpos`.
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import qrcode import qrcode
import textwrap import textwrap

View File

@ -25,11 +25,6 @@ Result/Exit codes:
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
class Error(Exception): class Error(Exception):
""" Base class for ESC/POS errors """ """ Base class for ESC/POS errors """

View File

@ -8,10 +8,6 @@ This module contains the image format handler :py:class:`EscposImage`.
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import math import math
from PIL import Image, ImageOps from PIL import Image, ImageOps

View File

@ -4,11 +4,6 @@
I doubt that this currently works correctly. I doubt that this currently works correctly.
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
try: try:
import jaconv import jaconv

View File

@ -12,10 +12,6 @@ The code is based on the encoding-code in py-xml-escpos by @fvdsn.
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from builtins import bytes from builtins import bytes
from .constants import CODEPAGE_CHANGE from .constants import CODEPAGE_CHANGE

View File

@ -8,7 +8,6 @@
:license: MIT :license: MIT
""" """
from __future__ import absolute_import, division, print_function, unicode_literals
import serial import serial
import socket import socket

View File

@ -7,10 +7,6 @@
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from nose.tools import raises from nose.tools import raises

View File

@ -2,10 +2,6 @@
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import os import os
import sys import sys

View File

@ -1,8 +1,4 @@
#!/usr/bin/python #!/usr/bin/python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer import escpos.printer as printer
from escpos.constants import BARCODE_TYPE_A, BARCODE_TYPE_B from escpos.constants import BARCODE_TYPE_A, BARCODE_TYPE_B

View File

@ -1,8 +1,4 @@
#!/usr/bin/python #!/usr/bin/python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer import escpos.printer as printer
from escpos.exceptions import CashDrawerError from escpos.exceptions import CashDrawerError

View File

@ -1,10 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer import escpos.printer as printer
import pytest import pytest

View File

@ -1,7 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import six import six

View File

@ -7,10 +7,6 @@
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import pytest import pytest

View File

@ -7,10 +7,6 @@
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer import escpos.printer as printer

View File

@ -7,10 +7,6 @@
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer import escpos.printer as printer

View File

@ -7,10 +7,6 @@
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from nose.tools import raises from nose.tools import raises
import pytest import pytest

View File

@ -8,10 +8,6 @@
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import pytest import pytest
import mock import mock

View File

@ -1,7 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import six import six

View File

@ -1,8 +1,4 @@
#!/usr/bin/python #!/usr/bin/python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer import escpos.printer as printer
import pytest import pytest

View File

@ -7,10 +7,6 @@
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import pytest import pytest
import mock import mock

View File

@ -7,10 +7,6 @@
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer import escpos.printer as printer

View File

@ -8,10 +8,6 @@
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import pytest import pytest
from nose.tools import raises, assert_raises from nose.tools import raises, assert_raises

View File

@ -8,10 +8,6 @@
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import six import six

View File

@ -7,10 +7,6 @@
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import pytest import pytest
import escpos import escpos

View File

@ -7,10 +7,6 @@
:license: MIT :license: MIT
""" """
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer import escpos.printer as printer
import escpos.escpos as escpos import escpos.escpos as escpos