infinitymatter commited on
Commit
2f3f572
·
verified ·
1 Parent(s): 4e3cfe7

Update src/utils.py

Browse files
Files changed (1) hide show
  1. 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\(([^)]+)\)', code_str)
24
  if match:
25
- parts = re.findall(r'["\']([^"\']+)["\']', match.group(1))
26
- if parts:
27
- return os.path.join(*parts)
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: