amoorion.utilities¶
Small helpers around the methods: markdown posts, the tunnel.
- amoorion.utilities.open_tunnel(port, vault, forward=None)[source]¶
Make a local port reachable from outside by ngrok, for hooks: the secret
ngrok/token.Anyone with the address reaches that port, so only the API, whose methods need their token and whose hooks verify themselves, belongs behind it.
ngrokis not a dependency:pip install ngrok. Returns the listener (.url(),.close()).- Parameters:
port (int)
vault (Vault)
forward (Callable[[...], Any] | None)
- Return type:
Any
- amoorion.utilities.post_from_markdown(source, values=None)[source]¶
A Markdown text or file as a post, and the platforms its front matter names.
— title: Hello tags: [news] links: [https://example.org] to: [mastodon, bluesky] — The text of the post.
valuesfill the names of a template (a dollar and the name), after parsing: they can’t change the settings.- Parameters:
source (str | Path)
values (dict[str, str] | None)
- Return type:
tuple[Post, list[str]]
- amoorion.utilities.read_env(path)[source]¶
An env file as a dict; comments and quotes dealt with.
- Parameters:
path (str | Path)
- Return type:
dict[str, str | None]
- amoorion.utilities.write_env(path, **values)[source]¶
Set values in an env file, made if missing; other lines and comments stay as they are.
- Parameters:
path (str | Path)
values (str)
- Return type:
Path
Modules