Skip to content

Commit c30056a

Browse files
committed
lint : fix
1 parent d53240c commit c30056a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

scripts/gen-unicode-data.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import regex
2-
import struct
2+
33

44
def cpt_to_utf8_str(cpt):
55
if cpt <= 0xFF:
@@ -11,13 +11,15 @@ def cpt_to_utf8_str(cpt):
1111
else:
1212
return bytes([cpt & 0xFF, (cpt >> 8) & 0xFF, (cpt >> 16) & 0xFF, cpt >> 24])
1313

14+
1415
def is_match(codepoint, regex_expr):
1516
try:
1617
res = regex.match(regex_expr, cpt_to_utf8_str(codepoint).decode('utf-32'))
1718
return res is not None
18-
except:
19+
except Exception:
1920
return False
2021

22+
2123
def get_matches(regex_expr):
2224
unicode_ranges = []
2325
current_range = None
@@ -37,6 +39,7 @@ def get_matches(regex_expr):
3739

3840
return unicode_ranges
3941

42+
4043
def print_cat(cat, ranges):
4144
print("const std::vector<std::pair<uint32_t, uint32_t>> unicode_ranges_{} = {{".format(cat))
4245
cnt = 0
@@ -53,11 +56,11 @@ def print_cat(cat, ranges):
5356
print("};")
5457
print("")
5558

59+
5660
print_cat("number", get_matches(r'\p{N}'))
5761
print_cat("letter", get_matches(r'\p{L}'))
5862
print_cat("whitespace", get_matches(r'\p{Z}'))
5963
print_cat("accent_mark", get_matches(r'\p{M}'))
6064
print_cat("punctuation", get_matches(r'\p{P}'))
6165
print_cat("symbol", get_matches(r'\p{S}'))
6266
print_cat("control", get_matches(r'\p{C}'))
63-

0 commit comments

Comments
 (0)