mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
tools: Use raw strings for regexps in python scripts (fixes #3677)
Starting with Python 3.12, use of invalid escape sequences in strings is reported as a SyntaxWarning and will become a SyntaxError at a later point. Regular expressions use the backslash character a lot, which result in warnings of this kind. Python docs recommend to generally use raw strings for this purpose.
This commit is contained in:
committed by
Marshall Greenblatt
parent
744a194a6e
commit
81a0648ee1
@ -273,7 +273,7 @@ def format_translation_includes(header, body):
|
||||
result += '#include "libcef_dll/template_util.h"\n'
|
||||
|
||||
# identify what CppToC classes are being used
|
||||
p = re.compile('([A-Za-z0-9_]{1,})CppToC')
|
||||
p = re.compile(r'([A-Za-z0-9_]{1,})CppToC')
|
||||
list = sorted(set(p.findall(body)))
|
||||
for item in list:
|
||||
directory = ''
|
||||
@ -286,7 +286,7 @@ def format_translation_includes(header, body):
|
||||
get_capi_name(item[3:], False)+'_cpptoc.h"\n'
|
||||
|
||||
# identify what CToCpp classes are being used
|
||||
p = re.compile('([A-Za-z0-9_]{1,})CToCpp')
|
||||
p = re.compile(r'([A-Za-z0-9_]{1,})CToCpp')
|
||||
list = sorted(set(p.findall(body)))
|
||||
for item in list:
|
||||
directory = ''
|
||||
@ -355,21 +355,21 @@ def dict_to_str(dict):
|
||||
|
||||
|
||||
# regex for matching comment-formatted attributes
|
||||
_cre_attrib = '/\*--cef\(([A-Za-z0-9_ ,=:\n]{0,})\)--\*/'
|
||||
_cre_attrib = r'/\*--cef\(([A-Za-z0-9_ ,=:\n]{0,})\)--\*/'
|
||||
# regex for matching class and function names
|
||||
_cre_cfname = '([A-Za-z0-9_]{1,})'
|
||||
_cre_cfname = r'([A-Za-z0-9_]{1,})'
|
||||
# regex for matching class and function names including path separators
|
||||
_cre_cfnameorpath = '([A-Za-z0-9_\/]{1,})'
|
||||
_cre_cfnameorpath = r'([A-Za-z0-9_\/]{1,})'
|
||||
# regex for matching typedef value and name combination
|
||||
_cre_typedef = '([A-Za-z0-9_<>:,\*\&\s]{1,})'
|
||||
_cre_typedef = r'([A-Za-z0-9_<>:,\*\&\s]{1,})'
|
||||
# regex for matching function return value and name combination
|
||||
_cre_func = '([A-Za-z][A-Za-z0-9_<>:,\*\&\s]{1,})'
|
||||
_cre_func = r'([A-Za-z][A-Za-z0-9_<>:,\*\&\s]{1,})'
|
||||
# regex for matching virtual function modifiers + arbitrary whitespace
|
||||
_cre_vfmod = '([\sA-Za-z0-9_]{0,})'
|
||||
_cre_vfmod = r'([\sA-Za-z0-9_]{0,})'
|
||||
# regex for matching arbitrary whitespace
|
||||
_cre_space = '[\s]{1,}'
|
||||
_cre_space = r'[\s]{1,}'
|
||||
# regex for matching optional virtual keyword
|
||||
_cre_virtual = '(?:[\s]{1,}virtual){0,1}'
|
||||
_cre_virtual = r'(?:[\s]{1,}virtual){0,1}'
|
||||
|
||||
# Simple translation types. Format is:
|
||||
# 'cpp_type' : ['capi_type', 'capi_default_value']
|
||||
@ -437,11 +437,11 @@ def get_function_impls(content, ident, has_impl=True):
|
||||
content = content.replace('NO_SANITIZE("cfi-icall")\n', '')
|
||||
|
||||
# extract the functions
|
||||
find_regex = '\n' + _cre_func + '\((.*?)\)([A-Za-z0-9_\s]{0,})'
|
||||
find_regex = r'\n' + _cre_func + r'\((.*?)\)([A-Za-z0-9_\s]{0,})'
|
||||
if has_impl:
|
||||
find_regex += '\{(.*?)\n\}'
|
||||
find_regex += r'\{(.*?)\n\}'
|
||||
else:
|
||||
find_regex += '(;)'
|
||||
find_regex += r'(;)'
|
||||
p = re.compile(find_regex, re.MULTILINE | re.DOTALL)
|
||||
list = p.findall(content)
|
||||
|
||||
@ -603,7 +603,7 @@ class obj_header:
|
||||
data = data.replace("> >", ">>")
|
||||
|
||||
# extract global typedefs
|
||||
p = re.compile('\ntypedef' + _cre_space + _cre_typedef + ';',
|
||||
p = re.compile(r'\ntypedef' + _cre_space + _cre_typedef + r';',
|
||||
re.MULTILINE | re.DOTALL)
|
||||
list = p.findall(data)
|
||||
if len(list) > 0:
|
||||
@ -617,7 +617,7 @@ class obj_header:
|
||||
self.typedefs.append(obj_typedef(self, filename, value, alias))
|
||||
|
||||
# extract global functions
|
||||
p = re.compile('\n' + _cre_attrib + '\n' + _cre_func + '\((.*?)\)',
|
||||
p = re.compile(r'\n' + _cre_attrib + r'\n' + _cre_func + r'\((.*?)\)',
|
||||
re.MULTILINE | re.DOTALL)
|
||||
list = p.findall(data)
|
||||
if len(list) > 0:
|
||||
@ -631,17 +631,17 @@ class obj_header:
|
||||
obj_function(self, filename, attrib, retval, argval, comment))
|
||||
|
||||
# extract includes
|
||||
p = re.compile('\n#include \"include/' + _cre_cfnameorpath + '.h')
|
||||
p = re.compile(r'\n#include \"include/' + _cre_cfnameorpath + r'.h')
|
||||
includes = p.findall(data)
|
||||
|
||||
# extract forward declarations
|
||||
p = re.compile('\nclass' + _cre_space + _cre_cfname + ';')
|
||||
p = re.compile(r'\nclass' + _cre_space + _cre_cfname + r';')
|
||||
forward_declares = p.findall(data)
|
||||
|
||||
# extract empty classes
|
||||
p = re.compile('\n' + _cre_attrib + '\nclass' + _cre_space + _cre_cfname +
|
||||
_cre_space + ':' + _cre_space + 'public' + _cre_virtual +
|
||||
_cre_space + _cre_cfname + _cre_space + '{};',
|
||||
p = re.compile(r'\n' + _cre_attrib + r'\nclass' + _cre_space + _cre_cfname +
|
||||
_cre_space + r':' + _cre_space + r'public' + _cre_virtual +
|
||||
_cre_space + _cre_cfname + _cre_space + r'{};',
|
||||
re.MULTILINE | re.DOTALL)
|
||||
list = p.findall(data)
|
||||
if len(list) > 0:
|
||||
@ -663,9 +663,9 @@ class obj_header:
|
||||
data = p.sub('', data)
|
||||
|
||||
# extract classes
|
||||
p = re.compile('\n' + _cre_attrib + '\nclass' + _cre_space + _cre_cfname +
|
||||
_cre_space + ':' + _cre_space + 'public' + _cre_virtual +
|
||||
_cre_space + _cre_cfname + _cre_space + '{(.*?)\n};',
|
||||
p = re.compile(r'\n' + _cre_attrib + r'\nclass' + _cre_space + _cre_cfname +
|
||||
_cre_space + r':' + _cre_space + r'public' + _cre_virtual +
|
||||
_cre_space + _cre_cfname + _cre_space + r'{(.*?)\n};',
|
||||
re.MULTILINE | re.DOTALL)
|
||||
list = p.findall(data)
|
||||
if len(list) > 0:
|
||||
@ -852,7 +852,7 @@ class obj_class:
|
||||
|
||||
# extract typedefs
|
||||
p = re.compile(
|
||||
'\n' + _cre_space + 'typedef' + _cre_space + _cre_typedef + ';',
|
||||
r'\n' + _cre_space + r'typedef' + _cre_space + _cre_typedef + r';',
|
||||
re.MULTILINE | re.DOTALL)
|
||||
list = p.findall(body)
|
||||
|
||||
@ -867,8 +867,8 @@ class obj_class:
|
||||
self.typedefs.append(obj_typedef(self, filename, value, alias))
|
||||
|
||||
# extract static functions
|
||||
p = re.compile('\n' + _cre_space + _cre_attrib + '\n' + _cre_space +
|
||||
'static' + _cre_space + _cre_func + '\((.*?)\)',
|
||||
p = re.compile(r'\n' + _cre_space + _cre_attrib + r'\n' + _cre_space +
|
||||
r'static' + _cre_space + _cre_func + r'\((.*?)\)',
|
||||
re.MULTILINE | re.DOTALL)
|
||||
list = p.findall(body)
|
||||
|
||||
@ -882,8 +882,8 @@ class obj_class:
|
||||
|
||||
# extract virtual functions
|
||||
p = re.compile(
|
||||
'\n' + _cre_space + _cre_attrib + '\n' + _cre_space + 'virtual' +
|
||||
_cre_space + _cre_func + '\((.*?)\)' + _cre_vfmod,
|
||||
r'\n' + _cre_space + _cre_attrib + r'\n' + _cre_space + r'virtual' +
|
||||
_cre_space + _cre_func + r'\((.*?)\)' + _cre_vfmod,
|
||||
re.MULTILINE | re.DOTALL)
|
||||
list = p.findall(body)
|
||||
|
||||
@ -1766,7 +1766,7 @@ class obj_analysis:
|
||||
return {'result_type': 'structure', 'result_value': value}
|
||||
|
||||
# check for CEF reference pointers
|
||||
p = re.compile('^CefRefPtr<(.*?)>$', re.DOTALL)
|
||||
p = re.compile(r'^CefRefPtr<(.*?)>$', re.DOTALL)
|
||||
list = p.findall(value)
|
||||
if len(list) == 1:
|
||||
return {
|
||||
@ -1776,7 +1776,7 @@ class obj_analysis:
|
||||
}
|
||||
|
||||
# check for CEF owned pointers
|
||||
p = re.compile('^CefOwnPtr<(.*?)>$', re.DOTALL)
|
||||
p = re.compile(r'^CefOwnPtr<(.*?)>$', re.DOTALL)
|
||||
list = p.findall(value)
|
||||
if len(list) == 1:
|
||||
return {
|
||||
@ -1786,7 +1786,7 @@ class obj_analysis:
|
||||
}
|
||||
|
||||
# check for CEF raw pointers
|
||||
p = re.compile('^CefRawPtr<(.*?)>$', re.DOTALL)
|
||||
p = re.compile(r'^CefRawPtr<(.*?)>$', re.DOTALL)
|
||||
list = p.findall(value)
|
||||
if len(list) == 1:
|
||||
return {
|
||||
|
Reference in New Issue
Block a user