Skip to main content

Code snapshot

Create a snapshot image for your code to share the formatted code anywhere. We use SHOWCODE api to create a PNG image for the specified code snippet.

Getting started

  1. Create an account on Showcode App to fetch the API key.

  2. Sign in to the account and create an API token:

    1. Token name: Provide a name to the token which you can remember where it is being used
    2. Check "read" permissions
    3. Copy the token displayed and store somewhere in safe. Note: This token won't be shown again, so you need to paste it before you close the window

    Create API token snapshot

  3. Export an environment variable to store the token in the terminal: export SHOWCODE_API_KEY={API Token}

  4. Now, you're ready to use the package in your applications.

Installation

  1. Create a virtual environment: conda create -n code-snapshot-test-env -y python=3.8
  2. Activate the environment: conda activate code-snapshot-test-env
  3. Install the package pip install code-snapshot

Usage

  1. Set the Showcode API token as an environment variable following Getting started section

  2. Write a python script as following:

    from code_snapshot.code_snapshot import CodeSnapshot
    from code_snapshot.models import CodeSnapshotSettings, CodeSnapshotEditor
    
    if __name__ == "__main__":
       settings=CodeSnapshotSettings(
          title="Hello world in Python",
       )
       editor=CodeSnapshotEditor(
          value="""
    def greet(name):
       print(f"Hello {name}!")
    
    greet("World")
          """
       )
       cs = CodeSnapshot()
       cs.save_snapshot(settings, editor, filepath="./code_snapshot.png")
    
  3. Run the python script python main.py. This should generate a file code_snapshot.png in the same directory as main.py.

  4. It should look like this: code_snapshot

  5. You can use cs.generate_snapshot(settings, editor) to consume bytes if required.

Metadata

Release files for code-snapshot 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for code-snapshot 0.2.4
File Size Uploaded Provenance Actions
code-snapshot-0.2.4.tar.gz 162.5 kB Without provenance Details for code-snapshot-0.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for code-snapshot 0.2.4
File Interpreter ABI Platform Actions
code_snapshot-0.2.4-py3-none-any.whl Python 3 none any Details for code_snapshot-0.2.4-py3-none-any.whl

Total release size: 178.6 kB

Release files / code-snapshot-0.2.4.tar.gz

Download URL code-snapshot-0.2.4.tar.gz
Size 162.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a738c605ffc58bdc08efaa4bb88c50c59104ef5fc9562da5a94c6f9d75934bce
BLAKE2b-256 checksum
How to use checksums
e367505b5cc997e5ada28d9ce847b3cc73a794415c018160df5b9b7cd0cdb43a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / code_snapshot-0.2.4-py3-none-any.whl

Download URL code_snapshot-0.2.4-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c884acd082b342f9e8ec4ac0beb07bbd4cf8766803d7ff98ce6a0f5b2838c5d7
BLAKE2b-256 checksum
How to use checksums
3866083f5c227394fdcb605d5cd0fce6ebb486e064d4038e023ffb8ae6fecda4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Security for code-snapshot 0.2.4

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page