Use raw strings for regular expression

Makes all re.compile function calls use raw string to prevent Syntax warning in future, if backslash escape characters are used in regular expressions

https: //github.com/ROCm/rocminfo/pull/66
Suggested-by: Author: Yiyang Wu <xgreenlandforwyy@gmail.com

Change-Id: I6c7aaf016c588bb2ae5a0f979da7d423a78d6ec3


[ROCm/rocminfo commit: e1716642ff]
Cette révision appartient à :
Shweta Khatri
2024-01-04 15:11:28 -05:00
révisé par Shweta Khatri
Parent 0412fdba60
révision 47be475e1f
+4 -4
Voir le fichier
@@ -81,7 +81,7 @@ def staticVars(**kwargs):
return func
return deco
@staticVars(search_term=re.compile("gfx[0-9a-fA-F]+"))
@staticVars(search_term=re.compile(r"gfx[0-9a-fA-F]+"))
def getGCNISA(line, match_from_beginning = False):
if match_from_beginning is True:
result = getGCNISA.search_term.match(line)
@@ -135,8 +135,8 @@ def readFromROCMINFO(search_arch_name = False):
break
# run rocminfo
rocminfo_output = subprocess.Popen(rocminfo_executable, stdout=subprocess.PIPE).communicate()[0].decode("utf-8").split('\n')
term1 = re.compile("Cannot allocate memory")
term2 = re.compile("HSA_STATUS_ERROR_OUT_OF_RESOURCES")
term1 = re.compile(r"Cannot allocate memory")
term2 = re.compile(r"HSA_STATUS_ERROR_OUT_OF_RESOURCES")
done = 1
for line in rocminfo_output:
if term1.search(line) is not None or term2.search(line) is not None:
@@ -196,7 +196,7 @@ def readFromKFD():
if os.path.isdir(node_path):
prop_path = node_path + '/properties'
if os.path.isfile(prop_path) and os.access(prop_path, os.R_OK):
target_search_term = re.compile("gfx_target_version.+")
target_search_term = re.compile(r"gfx_target_version.+")
with open(prop_path) as f:
try:
line = f.readline()