File: code39.py

package info (click to toggle)
python-barcode 0.15.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 684 kB
  • sloc: python: 1,661; makefile: 23; sh: 9
file content (61 lines) | stat: -rw-r--r-- 1,317 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import string

# Charsets for code 39
REF = (
    tuple(string.digits)
    + tuple(string.ascii_uppercase)
    + ("-", ".", " ", "$", "/", "+", "%")
)
B = "1"
E = "0"
CODES = (
    "101000111011101",
    "111010001010111",
    "101110001010111",
    "111011100010101",
    "101000111010111",
    "111010001110101",
    "101110001110101",
    "101000101110111",
    "111010001011101",
    "101110001011101",
    "111010100010111",
    "101110100010111",
    "111011101000101",
    "101011100010111",
    "111010111000101",
    "101110111000101",
    "101010001110111",
    "111010100011101",
    "101110100011101",
    "101011100011101",
    "111010101000111",
    "101110101000111",
    "111011101010001",
    "101011101000111",
    "111010111010001",
    "101110111010001",
    "101010111000111",
    "111010101110001",
    "101110101110001",
    "101011101110001",
    "111000101010111",
    "100011101010111",
    "111000111010101",
    "100010111010111",
    "111000101110101",
    "100011101110101",
    "100010101110111",
    "111000101011101",
    "100011101011101",
    "100010001000101",
    "100010001010001",
    "100010100010001",
    "101000100010001",
)

EDGE = "100010111011101"
MIDDLE = "0"

# MAP for assigning every symbol (REF) to (reference number, barcode)
MAP = dict(zip(REF, enumerate(CODES)))