Skip to content

Commit f356cc1

Browse files
author
Hugo Osvaldo Barrera
committed
Reformat all the code
1 parent 85fabf8 commit f356cc1

15 files changed

Lines changed: 413 additions & 158 deletions

File tree

barcode/__init__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from barcode.upc import UPCA
1818
from barcode.version import version # noqa: F401
1919

20-
2120
__BARCODE_MAP = {
2221
'ean8': EAN8,
2322
'ean13': EAN13,
@@ -48,8 +47,9 @@ def get(name, code=None, writer=None, options=None):
4847
try:
4948
barcode = __BARCODE_MAP[name.lower()]
5049
except KeyError:
51-
raise BarcodeNotFoundError('The barcode {0!r} you requested is not '
52-
'known.'.format(name))
50+
raise BarcodeNotFoundError(
51+
'The barcode {0!r} you requested is not known.'.format(name)
52+
)
5353
if code is not None:
5454
return barcode(code, writer, **options)
5555
else:
@@ -60,8 +60,15 @@ def get_class(name):
6060
return get_barcode(name)
6161

6262

63-
def generate(name, code, writer=None, output=None, writer_options=None,
64-
text=None, pil=False):
63+
def generate(
64+
name,
65+
code,
66+
writer=None,
67+
output=None,
68+
writer_options=None,
69+
text=None,
70+
pil=False
71+
):
6572
options = writer_options or {}
6673
barcode = get(name, code, writer, options)
6774
if pil:

barcode/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ def to_ascii(self):
3232
return '\n'.join(code)
3333

3434
def __repr__(self):
35-
return '<{0}({1!r})>'.format(self.__class__.__name__,
36-
self.get_fullcode())
35+
return '<{0}({1!r})>'.format(
36+
self.__class__.__name__, self.get_fullcode()
37+
)
3738

3839
def build(self):
3940
raise NotImplementedError

barcode/charsets/code128.py

Lines changed: 184 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,93 @@
33
# Charsets for code 128
44

55
_common = (
6-
' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',',
7-
'-', '.', '/',
6+
' ',
7+
'!',
8+
'"',
9+
'#',
10+
'$',
11+
'%',
12+
'&',
13+
"'",
14+
'(',
15+
')',
16+
'*',
17+
'+',
18+
',',
19+
'-',
20+
'.',
21+
'/',
822
) + tuple(string.digits) + (
9-
':', ';', '<', '=', '>', '?', '@',
23+
':',
24+
';',
25+
'<',
26+
'=',
27+
'>',
28+
'?',
29+
'@',
1030
) + tuple(string.ascii_uppercase) + (
11-
'[', '\\', ']', '^', '_',
31+
'[',
32+
'\\',
33+
']',
34+
'^',
35+
'_',
1236
)
1337

1438
_charset_a = _common + (
15-
'\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08',
16-
'\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f', '\x10', '\x11',
17-
'\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1a',
18-
'\x1b', '\x1c', '\x1d', '\x1e', '\x1f', '\xf3', '\xf2', 'SHIFT', 'TO_C',
19-
'TO_B', '\xf4', '\xf1',
39+
'\x00',
40+
'\x01',
41+
'\x02',
42+
'\x03',
43+
'\x04',
44+
'\x05',
45+
'\x06',
46+
'\x07',
47+
'\x08',
48+
'\x09',
49+
'\x0a',
50+
'\x0b',
51+
'\x0c',
52+
'\x0d',
53+
'\x0e',
54+
'\x0f',
55+
'\x10',
56+
'\x11',
57+
'\x12',
58+
'\x13',
59+
'\x14',
60+
'\x15',
61+
'\x16',
62+
'\x17',
63+
'\x18',
64+
'\x19',
65+
'\x1a',
66+
'\x1b',
67+
'\x1c',
68+
'\x1d',
69+
'\x1e',
70+
'\x1f',
71+
'\xf3',
72+
'\xf2',
73+
'SHIFT',
74+
'TO_C',
75+
'TO_B',
76+
'\xf4',
77+
'\xf1',
2078
)
2179

2280
_charset_b = _common + ('`',) + tuple(string.ascii_lowercase) + (
23-
'{', '|', '}', '~', '\x7f', '\xf3', '\xf2', 'SHIFT', 'TO_C', '\xf4',
24-
'TO_A', '\xf1',
81+
'{',
82+
'|',
83+
'}',
84+
'~',
85+
'\x7f',
86+
'\xf3',
87+
'\xf2',
88+
'SHIFT',
89+
'TO_C',
90+
'\xf4',
91+
'TO_A',
92+
'\xf1',
2593
)
2694

2795
ALL = set(_common + _charset_a + _charset_b)
@@ -30,27 +98,111 @@
3098
C = {'TO_B': 100, 'TO_A': 101, '\xf1': 102}
3199

32100
CODES = (
33-
'11011001100', '11001101100', '11001100110', '10010011000', '10010001100',
34-
'10001001100', '10011001000', '10011000100', '10001100100', '11001001000',
35-
'11001000100', '11000100100', '10110011100', '10011011100', '10011001110',
36-
'10111001100', '10011101100', '10011100110', '11001110010', '11001011100',
37-
'11001001110', '11011100100', '11001110100', '11101101110', '11101001100',
38-
'11100101100', '11100100110', '11101100100', '11100110100', '11100110010',
39-
'11011011000', '11011000110', '11000110110', '10100011000', '10001011000',
40-
'10001000110', '10110001000', '10001101000', '10001100010', '11010001000',
41-
'11000101000', '11000100010', '10110111000', '10110001110', '10001101110',
42-
'10111011000', '10111000110', '10001110110', '11101110110', '11010001110',
43-
'11000101110', '11011101000', '11011100010', '11011101110', '11101011000',
44-
'11101000110', '11100010110', '11101101000', '11101100010', '11100011010',
45-
'11101111010', '11001000010', '11110001010', '10100110000', '10100001100',
46-
'10010110000', '10010000110', '10000101100', '10000100110', '10110010000',
47-
'10110000100', '10011010000', '10011000010', '10000110100', '10000110010',
48-
'11000010010', '11001010000', '11110111010', '11000010100', '10001111010',
49-
'10100111100', '10010111100', '10010011110', '10111100100', '10011110100',
50-
'10011110010', '11110100100', '11110010100', '11110010010', '11011011110',
51-
'11011110110', '11110110110', '10101111000', '10100011110', '10001011110',
52-
'10111101000', '10111100010', '11110101000', '11110100010', '10111011110',
53-
'10111101110', '11101011110', '11110101110', '11010000100', '11010010000',
101+
'11011001100',
102+
'11001101100',
103+
'11001100110',
104+
'10010011000',
105+
'10010001100',
106+
'10001001100',
107+
'10011001000',
108+
'10011000100',
109+
'10001100100',
110+
'11001001000',
111+
'11001000100',
112+
'11000100100',
113+
'10110011100',
114+
'10011011100',
115+
'10011001110',
116+
'10111001100',
117+
'10011101100',
118+
'10011100110',
119+
'11001110010',
120+
'11001011100',
121+
'11001001110',
122+
'11011100100',
123+
'11001110100',
124+
'11101101110',
125+
'11101001100',
126+
'11100101100',
127+
'11100100110',
128+
'11101100100',
129+
'11100110100',
130+
'11100110010',
131+
'11011011000',
132+
'11011000110',
133+
'11000110110',
134+
'10100011000',
135+
'10001011000',
136+
'10001000110',
137+
'10110001000',
138+
'10001101000',
139+
'10001100010',
140+
'11010001000',
141+
'11000101000',
142+
'11000100010',
143+
'10110111000',
144+
'10110001110',
145+
'10001101110',
146+
'10111011000',
147+
'10111000110',
148+
'10001110110',
149+
'11101110110',
150+
'11010001110',
151+
'11000101110',
152+
'11011101000',
153+
'11011100010',
154+
'11011101110',
155+
'11101011000',
156+
'11101000110',
157+
'11100010110',
158+
'11101101000',
159+
'11101100010',
160+
'11100011010',
161+
'11101111010',
162+
'11001000010',
163+
'11110001010',
164+
'10100110000',
165+
'10100001100',
166+
'10010110000',
167+
'10010000110',
168+
'10000101100',
169+
'10000100110',
170+
'10110010000',
171+
'10110000100',
172+
'10011010000',
173+
'10011000010',
174+
'10000110100',
175+
'10000110010',
176+
'11000010010',
177+
'11001010000',
178+
'11110111010',
179+
'11000010100',
180+
'10001111010',
181+
'10100111100',
182+
'10010111100',
183+
'10010011110',
184+
'10111100100',
185+
'10011110100',
186+
'10011110010',
187+
'11110100100',
188+
'11110010100',
189+
'11110010010',
190+
'11011011110',
191+
'11011110110',
192+
'11110110110',
193+
'10101111000',
194+
'10100011110',
195+
'10001011110',
196+
'10111101000',
197+
'10111100010',
198+
'11110101000',
199+
'11110100010',
200+
'10111011110',
201+
'10111101110',
202+
'11101011110',
203+
'11110101110',
204+
'11010000100',
205+
'11010010000',
54206
'11010011100',
55207
)
56208

barcode/charsets/code39.py

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,55 @@
11
import string
22

33
# Charsets for code 39
4-
REF = (tuple(string.digits) + tuple(string.ascii_uppercase) +
5-
('-', '.', ' ', '$', '/', '+', '%'))
4+
REF = (
5+
tuple(string.digits) + tuple(string.ascii_uppercase) +
6+
('-', '.', ' ', '$', '/', '+', '%')
7+
)
68
B = '1'
79
E = '0'
810
CODES = (
9-
'101000111011101', '111010001010111', '101110001010111',
10-
'111011100010101', '101000111010111', '111010001110101',
11-
'101110001110101', '101000101110111', '111010001011101',
12-
'101110001011101', '111010100010111', '101110100010111',
13-
'111011101000101', '101011100010111', '111010111000101',
14-
'101110111000101', '101010001110111', '111010100011101',
15-
'101110100011101', '101011100011101', '111010101000111',
16-
'101110101000111', '111011101010001', '101011101000111',
17-
'111010111010001', '101110111010001', '101010111000111',
18-
'111010101110001', '101110101110001', '101011101110001',
19-
'111000101010111', '100011101010111', '111000111010101',
20-
'100010111010111', '111000101110101', '100011101110101',
21-
'100010101110111', '111000101011101', '100011101011101',
22-
'100010001000101', '100010001010001', '100010100010001',
11+
'101000111011101',
12+
'111010001010111',
13+
'101110001010111',
14+
'111011100010101',
15+
'101000111010111',
16+
'111010001110101',
17+
'101110001110101',
18+
'101000101110111',
19+
'111010001011101',
20+
'101110001011101',
21+
'111010100010111',
22+
'101110100010111',
23+
'111011101000101',
24+
'101011100010111',
25+
'111010111000101',
26+
'101110111000101',
27+
'101010001110111',
28+
'111010100011101',
29+
'101110100011101',
30+
'101011100011101',
31+
'111010101000111',
32+
'101110101000111',
33+
'111011101010001',
34+
'101011101000111',
35+
'111010111010001',
36+
'101110111010001',
37+
'101010111000111',
38+
'111010101110001',
39+
'101110101110001',
40+
'101011101110001',
41+
'111000101010111',
42+
'100011101010111',
43+
'111000111010101',
44+
'100010111010111',
45+
'111000101110101',
46+
'100011101110101',
47+
'100010101110111',
48+
'111000101011101',
49+
'100011101011101',
50+
'100010001000101',
51+
'100010001010001',
52+
'100010100010001',
2353
'101000100010001',
2454
)
2555

barcode/charsets/ean.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
EDGE = '101'
22
MIDDLE = '01010'
33
CODES = {
4-
'A': ('0001101', '0011001', '0010011', '0111101', '0100011',
5-
'0110001', '0101111', '0111011', '0110111', '0001011'),
6-
'B': ('0100111', '0110011', '0011011', '0100001', '0011101',
7-
'0111001', '0000101', '0010001', '0001001', '0010111'),
8-
'C': ('1110010', '1100110', '1101100', '1000010', '1011100',
9-
'1001110', '1010000', '1000100', '1001000', '1110100'),
4+
'A': (
5+
'0001101', '0011001', '0010011', '0111101', '0100011', '0110001',
6+
'0101111', '0111011', '0110111', '0001011'
7+
),
8+
'B': (
9+
'0100111', '0110011', '0011011', '0100001', '0011101', '0111001',
10+
'0000101', '0010001', '0001001', '0010111'
11+
),
12+
'C': (
13+
'1110010', '1100110', '1101100', '1000010', '1011100', '1001110',
14+
'1010000', '1000100', '1001000', '1110100'
15+
),
1016
}
11-
LEFT_PATTERN = ('AAAAAA', 'AABABB', 'AABBAB', 'AABBBA', 'ABAABB',
12-
'ABBAAB', 'ABBBAA', 'ABABAB', 'ABABBA', 'ABBABA')
17+
LEFT_PATTERN = (
18+
'AAAAAA', 'AABABB', 'AABBAB', 'AABBBA', 'ABAABB', 'ABBAAB', 'ABBBAA',
19+
'ABABAB', 'ABABBA', 'ABBABA'
20+
)

0 commit comments

Comments
 (0)