Skip to main content

manual

Python interfaces to system calls

To install: pip install manual

Examples

Write some "instructions" for someone with some placeholders like so:

template = """
git checkout {main_branch}
git pull
git checkout {to_merge_branch}
git merge {main_branch}
git push
"""

Then just make a function like this:

ri = mk_command_runner(template)

Then ri is a function with a nice signature with arguments to control the placeholders.

from inspect import signature
assert str(signature(ri)) == '(main_branch, to_merge_branch, *, _dry_run=False)'

If you call the function, it will run the commands one by one, printing the command it's about the run and then the output of the run. The _dry_run allows one to just do the command prints without actually running the commands:

print(ri('master', 'fixing_something', _dry_run=True))
(1/5)$ git checkout master

(2/5)$ git pull

(3/5)$ git checkout fixing_something

(4/5)$ git merge master

(5/5)$ git push

Note that you can also specify your commands as a list, and also ask that the commands be run one by one, asking the user to type any key to continue at every step:

pwd_and_ls = mk_command_runner(["pwd", "ls -l"], step_by_step=True)
pwd_and_ls()
(1/2)$ pwd
/Users/Thor.Whalen/Dropbox/dev/p3/proj/t/manual

TYPE ANY KEY TO CONTINUE

(2/2)$ ls -l
total 48
-rw-r--r--@ 1 Thor.Whalen  staff  11357 Jun 15 21:00 LICENSE
-rw-r--r--@ 1 Thor.Whalen  staff   1040 Jun 15 21:13 README.md
drwxr-xr-x@ 9 Thor.Whalen  staff    288 Jun 15 21:00 docsrc
drwxr-xr-x@ 5 Thor.Whalen  staff    160 Jun 15 21:04 manual
-rw-r--r--@ 1 Thor.Whalen  staff    422 Jun 15 21:04 setup.cfg
-rw-r--r--@ 1 Thor.Whalen  staff     91 Jun 15 21:00 setup.py

Where this is going

How many times do we write instructions for others, or ask others for us. Or perhaps we're even organized enough to have a little file where we put our little how-to recipes, commenting them with natural language so we can understand what the steps are, and simply be able to find those instructions when the time comes.

And then we go through those commands one by one, making sure we replace the right part of the instructions with the right values for our context, maybe trying to read the comments, so we know what we're doing.

Really though, we no extra effort but following some convention to make our instructions parsable, we can make our instructions, well, executable.

So instead of this:

git checkout {your_main_branch}
git pull
git checkout {your_branch}
git merge {your_main_branch}
# Now resolve conflics and press any key when ready for the next step
git commit -m {your_commit_message}
git push

just being that, we can take it as a DSL that will also give us:

  • A function that does it all
  • A function that will actually guide the user through the steps, explaining what's happening etc. (so also educational)

This means that we can then REUSE something like a markdown document that explains recipes, installation instructions, etc. also as boilerplate-less utils.

Metadata

Release files for manual 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for manual 0.0.2
File Size Uploaded
manual-0.0.2.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for manual 0.0.2
File Interpreter ABI Platform
manual-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 15.8 kB

Release files / manual-0.0.2.tar.gz

Download URL manual-0.0.2.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cef8e1281c350a6060e176e2e3a046e3854f8a228a9d8634559ad82b88d5ecf7
BLAKE2b-256 checksum
How to use checksums
22fa79a0d4d068db9333a22b715aa72d481f398d293c6d7379a916085c551720
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.28.0 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.6

Release files / manual-0.0.2-py3-none-any.whl

Download URL manual-0.0.2-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7396f6494286de45dcd53a7b27e67be0b03a00bb936e6a5e51127358879fdd20
BLAKE2b-256 checksum
How to use checksums
8a877a5cee695878eabd3ec19356ba008d6a326f8979510b36316c6d36c6c0c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.28.0 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.6

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page