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 hashes)

Uploaded Source

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