mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
18 lines
585 B
Python
18 lines
585 B
Python
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
import typing
|
|
from pathlib import Path
|
|
|
|
|
|
def append_to_file(filename: typing.Union[str, Path], what: str) -> None:
|
|
with open(filename, 'a', encoding='utf-8') as f:
|
|
f.write(what)
|
|
|
|
|
|
def replace_in_file(filename: typing.Union[str, Path], search: str, replace: str) -> None:
|
|
with open(filename, 'r', encoding='utf-8') as f:
|
|
data = f.read()
|
|
result = data.replace(search, replace)
|
|
with open(filename, 'w', encoding='utf-8') as f:
|
|
f.write(result)
|