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