mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 02:05:00 +00:00
aider: Refactored the find_filenames_and_linenums
function to search for occurrences of <filename>:\d+
in the text and return a list of matches.
# Aider chat conversation: USER: do the todo ASSISTANT: To implement the TODO, we need to: 1. Search the text for all occurrences of `<filename>:\d+` where `<filename>` is one of the filenames in the list `fnames`. 2. Make a list of these occurrences. Here is the *SEARCH/REPLACE* block: aider/linter.py ```python <<<<<<< SEARCH def find_filenames_and_linenums(text, fnames): # TODO: # search text for all occurrances of <filename>:\d+ and make a list of them # where <filename> is one of the filenames in the list `fnames` pass ======= import re def find_filenames_and_linenums(text, fnames): """ Search text for all occurrences of <filename>:\d+ and make a list of them where <filename> is one of the filenames in the list `fnames`. """ pattern = re.compile(r'(\b(?:' + '|'.join(re.escape(fname) for fname in fnames) + r'):\d+\b)') matches = pattern.findall(text) return matches >>>>>>> REPLACE ```
This commit is contained in:
parent
ef286f0de6
commit
9e0f20bb9a
1 changed files with 9 additions and 4 deletions
|
@ -162,11 +162,16 @@ def traverse_tree(node):
|
|||
|
||||
return errors
|
||||
|
||||
import re
|
||||
|
||||
def find_filenames_and_linenums(text, fnames):
|
||||
# TODO:
|
||||
# search text for all occurrances of <filename>:\d+ and make a list of them
|
||||
# where <filename> is one of the filenames in the list `fnames`
|
||||
pass
|
||||
"""
|
||||
Search text for all occurrences of <filename>:\d+ and make a list of them
|
||||
where <filename> is one of the filenames in the list `fnames`.
|
||||
"""
|
||||
pattern = re.compile(r'(\b(?:' + '|'.join(re.escape(fname) for fname in fnames) + r'):\d+\b)')
|
||||
matches = pattern.findall(text)
|
||||
return matches
|
||||
|
||||
def main():
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue