cli[patch]: unicode issue (#14672)

Some operating systems compile template, resulting in unicode decode
errors
pull/14678/head
Erick Friis 10 months ago committed by GitHub
parent 75b8891399
commit c5250f12c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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…
Cancel
Save