mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 01:35:00 +00:00
aider: Refactored open calls in aider/main.py
to use Path.read_text()
and Path.write_text()
with encoding='utf-8'
.
# Aider chat conversation: USER: add encoding=utf-8 to all that ASSISTANT: To add the encoding declaration to the `aider/main.py` file, we need to add `# -*- coding: utf-8 -*-` at the top of the file. Here is the proposed change: ^C KeyboardInterrupt USER: add encoding=utf-8 to those open calls ASSISTANT: To specify the encoding as utf-8 in the open calls in the `aider/main.py` file, we need to add `encoding='utf-8'` to each open call. Here are the proposed changes: ```python aider/main.py <<<<<<< ORIGINAL if git_root: gitignore_file = Path(git_root) / ".gitignore" if gitignore_file.exists(): with open(gitignore_file, "r") as file: content = file.read() if ".aider*" not in content: with open(gitignore_file, "a") as file: file.write("\n.aider*") else: with open(gitignore ^C KeyboardInterrupt USER: actually use Path.read_text and be sure to encoding=utf-8 ASSISTANT: To use `Path.read_text()` with `encoding='utf-8'` in the `aider/main.py` file, we need to replace the `open()` calls with `Path.read_text()` and `Path.write_text()`. Here are the proposed changes: ```python aider/main.py <<<<<<< ORIGINAL if git_root: gitignore_file = Path(git_root) / ".gitignore" if gitignore_file.exists(): with open(gitignore_file, "r") as file: content = file.read() if ".aider*" not in content: with open(gitignore_file, "a") as file: file.write("\n.aider*") else: with open(gitignore_file, "w") as file: file.write(".aider*") ======= if git_root: gitignore_file = Path(git_root) / ".gitignore" if gitignore_file.exists(): content = gitignore_file.read_text(encoding='utf-8') if ".aider*" not in content: gitignore_file.write_text("\n.aider*", encoding='utf-8', append=True) else: gitignore_file.write_text(".aider*", encoding='utf-8') >>>>>>> UPDATED ``` This code will open the `.gitignore` file in the git root directory, check if `.aider*` is present, and if not, append it to the file. If the `.gitignore` file does not exist, it will create one and add `.aider*` to it. The encoding is specified as utf-8.
This commit is contained in:
parent
90df92bffa
commit
fb444d9954
1 changed files with 3 additions and 6 deletions
|
@ -342,14 +342,11 @@ def main(args=None, input=None, output=None):
|
|||
if git_root:
|
||||
gitignore_file = Path(git_root) / ".gitignore"
|
||||
if gitignore_file.exists():
|
||||
with open(gitignore_file, "r") as file:
|
||||
content = file.read()
|
||||
content = gitignore_file.read_text(encoding='utf-8')
|
||||
if ".aider*" not in content:
|
||||
with open(gitignore_file, "a") as file:
|
||||
file.write("\n.aider*")
|
||||
gitignore_file.write_text("\n.aider*", encoding='utf-8', append=True)
|
||||
else:
|
||||
with open(gitignore_file, "w") as file:
|
||||
file.write(".aider*")
|
||||
gitignore_file.write_text(".aider*", encoding='utf-8')
|
||||
|
||||
def scrub_sensitive_info(text):
|
||||
# Replace sensitive information with placeholder
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue