Skip to content

Commit

Permalink
Remove shebangs, use triple double-quotes and add greek example every…
Browse files Browse the repository at this point in the history
…where
  • Loading branch information
Mickaël Schoentgen committed May 1, 2018
1 parent a5708ec commit 403339b
Show file tree
Hide file tree
Showing 40 changed files with 130 additions and 160 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Phillip 'vIiRuS' Thelen [http://pherth.net]
- Fix setup installation

Alexandros Kokkalas
-Print Greek Characters
- Print Greek characters example
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MIT License
Copyright (c) 2016-2017, Mickaël 'Tiger-222' Schoentgen
Copyright (c) 2016-2018, Mickaël 'Tiger-222' Schoentgen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@

# General information about the project.
project = 'ThermalPrinter'
copyright = '2016-2017, Tiger-222'
copyright = '2016-2018, Tiger-222'
author = 'Tiger-222'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1.7'
version = '0.1.8'
# The full version, including alpha/beta/rc tags.
release = 'latest'

Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

from types import FunctionType
Expand Down
1 change: 0 additions & 1 deletion tests/test__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
9 changes: 4 additions & 5 deletions tests/test_barcode.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/usr/bin/env python3
# coding: utf-8
''' UPC_A == UPC_E, skipping the last one.
""" UPC_A == UPC_E, skipping the last one.
JAN13 == EAN13, skipping the last one.
JAN8 == EAN8, skipping the last one.
'''
"""

import pytest

from thermalprinter.constants import BarCode
from thermalprinter.exceptions import ThermalPrinterConstantError, \
ThermalPrinterValueError
from thermalprinter.exceptions import (ThermalPrinterConstantError,
ThermalPrinterValueError)


def test_empty_values(printer):
Expand Down
1 change: 0 additions & 1 deletion tests/test_barcode_height.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_barcode_left_margin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_barcode_position.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_barcode_width.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_bold.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8


Expand Down
1 change: 0 additions & 1 deletion tests/test_char_spacing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_charset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_chinese.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8


Expand Down
1 change: 0 additions & 1 deletion tests/test_chinese_format.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_codepage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_double_height.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8


Expand Down
1 change: 0 additions & 1 deletion tests/test_double_width.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8


Expand Down
1 change: 0 additions & 1 deletion tests/test_feed.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_image.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

from os.path import abspath, dirname, realpath
Expand Down
1 change: 0 additions & 1 deletion tests/test_inverse.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8


Expand Down
1 change: 0 additions & 1 deletion tests/test_justify.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_left_margin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_line_spacing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_methods.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

from inspect import getargspec, ArgSpec
Expand Down
1 change: 0 additions & 1 deletion tests/test_online_offline.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8


Expand Down
8 changes: 6 additions & 2 deletions tests/test_out.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3
# coding: utf-8

from thermalprinter.constants import Chinese
from thermalprinter.constants import Chinese, CodePage


def test_print_one_line(printer):
Expand Down Expand Up @@ -34,6 +33,11 @@ def test_print_one_line_chinese(printer):
assert printer._chinese_format is Chinese.GBK


def test_print_one_line_greek(printer):
printer.out('Στην υγειά μας!', codepage=CodePage.CP737)
assert printer._codepage is CodePage.CP437


def test_print_one_line_bool(printer):
printer.out(True)

Expand Down
1 change: 0 additions & 1 deletion tests/test_rotate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8


Expand Down
1 change: 0 additions & 1 deletion tests/test_size.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_sleep_wake.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_strike.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8


Expand Down
1 change: 0 additions & 1 deletion tests/test_to_bytes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

from thermalprinter.constants import CodePage
Expand Down
1 change: 0 additions & 1 deletion tests/test_underline.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_upside_down.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8


Expand Down
17 changes: 8 additions & 9 deletions thermalprinter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
# coding: utf-8
''' Python module to manage the DP-EH600 thermal printer.
""" Python module to manage the DP-EH600 thermal printer.
This module is maintained by Mickaël Schoentgen <contact@tiger-222.fr>.
Based on the work of Phil Burgess and Fried/Ladyada (Adafruit).
Expand All @@ -13,25 +12,25 @@
You can always get the latest version of this module at:
https://github.com/BoboTiG/thermalprinter
If that URL should fail, try contacting the author.
'''
"""

from .constants import BarCode, BarCodePosition, CharSet, Chinese, Command, \
CodePage
from .constants import (BarCode, BarCodePosition, CharSet, Chinese, CodePage,
Command)
from .exceptions import ThermalPrinterError
from .thermalprinter import ThermalPrinter

__version__ = '0.1.7'
__version__ = '0.1.8'
__author__ = 'Mickaël Schoentgen'
__copyright__ = '''
Copyright (c) 2016-2017, Mickaël 'Tiger-222' Schoentgen
__copyright__ = """
Copyright (c) 2016-2018, Mickaël 'Tiger-222' Schoentgen
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee or royalty is hereby
granted, provided that the above copyright notice appear in all copies
and that both that copyright notice and this permission notice appear
in supporting documentation or portions thereof, including
modifications, that you make.
'''
"""
__license__ = 'MIT'
__all__ = ['BarCode', 'BarCodePosition', 'CharSet', 'Chinese', 'Command',
'CodePage', 'ThermalPrinter', 'ThermalPrinterError']
31 changes: 15 additions & 16 deletions thermalprinter/constants.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env python3
# coding: utf-8
''' This is part of the Python's module to manage the DP-EH600 thermal printer.
""" This is part of the Python's module to manage the DP-EH600 thermal printer.
Source: https://github.com/BoboTiG/thermalprinter
'''
"""

from enum import Enum

Expand All @@ -11,7 +10,7 @@


class BarCode(Enum):
''' Available bar code types: '''
""" Available bar code types: """

# (code, (min len(text), max len(text)), allowed_chars)
UPC_A = (65, (11, 12), 0)
Expand All @@ -26,25 +25,25 @@ class BarCode(Enum):
CODE93 = (72, (1, 255), 3)
CODE128 = (73, (2, 255), 3)

def __str__(self):
def __repr__(self):
return '{:<7} value: {}, {:>2} <= len(data) <= {:>3}'.format(
self.name, self.value[0], self.value[1][0], self.value[1][1])


class BarCodePosition(Enum):
''' Available bar code positions: '''
""" Available bar code positions: """

HIDDEN = 0
ABOVE = 1
BELOW = 2
BOTH = 3

def __str__(self):
def __repr__(self):
return '{:<6} value: {}'.format(self.name, self.value)


class CharSet(Enum):
''' Available internal character sets: '''
""" Available internal character sets: """

# pylint: disable=invalid-name

Expand All @@ -65,23 +64,23 @@ class CharSet(Enum):
SLOVENIA = 14
CHINA = 15

def __str__(self):
def __repr__(self):
return '{:<14} value: {:>2}'.format(self.name, self.value)


class Chinese(Enum):
''' Available Chinese formats: '''
""" Available Chinese formats: """

GBK = 0
UTF_8 = 1
BIG5 = 3

def __str__(self):
def __repr__(self):
return '{:<5} value: {}'.format(self.name, self.value)


class CodePage(Enum):
''' Available character code tables: '''
""" Available character code tables: """

# (code, description)
CP437 = (0, 'the United States of America, European standard')
Expand Down Expand Up @@ -129,13 +128,13 @@ class CodePage(Enum):
CP856 = (46, '')
CP874 = (47, '')

def __str__(self):
def __repr__(self):
return '{:<11} value: {:>2}, desc: {}'.format(
self.name, self.value[0], self.value[1])


class CodePageConverted(Enum):
''' Some code pages are not available in Python, use these instead: '''
""" Some code pages are not available in Python, use these instead: """

# (unsupported encoding, best replacement)
MIK = 'iso8859-5'
Expand All @@ -146,12 +145,12 @@ class CodePageConverted(Enum):
THAI = 'iso8859-11'
THAI2 = 'utf_8'

def __str__(self):
def __repr__(self):
return '{:<11} fallback: {:>2}'.format(self.name, self.value)


class Command(Enum):
''' Codes used to send commands. '''
""" Codes used to send commands. """

# pylint: disable=invalid-name

Expand Down
13 changes: 6 additions & 7 deletions thermalprinter/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#!/usr/bin/env python3
# coding: utf-8
''' This is part of the Python's module to manage the DP-EH600 thermal printer.
""" This is part of the Python's module to manage the DP-EH600 thermal printer.
Source: https://github.com/BoboTiG/thermalprinter
'''
"""


class ThermalPrinterError(Exception):
''' Error handling class. '''
""" Error handling class. """


class ThermalPrinterAttributeError(ThermalPrinterError):
''' Attribute error handling class. '''
""" Attribute error handling class. """


class ThermalPrinterConstantError(ThermalPrinterError):
''' Constant error handling class. '''
""" Constant error handling class. """


class ThermalPrinterValueError(ThermalPrinterError):
''' Value error handling class. '''
""" Value error handling class. """
Loading

0 comments on commit 403339b

Please sign in to comment.