mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-30 19:49:09 +00:00
cli[patch]: unicode issue (#14672)
Some operating systems compile template, resulting in unicode decode errors
This commit is contained in:
parent
75b8891399
commit
c5250f12c2
@ -14,7 +14,14 @@ def find_and_replace(source: str, replacements: Dict[str, str]) -> str:
|
||||
|
||||
|
||||
def replace_file(source: Path, replacements: Dict[str, str]) -> None:
|
||||
source.write_text(find_and_replace(source.read_text(), replacements))
|
||||
try:
|
||||
content = source.read_text()
|
||||
except UnicodeDecodeError:
|
||||
# binary file
|
||||
return
|
||||
new_content = find_and_replace(content, replacements)
|
||||
if new_content != content:
|
||||
source.write_text(new_content)
|
||||
|
||||
|
||||
def replace_glob(parent: Path, glob: str, replacements: Dict[str, str]) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user