Commit fe0efe3f authored by Matthias Meschede's avatar Matthias Meschede

type hints for barcode

parent 639bb691
......@@ -29,11 +29,16 @@ from inkex import Group, TextElement, Rectangle
(WHITE_BAR, BLACK_BAR, TALL_BAR) = range(3)
TEXT_TEMPLATE = 'font-size:%dpx;text-align:center;text-anchor:middle;'
try:
from typing import Optional
except ImportError:
pass
class Barcode(object):
"""Provide a base class for all barcode renderers"""
default_height = 30
font_size = 9
name = None
name = None # type: Optional[str]
def error(self, text, msg):
"""Cause an error to be reported"""
......
......@@ -22,6 +22,11 @@ Some basic common code shared between EAN and UCP generators.
from .Base import Barcode, TEXT_POS_TOP
try:
from typing import Optional, List, Dict
except ImportError:
pass
MAPPING = [
# Left side of barcode Family '0'
["0001101", "0011001", "0010011", "0111101", "0100011",
......@@ -37,10 +42,10 @@ FAMILIES = ('000000', '001011', '001101', '001110', '010011',
class EanBarcode(Barcode):
"""Simple base class for all EAN type barcodes"""
lengths = None
length = None
checks = []
extras = {}
lengths = None # type: Optional[List[int]]
length = None # type: Optional[int]
checks = [] # type: List[int]
extras = {} # type: Dict[int, str]
magic = 10
guard_bar = '202'
center_bar = '02020'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment