pkg_util

pkg_util

Miscellaneous utility functions for the package

Functions

Name Description
get_external_scripts Get list of standalone scripts included in the package
get_package_version Get the current version of a package from the metadata.
get_project_scripts Get a list of CLI tools in the package.
get_pyproject_toml Get the contents of the package’s pyproject.toml file.
get_version Get the current version of the ccbr_tools package.
msg Prints the error message with a timestamp.
msg_box Displays a message box with a given splash message.
print_citation Prints the citation for the given citation file in the specified output format.
repo_base Get the absolute path to a file in the repository

get_external_scripts

pkg_util.get_external_scripts(pkg_name='ccbr_tools')

Get list of standalone scripts included in the package

Parameters

Name Type Description Default
pkg_name str The name of the package. Defaults to “ccbr_tools”. 'ccbr_tools'

Returns

Name Type Description
scripts list A list of standalone scripts included in the package.

get_package_version

pkg_util.get_package_version(pkg_name='ccbr_tools')

Get the current version of a package from the metadata.

Parameters

Name Type Description Default
pkg_name str Name of the package (default: ccbr_tools). 'ccbr_tools'

Returns

Name Type Description
version str The version of the package.

get_project_scripts

pkg_util.get_project_scripts(pkg_name='ccbr_tools')

Get a list of CLI tools in the package.

Parameters

Name Type Description Default
pkg_name str The name of the package. Defaults to “ccbr_tools”. 'ccbr_tools'

Returns

Name Type Description
tools list A sorted list of CLI tool names.

get_pyproject_toml

pkg_util.get_pyproject_toml(pkg_name='ccbr_tools', repo_base=repo_base)

Get the contents of the package’s pyproject.toml file.

Parameters

Name Type Description Default
pkg_name str Name of the package (default: ccbr_tools). 'ccbr_tools'

Returns

Name Type Description
pyproject dict The contents of the pyproject.toml file.

get_version

pkg_util.get_version(repo_base=repo_base, debug=False)

Get the current version of the ccbr_tools package.

Parameters

Name Type Description Default
repo_base function A function that returns the base path of the repository. repo_base
debug bool Print the path to the VERSION file (default: False). False

Returns

Name Type Description
version str The version of the package.

msg

pkg_util.msg(err_message)

Prints the error message with a timestamp.

Parameters

Name Type Description Default
err_message str The error message to be printed. required

Returns: None

msg_box

pkg_util.msg_box(splash, errmsg=None)

Displays a message box with a given splash message.

Parameters

Name Type Description Default
splash str The splash message to be displayed. required
errmsg str An error message to be displayed below the splash message. Defaults to None. None

print_citation

pkg_util.print_citation(
    citation_file=repo_base('CITATION.cff'),
    output_format='bibtex',
)

Prints the citation for the given citation file in the specified output format.

Parameters

Name Type Description Default
citation_file str The path to the citation file. repo_base('CITATION.cff')
output_format str The desired output format for the citation. 'bibtex'

repo_base

pkg_util.repo_base(*paths)

Get the absolute path to a file in the repository

Parameters

Name Type Description Default
*paths str Additional paths to join with the base path. ()

Returns

Name Type Description
path str The absolute path to the file in the repository.