style: Format Python code

This commit is contained in:
Paul Gauthier (aider) 2024-08-22 06:34:22 -07:00
parent 7e763094b3
commit 4763582c9e

View file

@ -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>"}))