mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-04 03:35:00 +00:00
style: Format Python code
This commit is contained in:
parent
7e763094b3
commit
4763582c9e
1 changed files with 15 additions and 16 deletions
25
testsr.py
25
testsr.py
|
@ -1,7 +1,9 @@
|
||||||
|
import json
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import json
|
|
||||||
from aider.coders.editblock_coder import find_original_update_blocks, DEFAULT_FENCE
|
from aider.coders.editblock_coder import DEFAULT_FENCE, find_original_update_blocks
|
||||||
|
|
||||||
|
|
||||||
def process_markdown(filename):
|
def process_markdown(filename):
|
||||||
try:
|
try:
|
||||||
|
@ -23,24 +25,20 @@ def process_markdown(filename):
|
||||||
blocks = list(find_original_update_blocks(content, DEFAULT_FENCE))
|
blocks = list(find_original_update_blocks(content, DEFAULT_FENCE))
|
||||||
|
|
||||||
# Create a dictionary for this section
|
# Create a dictionary for this section
|
||||||
section_result = {
|
section_result = {"header": header, "blocks": []}
|
||||||
"header": header,
|
|
||||||
"blocks": []
|
|
||||||
}
|
|
||||||
|
|
||||||
for block in blocks:
|
for block in blocks:
|
||||||
if block[0] is None: # This is a shell command block
|
if block[0] is None: # This is a shell command block
|
||||||
section_result["blocks"].append({
|
section_result["blocks"].append({"type": "shell", "content": block[1]})
|
||||||
"type": "shell",
|
|
||||||
"content": block[1]
|
|
||||||
})
|
|
||||||
else: # This is a SEARCH/REPLACE block
|
else: # This is a SEARCH/REPLACE block
|
||||||
section_result["blocks"].append({
|
section_result["blocks"].append(
|
||||||
|
{
|
||||||
"type": "search_replace",
|
"type": "search_replace",
|
||||||
"filename": block[0],
|
"filename": block[0],
|
||||||
"original": block[1],
|
"original": block[1],
|
||||||
"updated": block[2]
|
"updated": block[2],
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
results.append(section_result)
|
results.append(section_result)
|
||||||
|
|
||||||
|
@ -52,6 +50,7 @@ def process_markdown(filename):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(json.dumps({"error": f"An error occurred: {str(e)}"}))
|
print(json.dumps({"error": f"An error occurred: {str(e)}"}))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print(json.dumps({"error": "Usage: python testsr.py <markdown_filename>"}))
|
print(json.dumps({"error": "Usage: python testsr.py <markdown_filename>"}))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue