Skip to content

Commit 07b2275

Browse files
committed
Prefer expansion instead of concatenation
Quite a bit simpler to read.
1 parent 8cdefd7 commit 07b2275

2 files changed

Lines changed: 55 additions & 61 deletions

File tree

barcode/charsets/code128.py

Lines changed: 54 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,40 @@
33
# Charsets for code 128
44

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

44-
_charset_a = _common + (
38+
_charset_a = (
39+
*_common,
4540
"\x00",
4641
"\x01",
4742
"\x02",
@@ -51,11 +46,11 @@
5146
"\x06",
5247
"\x07",
5348
"\x08",
54-
"\x09",
55-
"\x0a",
49+
"\t",
50+
"\n",
5651
"\x0b",
5752
"\x0c",
58-
"\x0d",
53+
"\r",
5954
"\x0e",
6055
"\x0f",
6156
"\x10",
@@ -74,33 +69,31 @@
7469
"\x1d",
7570
"\x1e",
7671
"\x1f",
77-
"\xf3",
78-
"\xf2",
72+
"ó",
73+
"ò",
7974
"SHIFT",
8075
"TO_C",
8176
"TO_B",
82-
"\xf4",
83-
"\xf1",
77+
"ô",
78+
"ñ",
8479
)
8580

8681
_charset_b = (
87-
_common
88-
+ ("`",)
89-
+ tuple(string.ascii_lowercase)
90-
+ (
91-
"{",
92-
"|",
93-
"}",
94-
"~",
95-
"\x7f",
96-
"\xf3",
97-
"\xf2",
98-
"SHIFT",
99-
"TO_C",
100-
"\xf4",
101-
"TO_A",
102-
"\xf1",
103-
)
82+
*_common,
83+
"`",
84+
*tuple(string.ascii_lowercase),
85+
"{",
86+
"|",
87+
"}",
88+
"~",
89+
"\x7f",
90+
"ó",
91+
"ò",
92+
"SHIFT",
93+
"TO_C",
94+
"ô",
95+
"TO_A",
96+
"ñ",
10497
)
10598

10699
ALL = set(_common + _charset_a + _charset_b)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ select = [
3434
"TCH",
3535
"INT",
3636
"ERA",
37+
"RUF",
3738
]
3839
target-version = "py37"
3940

0 commit comments

Comments
 (0)