mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 01:35:00 +00:00
aider: Modified get_tags to run ctags command and capture JSON output.
# Context: USER: in get_tags, run `ctags --fields=+S --output-format=json $f` on the filename and collect the json output instead of reading json from filename. use that json data for the rest of the func ASSISTANT: To modify the `get_tags` function in `aider/ctags.py` to run `ctags --fields=+S --output-format=json $f` on the filename and collect the JSON output, we will need to use the `subprocess` module to run the command and capture the output. Here are the changes: ```python aider/ctags.py <<<<<<< ORIGINAL def get_tags(filename): with open(filename, "r") as tags_file: for line in tags_file: tag = json.loads(line) ======= import subprocess def get_tags(filename): cmd = ["ctags", "--fields=+S", "--output-format=json", filename] output = subprocess.check_output(cmd).decode("utf-8") for line in output.splitlines(): tag = json.loads(line) >>>>>>> UPDATED ``` This change imports the `subprocess` module, replaces the `with open(filename, "r")` block with a `subprocess.check_output` call to run the `ctags` command, and iterates over the output lines instead of the file lines.
This commit is contained in:
parent
efe05b6d8a
commit
f5c6667de3
1 changed files with 6 additions and 3 deletions
|
@ -22,10 +22,13 @@ def print_tags_info(filename):
|
|||
last = tag
|
||||
|
||||
|
||||
import subprocess
|
||||
|
||||
def get_tags(filename):
|
||||
with open(filename, "r") as tags_file:
|
||||
for line in tags_file:
|
||||
tag = json.loads(line)
|
||||
cmd = ["ctags", "--fields=+S", "--output-format=json", filename]
|
||||
output = subprocess.check_output(cmd).decode("utf-8")
|
||||
for line in output.splitlines():
|
||||
tag = json.loads(line)
|
||||
path = tag.get("path")
|
||||
scope = tag.get("scope")
|
||||
kind = tag.get("kind")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue