alogos._utilities.operating_system
¶
Functions¶
|
Ensure that a filepath ends with a given extension. |
|
Delete a file. |
|
Check whether a given path exists. If yes, try to find a novel, incremented variant of it. |
|
Given a directory path, create it and all necessary parent directories. |
|
Open the given HTML text in the default webbrowser. |
Attributes¶
Detailed object descriptions¶
- alogos._utilities.operating_system.NEWLINE¶
- alogos._utilities.operating_system.ensure_file_extension(filepath, extension)[source]¶
Ensure that a filepath ends with a given extension.
References
- alogos._utilities.operating_system.ensure_new_path(path)[source]¶
Check whether a given path exists. If yes, try to find a novel, incremented variant of it.
Caution: Not threadsafe.
Examples
If
some_dir
exists, it becomessome_dir_1.mp3
, thensome_dir_2.mp3
, …If
some_file
exists, it becomessome_file_1
, thensome_file_2
, …If
some_file.mp3
exists, it becomessome_file_1.mp3
, thensome_file_2.mp3
, …If
x_1.y_2.z.txt
exists, it becomesx_1.y_2.z_1.txt
, thenx_1.y_2.z_2.txt
, …
- alogos._utilities.operating_system.create_directory(dirpath)[source]¶
Given a directory path, create it and all necessary parent directories.
Do nothing if the directory already exists.
References
- alogos._utilities.operating_system.open_in_webbrowser(html_text, start_delay=0.1, stop_delay_fast=0.25, stop_delay_slow=10.0)[source]¶
Open the given HTML text in the default webbrowser.
A short-lived local HTTP server is created that serves HTML text, so that it can be opened in the default webbrowser. An alternative would be to write the HTML text to a temporary file and open this file in the webbrowser.
- Parameters:
html_text (str)
start_delay (float) – Delay between starting the server and opening the webbrowser in another thread. If too short, the webbrowser might send the request before the server is running.
stop_delay_fast (float) – Delay between opening the webbrowser (or a new tab) and shutting down the server after it received the first GET request from the browser.
stop_delay_slow (float) – Delay between opening the webbrowser (or a new tab) and shutting down the server even if it never receives a GET request, e.g. because the browser does not open.
References