HAL
core_utils.cpp
Go to the documentation of this file.
2 
3 namespace hal
4 {
6  {
7  auto py_core_utils = m.def_submodule("CoreUtils", R"(
8  HAL Core Utility functions.
9  )");
10 
11  py_core_utils.def("get_binary_directory", &utils::get_binary_directory, R"(
12  Get the path to the executable of HAL.
13 
14  :returns: The path.
15  :rtype: pathlib.Path
16  )");
17 
18  py_core_utils.def("get_base_directory", &utils::get_base_directory, R"(
19  Get the base path to the HAL installation.
20  1. Use Environment Variable HAL_BASE_PATH
21  2. If current executable is hal (not e.g. python3 interpreter) use it's path to determine base path.
22  3. Try to find hal executable in path and use its base path.
23 
24  :returns: The path.
25  :rtype: pathlib.Path
26  )");
27 
28  py_core_utils.def("get_library_directory", &utils::get_library_directory, R"(
29  Get the path to the shared and static libraries of HAL.
30  Relative to the binary directory.
31 
32  :returns: The path.
33  :rtype: pathlib.Path
34  )");
35 
36  py_core_utils.def("get_share_directory", &utils::get_share_directory, R"(
37  Get the path to the sh
38  Relative to the binary
39 
40  :returns: The path.
41  :rtype: pathlib.Path
42  )");
43 
44  py_core_utils.def("get_user_share_directory", &utils::get_user_share_directory, R"(
45  Get the path to shared objects and files provided by the user.
46  home/.local/share for Unix
47 
48  :returns: The path.
49  :rtype: pathlib.Path
50  )");
51 
52  py_core_utils.def("get_user_config_directory", &utils::get_user_config_directory, R"(
53  Get the path to the configuration directory of the user.
54  home/.config/hal for Unix
55 
56  :returns: The path.
57  :rtype: pathlib.Path
58  )");
59 
60  py_core_utils.def("get_default_log_directory", &utils::get_default_log_directory, py::arg("source_file") = "", R"(
61  Get the path to the default directory for log files.
62  If an hdl source file is provided, the function returns the parent directory, otherwise get_user_share_directory() / "log".
63 
64  :param source_file: The hdl source file.
65  :type source_file: pathlib.Path
66  :returns: The path.
67  :rtype: pathlib.Path
68  )");
69 
70  py_core_utils.def("get_gate_library_directories", &utils::get_gate_library_directories, R"(
71  Get the paths where gate libraries are searched.
72  Contains the share and user share directories.
73 
74  :returns: A list of paths.
75  :rtype: list[pathlib.Path]
76  )");
77 
78  py_core_utils.def("get_plugin_directories", &utils::get_plugin_directories, R"(
79  Get the paths where plugins are searched.
80  Contains the library and user share directories.
81 
82  :returns: A vector of paths.
83  )");
84  }
85 } // namespace hal
void core_utils_init(py::module &m)
Definition: core_utils.cpp:5
const Module * module(const Gate *g, const NodeBoxes &boxes)
std::filesystem::path get_user_share_directory()
Definition: utils.cpp:156
std::filesystem::path get_share_directory()
Definition: utils.cpp:148
std::vector< std::filesystem::path > get_gate_library_directories()
Definition: utils.cpp:185
std::filesystem::path get_base_directory()
Definition: utils.cpp:99
std::filesystem::path get_library_directory()
Definition: utils.cpp:128
std::filesystem::path get_user_config_directory()
Definition: utils.cpp:171
std::vector< std::filesystem::path > get_plugin_directories()
Definition: utils.cpp:194
std::filesystem::path get_default_log_directory(std::filesystem::path source_file)
Definition: utils.cpp:178
std::filesystem::path get_binary_directory()
Definition: utils.cpp:69