Spells (API reference)
This is an API reference for the all the Invoke tasks and helper functions that are included in the Conjuring package.
conjuring.spells.aws
AWS: ECR login.
clean_ecr_url(c, url=None)
Clean an AWS ECR URL.
ecr_login(c, url='')
Log in to AWS ECR.
Using Amazon ECR with the AWS CLI - Amazon ECR
Source code in src/conjuring/spells/aws.py
fzf_aws_account(c)
fzf_aws_profile(c, partial_name=None)
Select an AWS profile from a partial profile name using fzf.
Source code in src/conjuring/spells/aws.py
fzf_aws_region(c)
list_aws_profiles(c)
run_aws_vault(c, *pieces, profile=None)
Run AWS vault commands in a subshell, or open a subshell if no commands were provided.
Source code in src/conjuring/spells/aws.py
conjuring.spells.direnv
direnv: init local dir.
init(c, source_up=False, dotenv=False, all_=False)
Configure direnv in the local dir.
Source code in src/conjuring/spells/direnv.py
conjuring.spells.docker
Docker: remove containers and volumes.
rm_containers(c, container='', all_=False, exited=False)
Remove Docker containers.
Source code in src/conjuring/spells/docker.py
rm_volumes(c, dangling=False)
Remove Docker volumes.
Source code in src/conjuring/spells/docker.py
conjuring.spells.duplicity
Backup and restore with Duplicity.
backup(c)
Backup files with Duplicity.
Source code in src/conjuring/spells/duplicity.py
print_hostname(c)
Print the hostname of the current machine.
restore(c)
Restore files with Duplicity. You will be prompted to choose the source dir. Restore dir is ~/Downloads.
Source code in src/conjuring/spells/duplicity.py
conjuring.spells.fork
GitHub forks: configure remote and sync.
remote(c, username, remote_='upstream')
Configure a remote for a fork.
Source code in src/conjuring/spells/fork.py
sync(c, remote_='upstream')
Source code in src/conjuring/spells/fork.py
conjuring.spells.generic
Generic spells: list to-do items in files.
Location
dataclass
Location of a to-do item in a file.
Source code in src/conjuring/spells/generic.py
ToDoItem
dataclass
A to-do item.
Source code in src/conjuring/spells/generic.py
sort_key: str
property
Key to sort the instance.
String concatenation works.
Checking both fields separately with and
conditions didn't work: sort order was not as expected
(meaning fix-me tasks first, then to-do tasks).
todo(c, cz=False, valid=True, invalid=True, short=False, priority='', markdown=False, dir_='')
List to-dos and fix-mes in code. Optionally check if the description follows Conventional Commits (cz check).
Source code in src/conjuring/spells/generic.py
conjuring.spells.git
Git: update all, extract subtree, rewrite history, ...
Git
Git helpers.
Source code in src/conjuring/spells/git.py
github_username: str
property
The GitHub username configured in the global settings.
checkout(*branches)
Try checking out the specified branches in order.
Source code in src/conjuring/spells/git.py
choose_local_branch(branch)
current_branch()
default_branch()
Return the default branch name (master/main/develop/development).
PrefixBranch
dataclass
body(c, prefix=False, original_order=False)
Prepare a commit body to be used on pull requests and squashed commits.
Source code in src/conjuring/spells/git.py
changes_since_tag(c, tag='', files=False, verbose=False, by_author=False)
Display changes (commits or files) since the last tag (or a chosen tag).
Source code in src/conjuring/spells/git.py
extract_subtree(c, new_project_dir, reset=False, keep=False)
Extract files from subdirectories of the current Git repo to another repo, using git subtree.
The files will be moved to the root of the new repo.
Solutions adapted from: - https://serebrov.github.io/html/2021-09-13-git-move-history-to-another-repository.html - https://stackoverflow.com/questions/25574407/git-subtree-split-two-directories/58253979#58253979
Source code in src/conjuring/spells/git.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
|
global_config()
cached
history(c, full=False, files=False, author=False, dates=False)
Grep the whole Git log and display information.
Source code in src/conjuring/spells/git.py
merge_default(c, remote=False, update=True, push=True, rebase=False)
Merge the default branch of the repo. Also set it with "git config", if not already set.
Source code in src/conjuring/spells/git.py
rewrite(c, commit='--root', gpg=True, author=True)
Rewrite a range of commits, signing with GPG and setting the author.
https://git-scm.com/docs/git-commit https://git-scm.com/docs/git-rebase
Source code in src/conjuring/spells/git.py
set_default_branch(c, remote=False)
Set the default branch config on the repo, if not configured yet.
Source code in src/conjuring/spells/git.py
switch_url_to(c, remote='origin', https=False)
Set an SSH or HTTPS URL for a remote.
Source code in src/conjuring/spells/git.py
tidy_up(c)
Prune remotes, update all branches of the repo, delete merged/squashed branches.
Source code in src/conjuring/spells/git.py
update_all(c, group='')
Run gita super to update and clean branches.
Source code in src/conjuring/spells/git.py
watch(c)
Watch a build on GitHub Actions, then open a pull request or repo after the build is over.
Source code in src/conjuring/spells/git.py
conjuring.spells.jrnl
Query tags and entries with the jrnl note-taking tool.
edit_last(c, journal='')
query(c, n=0, contains='', edit=False, fancy=False, short=False, journal='')
Query jrnl entries.
Source code in src/conjuring/spells/jrnl.py
tags(c, sort=False, rg='', journal='')
Query jrnl tags.
Source code in src/conjuring/spells/jrnl.py
conjuring.spells.k8s
Kubernetes: get pods, show variables from config maps, validate score and more.
Kubectl
dataclass
Kubectl commands.
Source code in src/conjuring/spells/k8s.py
choose_apps(partial_name=None, *, multi=False)
Select apps from Kubernetes deployments, using a partial app name and fzf.
Use the current dir as the app name if no partial app name is provided.
Source code in src/conjuring/spells/k8s.py
cmd_get(resource, apps)
run_get(resource, apps)
config_map(c, app, rg='')
Show the config map for an app.
Source code in src/conjuring/spells/k8s.py
exec_(c, app='')
Exec into the first pod found for the chosen app.
Source code in src/conjuring/spells/k8s.py
pods(c, app='', replica_set=False)
Show the pods and replica sets for an app.
Source code in src/conjuring/spells/k8s.py
validate_score(c)
Validate and score files that were changed from the master branch.
Source code in src/conjuring/spells/k8s.py
conjuring.spells.media
Media files: remove empty dirs, clean up picture dirs, download YouTube videos, transcribe audio.
CompareDirsAction
Bases: Enum
Actions to take when comparing two directories.
Source code in src/conjuring/spells/media.py
cleanup(c, browse=False)
Cleanup pictures.
Source code in src/conjuring/spells/media.py
compare_dirs(c, from_dir, to_dir, count=MAX_COUNT, size=MAX_SIZE, delete=False, move=False, wildcard_search=False)
Compare files in two directories. Stops when it reaches max count or size.
Source code in src/conjuring/spells/media.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
empty_dirs(c, dir_, delete=False, fd=True)
Remove some hidden files first, then remove empty dirs.
The ending slash is needed to search OneDrive, now that its behaviour changed in macOS Monterey.
Source code in src/conjuring/spells/media.py
invidious(c)
Parse Invidious instances to be used in the Chrome plugin random instance pool.
"Invidious random instance pool (comma-separated)" text field config from Privacy Redirect.
Source code in src/conjuring/spells/media.py
slideshow(c, start_at='')
Show pictures in the current dir with feh.
Source code in src/conjuring/spells/media.py
unzip_tree(c, dir_, count=1, delete=False)
Unzip .tar.gz files in a directory tree.
Source code in src/conjuring/spells/media.py
whisper(c, dir_)
Transcribe multiple audio file that haven't been transcribed yet, using whisper.
Source code in src/conjuring/spells/media.py
youtube_dl(c, url, min_height=360, download_archive_path='')
Download video URLs, try different low-res formats until it finds one.
Source code in src/conjuring/spells/media.py
zip_tree(c, dir_, count=1, depth=5, delete=False)
Zip files in a directory tree, creating a .tar.gz file.
Source code in src/conjuring/spells/media.py
conjuring.spells.mkdocs
MkDocs spells: install, build, deploy to GitHub, serve locally.
browse(c)
build(c)
deploy(c)
install(c, force=False)
Install MkDocs globally with the Material plugin. Upgrade if it already exists.
Source code in src/conjuring/spells/mkdocs.py
serve(c)
conjuring.spells.mr
myrepos repository management tool: grep text in repos.
MyRepos
dataclass
Find and interact with myrepos config files.
Source code in src/conjuring/spells/mr.py
find_configs(partial_name, echo=False)
Find config files in the current dir or dirs above.
Source code in src/conjuring/spells/mr.py
grep(c, search_text, config='', echo=False)
Grep mr repositories with a search text and print the directories in which the text was found.
Needs mr to be preconfigured with files starting with the ".mrconfig" prefix.
Source code in src/conjuring/spells/mr.py
conjuring.spells.onedrive
OneDrive: list files with conflicts.
conflicts(c, dir_)
List files with conflicts.
Source code in src/conjuring/spells/onedrive.py
force_downloads(c, dir_)
Force downloads of remote OneDrive files by reading them with a dummy "diff".
Source code in src/conjuring/spells/onedrive.py
conjuring.spells.paperless
Paperless: maintenance, renamer, sanity, delete duplicates.
Document
dataclass
OrphanFile
dataclass
delete_failed_duplicates(c, max_delete=100)
Delete records marked as duplicate but that cannot be downloaded. So the PDF files can be reimported.
Source code in src/conjuring/spells/paperless.py
maintenance(c, reindex=True, optimize=True, thumbnails=True)
Reindex all docs and optionally optimize them.
https://docs.paperless-ngx.com/administration/#index https://docs.paperless-ngx.com/administration/#thumbnails
Source code in src/conjuring/spells/paperless.py
paperless_cmd()
Command to run Paperless with Docker.
paperless_documents_dir()
Directory where Paperless stores documents.
Source code in src/conjuring/spells/paperless.py
paperless_token()
paperless_url()
rename(c)
sanity(c, hide=True, orphans=False, thumbnails=False, documents=False, unknown=True, together=False, fix=False, move=False)
Sanity checker. Optionally fix orphan files (copies or movies them to the download dir).
https://docs.paperless-ngx.com/administration/#sanity-checker
Source code in src/conjuring/spells/paperless.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
conjuring.spells.pre_commit
pre-commit: install, uninstall, run/autoupdate selected hooks.
auto(c, repo='', bleed=False)
Autoupdate a Git hook or all hooks with the latest tag. Needs fzf and yq.
Source code in src/conjuring/spells/pre_commit.py
get_hook_types(commit_msg, desired_hooks=None)
Prepare a list of hook types to install/uninstall.
Source code in src/conjuring/spells/pre_commit.py
install(c, before, gc=False, commit_msg=True)
Pre-commit install hooks.
Source code in src/conjuring/spells/pre_commit.py
run(c, hooks)
Pre-commit run all hooks or a specific one. Don't stop on failures. Needs fzf and yq.
Source code in src/conjuring/spells/pre_commit.py
uninstall(c, gc=False, commit_msg=True)
Pre-commit uninstall ALL hooks.
Source code in src/conjuring/spells/pre_commit.py
conjuring.spells.py
Install venvs, run tests and coverage, install debug tools.
Poetry
dataclass
Poetry-related tasks.
Source code in src/conjuring/spells/py.py
guess_python_version()
Guess Python version from pyproject.toml.
Source code in src/conjuring/spells/py.py
parse_python_version(venv)
staticmethod
remove_venv(python_version)
use_venv(python_version)
used_in_project(display_error=True)
Check if Poetry is being used.
Source code in src/conjuring/spells/py.py
PyEnv
dataclass
pyenv-related tasks.
Source code in src/conjuring/spells/py.py
has_local()
list_versions(python_version=None)
List all installed Python versions, or only the ones matching the desired version.
Source code in src/conjuring/spells/py.py
Pytest
Pytest-related tasks.
Source code in src/conjuring/spells/py.py
coverage(c, show_all=False, s=False)
Run tests with pytest and coverage.
Source code in src/conjuring/spells/py.py
debug_tools(c, all_=False, ipython=False, ipdb=False, pudb=False, icecream=False, devtools=False, watch=False, watcher=False)
Install debug tools.
Source code in src/conjuring/spells/py.py
editable(c, inject='')
Hack to install a Poetry package as editable until Poetry supports PEP660 hooks.
It won't be needed anymore when https://github.com/python-poetry/poetry-core/pull/182 is merged.
Source code in src/conjuring/spells/py.py
install(c, version='', force=False, delete_all=False, pipx=False, editable=False)
Install a Python virtual environment. For now, only works with Poetry.
Source code in src/conjuring/spells/py.py
test(c, s=False)
Run tests with pytest.
Source code in src/conjuring/spells/py.py
watch(c)
conjuring.spells.shell
Shell: install/uninstall completion.
completion_install(c, app)
Install shell completion. For now, only for the Bash shell, and only for Click projects.
- Shell Completion — Click Documentation (8.0.x)
- click-contrib/click-completion: Add or enhance bash, fish, zsh and powershell completion in Click
Source code in src/conjuring/spells/shell.py
completion_list(c)
completion_uninstall(c, app)
Uninstall shell completion from both completion dirs.