pkg
thkit.pkg
¶
Functions:
-
strip_ansi_codes
–Strip ANSI codes for color formatting from a string.
-
create_logger
–Create and configure a logger with console and optional file handlers.
-
check_package
–Check if the required packages are installed
-
install_package
–Install the required package:
-
dependency_info
–Get the dependency information
strip_ansi_codes(msg: str) -> str
¶
Strip ANSI codes for color formatting from a string.
create_logger(logger_name: str = None, log_file: str = None, level: str = 'INFO', level_logfile: str = None) -> logging.Logger
¶
Create and configure a logger with console and optional file handlers.
check_package(package_name: str, auto_install: bool = False, git_repo: str = None, conda_channel: str = None)
¶
Check if the required packages are installed
install_package(package_name: str, git_repo: str | None = None, conda_channel: str | None = None) -> None
¶
Install the required package
- Default using:
pip install -U {package_name}
- If
git_repo
is provided:pip install -U git+{git_repo}
- If
conda_channel
is provided:conda install -c {conda_channel} {package_name}
Parameters:
-
package_name
(str
) –package name
-
git_repo
(str
, default:None
) –git path for the package. Default: None. E.g., http://somthing.git
-
conda_channel
(str
, default:None
) –conda channel for the package. Default: None. E.g., conda-forge
dependency_info(packages=['numpy', 'polars', 'thkit', 'ase']) -> str
¶
Get the dependency information
Note
Use importlib
instead of __import__
for clarity.