| # SPDX-License-Identifier: MIT |
| def write_file(path, data): |
| # In case data is None, return immediately |
| wdata = data.rstrip() + "\n" |
| with open(path, "w") as f: |
| def append_file(path, data): |
| # In case data is None, return immediately |
| wdata = data.rstrip() + "\n" |
| with open(path, "a") as f: |
| def remove_from_file(path, data): |
| # In case data is None, return immediately |
| # if file does not exit, just quit, otherwise raise an exception |
| if e.errno == errno.ENOENT: |
| contents = rdata.strip().splitlines() |
| for r in data.strip().splitlines(): |
| write_file(path, "\n".join(contents)) |