A pluggable manager for syntax rewriting codecs
Project description
Yes, this is a joke. But I think it works? *rofl* A joke… that works…
Projects like Coconut and cursed-for offer new syntax on top of the standard Python syntax. They achieve this by preprocessing code of their customized form down to standard Python. One option for this preprocessing is to leverage the source code encoding features of Python. For example, specifying # coding: coconut, after some other setup, can enable Coconut syntax for that file. But, what if you need multiple of these syntax modifying encodings? That’s where shimtax comes in and let’s you apply multiple other encodings.
# coding: shimtax:cursed-for:coconut
for (i = 0; i < 10; i += 2):
i |> print
Given that each encoding is offering custom syntax that the others are presumably unaware of, expect many combinations to be order dependent or to simply not work. Those that simply operate on the code as a string are much more likely to be mixable. Those that parse the code via a Python syntax parser are likely to fail.
Setup
shimtax can be set to be automatically enabled using the CLI. This will insert a .pth file in the platlib directory returned by sysconfig.get_path("platlib"). That file will register the shimtax encoding so you don’t have to.
$ .venv/bin/shimtax register
The CLI can also remove the .pth file.
$ .venv/bin/shimtax unregister
If handling this yourself is preferred, you can use the registration helper function.
import shimtax
shimtax.register()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file shimtax-0.1.tar.gz
.
File metadata
- Download URL: shimtax-0.1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | efcf6d227ee979f2cf61c4a9c5f415fcac7a7ddd9f3030cf6c3c2f0cae1d5cd9 |
|
MD5 | 14676dfaa6b13a8765752fcf962d8be5 |
|
BLAKE2b-256 | d030170f4879d641b6687655e18664666ef92d22b2168c8f16e01b9b6708eca1 |
File details
Details for the file shimtax-0.1-py3-none-any.whl
.
File metadata
- Download URL: shimtax-0.1-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7889f14aad45a8588390915a57a741d511c44357be88532b5f994284611a9dc6 |
|
MD5 | 90b1d3ee09757a677cb98ffaafeef273 |
|
BLAKE2b-256 | a10121bd548f745803f3913b466e8c4c4f22087ed5f65beea58ff83b80bfa655 |