[build] added ignorecase for plugins rebranding

This commit is contained in:
Aleksandr
2023-11-25 21:51:01 +03:00
parent adefce2542
commit 1125676522

View File

@ -316,14 +316,14 @@ def replaceInFileUtf8(path, text, textReplace):
with open(get_path(path), "wb") as file: with open(get_path(path), "wb") as file:
file.write(filedata.encode("UTF-8")) file.write(filedata.encode("UTF-8"))
return return
def replaceInFileRE(path, pattern, textReplace): def replaceInFileRE(path, pattern, textReplace, flags=0):
if not is_file(path): if not is_file(path):
print("[replaceInFile] file not exist: " + path) print("[replaceInFile] file not exist: " + path)
return return
filedata = "" filedata = ""
with open(get_path(path), "r", encoding='utf-8') as file: with open(get_path(path), "r", encoding='utf-8') as file:
filedata = file.read() filedata = file.read()
filedata = re.sub(pattern, textReplace, filedata) filedata = re.sub(pattern, textReplace, filedata, flags=flags)
delete_file(path) delete_file(path)
with open(get_path(path), "w", encoding='utf-8') as file: with open(get_path(path), "w", encoding='utf-8') as file:
file.write(filedata) file.write(filedata)
@ -1297,8 +1297,7 @@ def check_correct_plugins(dir, license = '', branding=''):
elif (file_extension == '.html'): elif (file_extension == '.html'):
change_plugin_license(path, html_license, start='<!--', end='-->') change_plugin_license(path, html_license, start='<!--', end='-->')
replaceInFile(path, "https://onlyoffice.github.io/sdkjs-plugins/", "../") replaceInFile(path, "https://onlyoffice.github.io/sdkjs-plugins/", "../")
replaceInFileRE(path, 'onlyoffice', branding.lower()) replaceInFileRE(path, 'onlyoffice', branding.lower(), re.IGNORECASE)
replaceInFileRE(path, 'ONLYOFFICE', branding.upper())
elif (file_extension == '.md' or file_extension == '.txt'): elif (file_extension == '.md' or file_extension == '.txt'):
check = readFile(path) check = readFile(path)
if (re.search(r'onlyoffice', check, re.IGNORECASE) or re.search(r'ascensio', check, re.IGNORECASE)): if (re.search(r'onlyoffice', check, re.IGNORECASE) or re.search(r'ascensio', check, re.IGNORECASE)):