(path_string, current_folder=None)
| 34 | |
| 35 | |
| 36 | def normalize_path(path_string, current_folder=None): |
| 37 | path_string = os.path.expanduser(path_string) |
| 38 | path_string = os.path.normpath(path_string) |
| 39 | |
| 40 | if os.path.isabs(path_string): |
| 41 | return path_string |
| 42 | |
| 43 | if current_folder: |
| 44 | normalized_folder = normalize_path(current_folder) |
| 45 | return os.path.join(normalized_folder, path_string) |
| 46 | |
| 47 | if not os.path.exists(path_string): |
| 48 | return path_string |
| 49 | |
| 50 | return str(pathlib.Path(path_string).resolve()) |
| 51 | |
| 52 | |
| 53 | def read_file(filename, byte_content=False, keep_newlines=False): |
no outgoing calls