Skip to main content

A simple tool to help you debug and see all the final values of the variables in every scope.

Project description

PyInspectX

A simple Python package to access all variables, per scope after a runtime. Can be used

for multiple purposes. (Ex: debugging, visual tool to highlight variables in runtime, ...)

Installation

pip install pyinspectx

Usage

The main class of the program is the Inspector class. This class can be used to inspect the variables inside the runtime.

We start generating the modified code. This code can be run as you wish.

The snippet below shows how to generate the modified code.

from pyinspectx import Inspector



testCode = open(os.path.abspath(os.path.join(os.getcwd(), 'example.py')), 'r', encoding='utf-8').read()



inspector = PyInspectX.Inspector()

inspector.modify_code(testCode)



modified_code = inspector.get_modified_code()

print(modified_code)

There is a built in method that generates a temp file inside the current working directory and runs the result for you. The output can be accessed inside a variable.

from pyinspectx import Inspector



testCode = open(os.path.abspath(os.path.join(os.getcwd(), 'example.py')), 'r', encoding='utf-8').read()



inspector = PyInspectX.Inspector()

inspector.modify_code(testCode)



output = inspector.run_modified_code()

print(output)

IMPORTANT: Do not run the code using exec() or eval()! Wrong results will occur.

Inside the ./tests/ folder you can find a few examples on how to use the package.

TODO

  • Add general (regex and keyword) support to block basic variable names inside the runtime.

  • Make injected variables names random.

  • Make a better viewer for the raw data

  • New JSON output format so it can be used for automation and testing.

  • Find more edge cases

  • Check for compatibility with other Python versions and systems.

  • Setup Github action for pytest and flake8

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

pyinspectx-0.0.1.tar.gz (7.3 kB view details)

Uploaded Source

File details

Details for the file pyinspectx-0.0.1.tar.gz.

File metadata

  • Download URL: pyinspectx-0.0.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for pyinspectx-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3c80768db6b9f3e116e0c851275ffe500e3f7fdf9aecd25da0bee50e240ca0eb
MD5 0223dcd3e1db24b1ca7619bd44cfe930
BLAKE2b-256 cfd3cecfc836e1ca582042e6f65982fbc8390d7b2bca4395691cfc9997ec1237

See more details on using hashes here.

Supported by

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