Fix regexp syntax warnings in localedata/unicode-gen/ctype_compatibility.py

Fix these:

$ python -m py_compile ./ctype_compatibility.py
./ctype_compatibility.py:146: SyntaxWarning: invalid escape sequence '\)'

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
Mike FABIAN 2023-09-14 18:20:57 +02:00
parent 973fe93a56
commit ba017b4f9d

View file

@ -89,12 +89,12 @@ def extract_character_classes(filename):
'tolower', 'tolower',
'totitle']: 'totitle']:
match = re.match(r'^(' match = re.match(r'^('
+'(?:(?:class|map)\s+")' r'(?:(?:class|map)\s+")'
+re.escape(char_class)+ +re.escape(char_class)+
'(?:";)\s+' r'(?:";)\s+'
+'|' r'|'
+re.escape(char_class)+'\s+' +re.escape(char_class)+r'\s+'+
+')', line) r')', line)
if match: if match:
if char_class not in ctype_dict: if char_class not in ctype_dict:
ctype_dict[char_class] = [] ctype_dict[char_class] = []
@ -117,8 +117,8 @@ def process_chars(char_class_list, code_point_line):
continue continue
match = re.match( match = re.match(
r'^<U(?P<codepoint1>[0-9A-F]{4,8})>' r'^<U(?P<codepoint1>[0-9A-F]{4,8})>'
+'\.\.'+ r'\.\.'
'<U(?P<codepoint2>[0-9A-F]{4,8})>$', r'<U(?P<codepoint2>[0-9A-F]{4,8})>$',
code_points) code_points)
if match: # <Uxxxx>..<Uxxxx> if match: # <Uxxxx>..<Uxxxx>
for codepoint in range( for codepoint in range(
@ -128,8 +128,8 @@ def process_chars(char_class_list, code_point_line):
continue continue
match = re.match( match = re.match(
r'^<U(?P<codepoint1>[0-9A-F]{4,8})>' r'^<U(?P<codepoint1>[0-9A-F]{4,8})>'
+'\.\.\(2\)\.\.'+ r'\.\.\(2\)\.\.'
'<U(?P<codepoint2>[0-9A-F]{4,8})>$', r'<U(?P<codepoint2>[0-9A-F]{4,8})>$',
code_points) code_points)
if match: # <Uxxxx>..(2)..<Uxxxx> if match: # <Uxxxx>..(2)..<Uxxxx>
for codepoint in range( for codepoint in range(
@ -140,10 +140,10 @@ def process_chars(char_class_list, code_point_line):
continue continue
match = re.match( match = re.match(
r'^\(' r'^\('
+'<U(?P<codepoint1>[0-9A-F]{4,8})>' r'<U(?P<codepoint1>[0-9A-F]{4,8})>'
+','+ r','
'<U(?P<codepoint2>[0-9A-F]{4,8})>' r'<U(?P<codepoint2>[0-9A-F]{4,8})>'
+'\)$', r'\)$',
code_points) code_points)
if match: # (<Uxxxx>,<Uxxxx>) if match: # (<Uxxxx>,<Uxxxx>)
char_class_list.append(( char_class_list.append((