mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 16:25: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
|
@ -321,8 +321,7 @@ class InputOutput:
|
||||||
self.tool_error(f"{filename}: {e}")
|
self.tool_error(f"{filename}: {e}")
|
||||||
return
|
return
|
||||||
|
|
||||||
# add silent=False, if true don't output any error messages. SEARCH/REPLACE the entire func. AI!
|
def read_text(self, filename, silent=False):
|
||||||
def read_text(self, filename):
|
|
||||||
if is_image_file(filename):
|
if is_image_file(filename):
|
||||||
return self.read_image(filename)
|
return self.read_image(filename)
|
||||||
|
|
||||||
|
@ -330,15 +329,19 @@ class InputOutput:
|
||||||
with open(str(filename), "r", encoding=self.encoding) as f:
|
with open(str(filename), "r", encoding=self.encoding) as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
|
if not silent:
|
||||||
self.tool_error(f"{filename}: unable to read: {err}")
|
self.tool_error(f"{filename}: unable to read: {err}")
|
||||||
return
|
return
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
if not silent:
|
||||||
self.tool_error(f"{filename}: file not found error")
|
self.tool_error(f"{filename}: file not found error")
|
||||||
return
|
return
|
||||||
except IsADirectoryError:
|
except IsADirectoryError:
|
||||||
|
if not silent:
|
||||||
self.tool_error(f"{filename}: is a directory")
|
self.tool_error(f"{filename}: is a directory")
|
||||||
return
|
return
|
||||||
except UnicodeError as e:
|
except UnicodeError as e:
|
||||||
|
if not silent:
|
||||||
self.tool_error(f"{filename}: {e}")
|
self.tool_error(f"{filename}: {e}")
|
||||||
self.tool_error("Use --encoding to set the unicode encoding.")
|
self.tool_error("Use --encoding to set the unicode encoding.")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue