Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /Extralit_extralit /extralit-server /src /extralit_server /helpers.py
| """ | |
| Common helper functions | |
| """ | |
| import logging | |
| _LOGGER = logging.getLogger("extralit_server") | |
| shared_resources = {} | |
| def replace_string_in_file(filename: str, string: str, replace_by: str, encoding: str = "utf-8"): | |
| # TODO Move where is used | |
| """Read a file and replace an old value in file by a new one""" | |
| # Safely read the input filename using 'with' | |
| with open(filename, encoding=encoding) as f: | |
| data = f.read() | |
| if string not in data: | |
| return | |
| # Safely write the changed content, if found in the file | |
| with open(filename, mode="w", encoding=encoding) as f: | |
| data = data.replace(string, replace_by) | |
| f.write(data) | |
Xet Storage Details
- Size:
- 680 Bytes
- Xet hash:
- 67908c5d50fe57e55ee04d29962dc1040185e2129161515808612dc278148ad5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.