gitmopy.utils¶
Utility functions and constants for gitmopy.
Module Contents¶
- gitmopy.utils.check_config(config)[source]¶
Check that the user configuration is valid.
- Parameters:
config (Dict[str, Union[bool, str]]) – Current gitmopy configuration that should be saved
- Raises:
ValueError – Unknown config key
ValueError – Wrong config value type
- Return type:
None
- gitmopy.utils.choice_separator(title='', width=30, sep='─')[source]¶
Create an InquirerPy separator with a title.
- gitmopy.utils.clear_line_and_move_up()[source]¶
Clear the current line and move up one line in the terminal.
- gitmopy.utils.load_config()[source]¶
Load the configuration from
${APP_PATH}/config.yaml.Returns the default configuration if the file does not exist.
- gitmopy.utils.load_user_gitmojis()[source]¶
Load custom gitmojis from
${APP_PATH}/custom_gitmojis.yaml.
- gitmopy.utils.message_from_commit_dict(commit_dict)[source]¶
Create a commit message from a commit dictionary.
Depending on whether
scopeis set, will look like{emoji} ({scope}): {title}{emoji}: {title}
Then
\n\n{message}is appended if a message is specified.
- gitmopy.utils.print_staged_files(staged)[source]¶
Print the currently staged files with Rich colours.
- Parameters:
staged (List[str]) – List of staged files paths.
- Return type:
None
- gitmopy.utils.resolve_path(path)[source]¶
Resolve a path with
expandvars,expanduserandresolve.- Parameters:
path (Union[str, Path]) – Path to resolve.
- Returns:
Resolved (absolute) path.
- Return type:
Path
- gitmopy.utils.safe_capitalize(s)[source]¶
Capitalize a string if it is not empty, but keeps all-caps words.
Example: ..code-block:: python
>>> safe_capitalize("hello") "Hello" >>> safe_capitalize("HELLO") "HELLO" >>> "HELLO".capitalize() "Hello"
- Parameters:
s (str) – String to capitalize
- gitmopy.utils.save_config(config)[source]¶
Save the configuration to
${APP_PATH}/config.yaml.Creates the parent directory if it does not exist.
- gitmopy.utils.set_start_options()[source]¶
Set the options for the default commit arguments automatically from the
gitmopy commitcommand’s signature.
- gitmopy.utils.terminal_separator(margin=10)[source]¶
Create a separator for the terminal.
- Returns:
Terminal separator
- Return type:
- gitmopy.utils.validate_user_emojis(custom_emos)[source]¶
Validate user emojis.
Must be a list of dictionaries (possibly empty)
Each dictionary must have an
emojikey and adescriptionkeyEach key must be a string
Each key must be non-empty
- Raises:
ValueError – If any of the above conditions are not met.
- Parameters:
custom_emos (Any) – User defined emojis.
- Returns:
Validated emojis.
- Return type: