Skip to content

Commit

Permalink
fix(python): invalid escape sequences (#5063)
Browse files Browse the repository at this point in the history
Convert regex with escape sequences to raw string to avoid invalid escape sequence.
  • Loading branch information
Rotzbua committed May 2, 2024
1 parent 9718493 commit 6449751
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion scripts/git-archive-all.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def read_git_shell(cmd, cwd=None):
import re

output_name = path.basename(output_file_path)
output_name = re.sub('(\.zip|\.tar|\.tgz|\.gz|\.bz2|\.tar\.gz|\.tar\.bz2)$', '', output_name) or "Archive"
output_name = re.sub(r'(\.zip|\.tar|\.tgz|\.gz|\.bz2|\.tar\.gz|\.tar\.bz2)$', '', output_name) or "Archive"
options.prefix = path.join(output_name, '')

try:
Expand Down
14 changes: 7 additions & 7 deletions scripts/macosx-sanity-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ def lookup_library(file):
if os.path.exists(file): found = file
if DEBUG: print("@rpath resolved: " + str(file))
if not found:
if re.search("\.app/", file):
if re.search(r"\.app/", file):
found = file
if DEBUG: print("App found: " + str(found))
elif re.search("@executable_path", file):
abs = re.sub("^@executable_path", executable_path, file)
if os.path.exists(abs): found = abs
if DEBUG: print("Lib in @executable_path found: " + str(found))
elif re.search("\.framework/", file):
elif re.search(r"\.framework/", file):
found = os.path.join("/Library/Frameworks", file)
if DEBUG: print("Framework found: " + str(found))
else:
Expand All @@ -78,7 +78,7 @@ def find_dependencies(file):
# print(dep)
# Fail if libstc++ and libc++ was mixed
global cxxlib
match = re.search("lib(std)?c\+\+", dep)
match = re.search(r"lib(std)?c\+\+", dep)
if match:
if not cxxlib:
cxxlib = match.group(0)
Expand All @@ -88,7 +88,7 @@ def find_dependencies(file):
return None
dep = re.sub(".*:$", "", dep) # Take away header line
dep = re.sub("^\t", "", dep) # Remove initial tabs
dep = re.sub(" \(.*\)$", "", dep) # Remove trailing parentheses
dep = re.sub(r"\s\(.*\)$", "", dep) # Remove trailing parentheses
if len(dep) > 0 and not re.search("/System/Library", dep) and not re.search("/usr/lib", dep):
libs.append(dep)
return libs
Expand All @@ -101,12 +101,12 @@ def validate_lib(lib):
output = p.communicate()[0]
if p.returncode != 0: return False
# Check deployment target
m = re.search("LC_VERSION_MIN_MACOSX([^\n]*\n){2}\s+version (.*)", output, re.MULTILINE)
m = re.search(r"LC_VERSION_MIN_MACOSX([^\n]*\n){2}\s+version\s(.*)", output, re.MULTILINE)
deploymenttarget = None
if m is not None:
deploymenttarget = m.group(2)
if deploymenttarget is None:
m = re.search("LC_BUILD_VERSION([^\n]*\n){3}\s+minos (.*)", output, re.MULTILINE)
m = re.search(r"LC_BUILD_VERSION([^\n]*\n){3}\s+minos\s(.*)", output, re.MULTILINE)
if m is not None:
deploymenttarget = m.group(2)
if deploymenttarget is None:
Expand Down Expand Up @@ -155,7 +155,7 @@ def validate_lib(lib):
print('Error otool -l failed on main executable')
sys.exit(1)
# Check deployment target
m = re.search("LC_RPATH\n(.*)\n\s+path ([^ ]+)", output, re.MULTILINE)
m = re.search(r"LC_RPATH\n(.*)\n\s+path\s([^\s]+)", output, re.MULTILINE)
lc_rpath = m.group(2)
if DEBUG: print('Runpath search path: ' + lc_rpath)

Expand Down

0 comments on commit 6449751

Please sign in to comment.