Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shimtax-0.1.tar.gz (6.7 kB view hashes)

Uploaded Source

Built Distribution

shimtax-0.1-py3-none-any.whl (8.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page