mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
fix: Move FileNotFoundError handling up after file open and read
This commit is contained in:
parent
35c6d5b569
commit
b219e790a4
1 changed files with 7 additions and 4 deletions
11
testsr.py
11
testsr.py
|
@ -15,12 +15,15 @@ def process_markdown(filename):
|
||||||
try:
|
try:
|
||||||
with open(filename, "r") as file:
|
with open(filename, "r") as file:
|
||||||
content = file.read()
|
content = file.read()
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(json.dumps({"error": f"File '{filename}' not found."}, indent=4))
|
||||||
|
return
|
||||||
|
|
||||||
# Split the content into sections based on '####' headers
|
# Split the content into sections based on '####' headers
|
||||||
sections = re.split(r"(?=####\s)", content)
|
sections = re.split(r"(?=####\s)", content)
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
for section in sections:
|
for section in sections:
|
||||||
if not section.strip(): # Ignore empty sections
|
if not section.strip(): # Ignore empty sections
|
||||||
continue
|
continue
|
||||||
# Extract the header (if present)
|
# Extract the header (if present)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue