ginpar.utils package

Submodules

ginpar.utils.echo module

Echo different categories of messages.

Use either click.echo or click.secho with predefined custom foreground colors to echo different categories of messages like success, errors, or warnings.

ginpar.utils.echo.alert(m)

Warnings and alerts that may change Ginpar behavior. Yellow foreground.

ginpar.utils.echo.echo(m)

General messages with no emphasis. Blue foreground.

ginpar.utils.echo.error(m)

Failure messages that interrumpted a certain operation. Red foreground.

ginpar.utils.echo.info(m)

Information messages with tips or suggestions. Blue foreground.

ginpar.utils.echo.success(m)

Success messages after operations or tasks. Green foreground.

ginpar.utils.files module

File management for common Ginpar operations.

This module implements the default ways of managing file creation, deletion, copying, and moving.

ginpar.utils.files.check_existence(path)

Check if the received path exists as either a file or a directory.

Parameters:
path : str

Can be a valid path or not.

ginpar.utils.files.copy_folder(fr, to, force=False)

Attempt (and optionally force) the copy of a folder.

Parameters:
fr : str

From. Path of the folder to be copied.

to : str

To. Path of the to be created.

force : bool

Will remove an existing directory with the same name of to, if it exists.

ginpar.utils.files.create_file(file, content)

Attempt the creation of a new file with custom content.

Parameters:
file : str

Name of the file to be created (path must be included).

content : str

Content to write into the file.

ginpar.utils.files.create_folder(folder, force=False)

Attempt (and optionally force) the creation of a new folder.

Parameters:
folder : str

Name of the folder to be created (path must be included).

force : bool

Will remove an existing directory with the same name, if it exists.

ginpar.utils.files.try_remove(path)

Attempt the removal of a path, either if it is a file or a directory.

Parameters:
path : str

Must be an existing path.

Notes

To check for the existence of the path, previous to calling try_remove, use `check_existence`_.

ginpar.utils.git module

Git repository management inside Ginpar for themes and quickstart.

ginpar.utils.git.clone_repo(repo, path)

Clone the contents of a repository in a custom path

Parameters:
repo : str

GitHub repository as in “{USER}/{REPO}”

path : str

Path to clone the repository to

ginpar.utils.git.delete_git_files(path)

Delete the git files to only keep the relevant files

Parameters:
path : str

Path to look for git files

ginpar.utils.strings module

String filters to convert between cases.

The list of filters in here are added to the Jinja2 environment, so they may come handy when designing a custom theme.

ginpar.utils.strings.camel_to_space(s)

Replace low dashes with spaces.

Parameters:
s : str

String that may contain “_” characters.

ginpar.utils.strings.space_to_kebab(s)

Replace spaces with dashes.

Parameters:
s : str

String that may contain ” ” characters.

ginpar.utils.strings.unkebab(s)

Replace dashes with spaces.

Parameters:
s : str

String that may contain “-” characters.

Module contents