utils
pykmhelpers.core.utils
Main
Main initialization class for kmhelpers.
Source code in pykmhelpers/core/utils.py
init(default_bin_path='./bin', check_all=True, chdir='')
staticmethod
Initialize kmhelpers by setting up binary paths and checking dependencies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
default_bin_path
|
str
|
Default path for binary executables (default: "./bin"). |
'./bin'
|
check_all
|
bool
|
If True, verify all required binaries are available (default: True). |
True
|
chdir
|
str
|
If non-empty, change the working directory to this path before initialization. |
''
|
Source code in pykmhelpers/core/utils.py
Bin
Binary path management and validation utilities.
Source code in pykmhelpers/core/utils.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
set_default_bin_path(path)
staticmethod
Set the default binary path if not already set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the binary directory |
required |
Source code in pykmhelpers/core/utils.py
fetch(binary, path)
staticmethod
Fetch a binary from a given path and create a symlink in the bin directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
binary
|
str
|
Name of the binary |
required |
path
|
str
|
Source path of the binary |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the source binary is not found |
Source code in pykmhelpers/core/utils.py
get_bin_dir()
staticmethod
Get the binary directory path.
Returns:
| Type | Description |
|---|---|
str
|
The canonical path to the binary directory |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If Main.init() hasn't been called |
Source code in pykmhelpers/core/utils.py
get_bin_path(binary)
staticmethod
Get the full path to a binary executable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
binary
|
str
|
Name of the binary |
required |
Returns:
| Type | Description |
|---|---|
str
|
Full path to the binary |
add_bin_dir_to_syspath()
staticmethod
kmindex()
staticmethod
check_bin(binary_name)
staticmethod
Check if a binary exists in PATH and print a warning if not found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
binary_name
|
str
|
Name of the binary to check |
required |
Source code in pykmhelpers/core/utils.py
check_kmindex()
staticmethod
Check if kmindex is available with helpful error message.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If kmindex >= 0.5.3 is not found in PATH |
Source code in pykmhelpers/core/utils.py
check_all()
staticmethod
Toolbox
Utility class for common operations.
Source code in pykmhelpers/core/utils.py
get_canonical_path(path)
staticmethod
Get the canonical absolute path of a given path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The input path to resolve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The canonical absolute path. |
Source code in pykmhelpers/core/utils.py
get_basename(path)
staticmethod
Get the base name of a given path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The input path. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The base name of the path. |