mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 23:05:00 +00:00
feat: add silent mode to read_text method
This commit is contained in:
parent
a664c3dd47
commit
e14c84f2fb
1 changed files with 10 additions and 7 deletions
17
aider/io.py
17
aider/io.py
|
@ -321,8 +321,7 @@ class InputOutput:
|
|||
self.tool_error(f"{filename}: {e}")
|
||||
return
|
||||
|
||||
# add silent=False, if true don't output any error messages. SEARCH/REPLACE the entire func. AI!
|
||||
def read_text(self, filename):
|
||||
def read_text(self, filename, silent=False):
|
||||
if is_image_file(filename):
|
||||
return self.read_image(filename)
|
||||
|
||||
|
@ -330,17 +329,21 @@ class InputOutput:
|
|||
with open(str(filename), "r", encoding=self.encoding) as f:
|
||||
return f.read()
|
||||
except OSError as err:
|
||||
self.tool_error(f"{filename}: unable to read: {err}")
|
||||
if not silent:
|
||||
self.tool_error(f"{filename}: unable to read: {err}")
|
||||
return
|
||||
except FileNotFoundError:
|
||||
self.tool_error(f"{filename}: file not found error")
|
||||
if not silent:
|
||||
self.tool_error(f"{filename}: file not found error")
|
||||
return
|
||||
except IsADirectoryError:
|
||||
self.tool_error(f"{filename}: is a directory")
|
||||
if not silent:
|
||||
self.tool_error(f"{filename}: is a directory")
|
||||
return
|
||||
except UnicodeError as e:
|
||||
self.tool_error(f"{filename}: {e}")
|
||||
self.tool_error("Use --encoding to set the unicode encoding.")
|
||||
if not silent:
|
||||
self.tool_error(f"{filename}: {e}")
|
||||
self.tool_error("Use --encoding to set the unicode encoding.")
|
||||
return
|
||||
|
||||
def write_text(self, filename, content, max_retries=5, initial_delay=0.1):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue