Skip to content

utils

Utilities not easily categorized.

echo(
    message: Optional[Any] = None,
    file: Optional[IO] = None,
    nl: bool = True,
    err: bool = False,
    color: Optional[bool] = None,
    **styles: Any
) -> None

A local abstraction for printing messages.

Default behavior is that of click.secho.

This is to allow user feedback without every function requiring a click dependency. Especially during testing.

Parameters:

message

The string or bytes to output. Other objects are converted to strings.

TYPE: Optional[Any]

DEFAULT: None

file

The file to write to. Defaults to stdout.

TYPE: Optional[IO]

DEFAULT: None

nl

Print a newline after the message. Enabled by default.

TYPE: bool

DEFAULT: True

err

Write to stderr instead of stdout.

TYPE: bool

DEFAULT: False

color

Force showing or hiding colors and other styles. By default Click will remove color if the output does not look like an interactive terminal.

TYPE: Optional[bool]

DEFAULT: None

**styles

Style keyword arguments

TYPE: Any

DEFAULT: {}

get_deleted_files(
    template_dir: Path, project_dir: Path
) -> Set[Path]

Get a list of files in the rendered template that do not exist in the project.

This is to avoid introducing changes that won’t apply cleanly to the current project.

Nabbed from Cruft: https://github.com/cruft/cruft/

Parameters:

template_dir

The path to the directory rendered with the same context as the project

TYPE: Path

project_dir

The path to the current project

TYPE: Path

Returns:

Set[Path]

A set of paths that are missing

remove_paths(
    root: Path, paths_to_remove: Set[Path]
) -> None

Remove all paths in paths_to_remove from root.

Nabbed from Cruft: https://github.com/cruft/cruft/

Parameters:

root

The absolute path of the directory requiring path removal

TYPE: Path

paths_to_remove

The set of relative paths to remove from root

TYPE: Set[Path]

remove_readonly_bit(
    func: Callable[[str], None], path: str, _: Any
) -> None

Clear the readonly bit and reattempt the removal.

remove_single_path(path: Path) -> None

Remove a path with extra error handling for Windows.

Parameters:

path

The path to remove

TYPE: Path

Raises:

IOError

If the file could not be removed

temporary_copy(original_path: Path) -> Iterator[Path]

Create a temporary copy of a file or directory.

Parameters:

original_path

The path to the file or directory to copy

TYPE: Path

YIELDS DESCRIPTION
Path

The path to the temporary copy