trickkiste
trickkiste is a collection of convenience functionality I use quite often that
are too small to give them their own project on the one side but prone to
changes due to changes to the Python ecosystem to just copy&paste them and leave
them as they are.
So they are here now, enjoy.
Beware: most of this is not part of any standard library for a reason. That reason might be there are better built in solutions which are harder (but more flexible) to use or I just didn't find them back then. In most cases you're advised to build them your own (to avoid dependencies and bugs).
Content
Here is an overview of what's in here, see the docstings for a better description (some even have a doctest!):
misc
-
throw(BaseException): functionalraisefor closed expressions -
md5from(Path): convenient wrapper returning an MD5 file checksum -
cwd(Path): path changing context manager -
process_output(cmd): short form for 'run a command and return it's output as one string' -
asyncify: decorator turning a sync method or function into an async one -
async_chain: likechainbut async -
async_filter: likefilterbut async -
date_str(timestamp, [datefmt]): convenience wrapper forstrftime -
def date_from(timestamp: float | str): : convenience wrapper forstrptime -
dur_str(seconds, [fixed]): short human readable representation of a duration -
age_str(now, age, [fixed]): likedur_strbut with an age context -
parse_age(string: str): inverse ofage_str -
smart_split(string: str, delimiter: str = ","): likesplitbut parenthesis aware! -
multi_replace(string: str, *substitutions: tuple[str, str]): short form for chaingingreplace -
compact_dict(mapping, [maxlen], [delim]): create a short one-string map -
def split_params(string: str): inverse ofcompact_dict
logging
apply_common_logging_cli_args(ArgumentParser): enrich a given parser to recognize default stuff like--verbose, etc.setup_logging: sets up arichenhanced logger with useful stuff like call stack and posix thread idloggingfilters: internally used bysetup_loggingbut can be re-used of coursemarkup_escape_filter: escapes (accidental) markup elements in the messagethread_id_filter: adds the (posix) thread idcallstack_filter: adds a short call stacklogger_name_filter: adds the logger name (richedition)logger_funcname_filter: adds the function name (richedition)logger_levelname_filter: adds the level name (richedition)
Textual stuff / TuiBaseApp
TuiBaseApp: liketextual.Appbut with convenience stuff mostly regarding loggingRichLogHandler: a logging handler for atextualwidgetLockingRichLog: locks your log view scroll position until you scroll to the bottomHeatBar: a colorful heat bar widget for things like CPU monitoring
std_suppress
std_suppress (with it's own shell entry point suppress) can be prefixed
to a command and acts like adding >/dev/null 2>&1 but will print the output
if the command needs 'longer than expected' something bad happens (i.e.
nonzero exit).
Use it in scripts where you don't need the output to spam your log but you still
want to know if something unusual happend.
License
See License.md.
Contribution
Initialize
git clone https://github.com/frans-fuerst/trickkiste --recurse-submodules
cd trickkiste
uv run pre-commit install
Manually run checks and fixes
Depending on your workflow / IDE you might want to stay in charge over what's
being executed in order to check and fix code validity. For a number of
scenarios there is a bunch of scripts located in the dev submodule which just
wrap manual calls to what would be done by pre-commit. Some actually run
pre-commit for consistency, some don't in order to stay flexible regarding
command line arguments, e.g. for unit-testing using pytest.
run all checks which would be executed on commit, but on unstaged stuff, too
dev/check-validity
do this in a loop (convenience wrapper around inotifywait)
dev/watchandcheck
run all checks separately
dev/check-python-doctests
dev/check-python-formatting
dev/check-python-linting
dev/check-python-systemtests
dev/check-python-typing
dev/check-python-unittests
dev/check-shellscripts
dev/check-yaml-linting
apply fixes for automatically fixable stuff
dev/fix-python-formatting
dev/fix-python-linting
Version bump and publishing
uv version --bump <patch|minor|major>
uv lock --upgrade
uv build
# do manual tests here
git commit -m"Bump version [..]"
git push
uv publish --token <TOKEN>
Metadata
Release files for trickkiste 0.3.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| trickkiste-0.3.7.tar.gz | 55.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| trickkiste-0.3.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 78.5 kB
Release files / trickkiste-0.3.7.tar.gz
| Download URL | trickkiste-0.3.7.tar.gz |
|---|---|
| Size | 55.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0f447922ce76310fcb7f1b8b446da4f921d290c57bdd82126b9fe2c3a4284d3
|
|
BLAKE2b-256 checksum How to use checksums |
e18295e2840864bbf6be2e3773424400773e9ab104c59ada744fe03412ddd2be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / trickkiste-0.3.7-py3-none-any.whl
| Download URL | trickkiste-0.3.7-py3-none-any.whl |
|---|---|
| Size | 22.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f02f79a59eb9756e97c54bd531ba41a736953a18f94809bd05a10869186ef9ed
|
|
BLAKE2b-256 checksum How to use checksums |
7ffbb8862d2e799f0927c39a377393c2587d44e3161304895b9972f8393faaa2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for trickkiste 0.3.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.