Skip to main content

Restrict writing to certain areas in the Thonny editor based on code comments.

Project description

Continuous Integration - Ubuntu Continuous Integration - OSX Continuous Integration - Windows Test coverage PyPI - version PyPI - Python Version

thonny-sealed is a plug-in for Thonny IDE to restrict writing to certain blocks of text based on code comments.

This is especially practical for instructional sessions such as classroom exercises. The teacher prepares the exercises and demarcates the “sealed” blocks using special comments (# sealed: on and # sealed: off or, more visually appealing, # sealed: 🡻 and # sealed: 🡹, respectively).

Since we do not want the students to inadvertently introduce new sealed blocks during the exercises, the comment blocks are further sealed by using a hash of the content and their order. To that end, the plug-in provides a command-line utility thonny-seal.

Once the content was properly sealed, the teacher distributes the exercises. The students open them in Thonny with thonny-sealed plug-in installed. The sealed blocks can be copied in the editor, but not modified anymore.

Screenshot of the code view with the sealed content

Installation

In Thonny

The plug-in can be easily installed via Thonny. Go to Tools menu and select Manage plug-ins...:

Tools -> Manage plug-ins...

Search for thonny-sealed on PyPI and click on the link to install it:

Search on PyPI

With pip

In your virtual environment, invoke:

pip install --user thonny-sealed

Usage

Thonny-sealed inspects the blocks of code in your files based on the special comments. The user is prevented from editing the content within the sealed blocks.

  • Mark the start of every block with a comment line # sealed: on. Analogously, mark the end of a sealed block with # sealed: off. Alternatively, you can use the visually more appealing comments # sealed: 🡻 and # sealed: 🡹, respectively.

    Here is an example file:

"""Provide some service."""

# sealed: on
def some_func() -> None:
    """Do something."""
    # sealed: off
  • Call in the terminal (where plug-in has been installed) to “seal” the blocks with the hashes:

thonny-seal --input path/to/the/file.py --write
  • Your file is now sealed and can be loaded in the plug-in. The content of the file is:

"""Provide some service."""

# sealed: on 3a9ff394
def some_func() -> None:
    """Do something."""
    # sealed: off 3a9ff394

Alternatively, you can write the output to the STDOUT if you do not want to overwrite the file by omitting the --write argument:

thonny-sealed --input path/to/the/file.py

Contributing

Feature requests or bug reports are always very, very welcome!

Please see quickly if the issue does not already exist in the issue section and, if not, create a new issue.

You can also contribute in code. Please see CONTRIBUTING.rst.

Versioning

We follow Semantic Versioning. The version X.Y.Z indicates:

  • X is the major version (backward-incompatible),

  • Y is the minor version (backward-compatible), and

  • Z is the patch version (backward-compatible bug fix).

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

thonny-sealed-1.0.0b2.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

thonny_sealed-1.0.0b2-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file thonny-sealed-1.0.0b2.tar.gz.

File metadata

  • Download URL: thonny-sealed-1.0.0b2.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for thonny-sealed-1.0.0b2.tar.gz
Algorithm Hash digest
SHA256 b1062cbaa23417da81bc2072f7be5cec4322d0a6ba129e9c472a33c5a0c887e2
MD5 fbe8e29a17d8eb0d3862bda0607fb2bf
BLAKE2b-256 2d247e47dc0d79010234d8d3c190347716e7b9fe44f79c1e34019fd2f6d779f5

See more details on using hashes here.

File details

Details for the file thonny_sealed-1.0.0b2-py3-none-any.whl.

File metadata

  • Download URL: thonny_sealed-1.0.0b2-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for thonny_sealed-1.0.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 7e8b625378462e7e3e695db328cb81c2d128b0b6f3610ee440658e944f9ae32f
MD5 17c237a154cd0992342e4d6edb89770e
BLAKE2b-256 5df8ce78a3fc44c74de4ef3964eed6d460f8fd6760f6cdd761a1b878c1ac80ce

See more details on using hashes here.

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