Spaces:
Sleeping
Sleeping
Update src/utils.py
Browse files- src/utils.py +4 -4
src/utils.py
CHANGED
@@ -20,11 +20,11 @@ def extract_code(text):
|
|
20 |
# Extract file path from a code string that uses os.path.join()
|
21 |
def extract_file_path(code_str):
|
22 |
try:
|
23 |
-
match = re.search(r'os\.path\.join\(([
|
24 |
if match:
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
print("No file path found.")
|
29 |
return None
|
30 |
except Exception as e:
|
|
|
20 |
# Extract file path from a code string that uses os.path.join()
|
21 |
def extract_file_path(code_str):
|
22 |
try:
|
23 |
+
match = re.search(r'os\.path\.join\(\s*["\'](.+?)["\']\s*,\s*["\'](.+?)["\']\s*\)', code_str)
|
24 |
if match:
|
25 |
+
folder = match.group(1)
|
26 |
+
filename = match.group(2)
|
27 |
+
return os.path.join(folder, filename)
|
28 |
print("No file path found.")
|
29 |
return None
|
30 |
except Exception as e:
|