Skip to main content

Elegant debuging module

Project description

Nezu

PyPI version License Dependencies

Elegant debugging module

  • Python code example
    # file.py
    from nezu import say
    x = 13
    say('x')  # print debuging info
    
  • Bash commands to run
    export NEZU_SEEK = 1
    $ py file.py
        @4 l x:int  =>  13
    

How to install?

$ python -m pip install nezu

or

$ python -m poetry add nezu

How to use?

Basic usage

Inspect variable using say function. Pass name of variable you want to inspect as str argument.

  • Note

    Output of say function is hidden by default. If you wannna see what nezu has to say you need to configure it first using nezu object. Simplest way is to call it with argument 1.

# file.py
from nezu import nezu, say
nezu(1)

say('egg')          # works on simple variables
say('ham.spam')     # works on attributes
say('spam["spam"]') # works on keys and indexes
say('print')        # works on functions and build-ins

How to interpret output?

@7      b  print:function  =>  Prints the values to a stream, or to sys...
 │      │  │     │             │
 │      │  │     │             └───────── Value of inspected variable
 │      │  │     │
 │      │  │     └─────────────── Type of inspected variable.
 │      │  │
 │      │  └───────────── Name of inspected variable.
 │      │
 │      └──────── Scope of inspected variable.
 │                l:local, g:global, b:build-in, u:undefined
 |
 └────── Line number of inspection.

Configuration

By default nezu is configured by env vars. This can be changed in code.

Env vars config

If you want to use default configuration method, change your env vars in terminal and than run your Python file.

  • Bash

    export NEZU_SEEK = 1
    export NEZU_COLOR = 1
    export NEZU_LOCK = 0
    python3 file.py
    
  • PowerShell

    $env:NEZU_SEEK = 1
    $env:NEZU_COLOR = $True
    $env:NEZU_LOCK = $True
    py file.py
    

JSON config

If you dont want to use env vars as configuration you can call nezu.json() to read configuration data from json file. It will search for key nezu inside chosen file.

  • Params
    • path:str = 'nezu.json - path of configuration file
  • Example config file
    "nezu" {
      "seek": 1,
      "color": true,
      "locked": false
    }
    

Hardcoded config

If you dont want to use env vars as configuration you can also call object nezu like function to make hardcoded config.

  • Params

    • seek:int = 0 - debuging level
    • color:bool = False - output coloring
    • lock:bool = False - lock this config
  • Example

    # file.py
    from nezu import nezu, say
    
    nezu(1, True, False)
    ...
    
  • Tip

    There is no build in support for yaml, toml or .env in nezu This is so nezu can stay free of dependencies. However you can use hardcoded config to pass data from any config file.

Coloring output

By default nezu output is monochrome. If your terminal of choise support coloring you can change that.

Env vars coloring

  • Example Bash command
    export NEZU_COLOR = 1
    python3 file.py
    
  • Example PowerShell command
    $env:NEZU_COLOR = $True
    py file.py
    

JSON coloring

  • Example config file
    "nezu" {
      "color": true,
    }
    

Hardcoded coloring

  • Example

    from nezu import nezu, say
    
    nezu(color = True)
    ...
    

Hiding output

Function say() can be can be hidden into deeper levels of debugging via hide parameter. Execution argument --nezu seeks only for says hidden at level 1. Now if you want to display more, you run your program with --nezu-seek integer argument. In example bellow only says hidden up to level 3 are displayed.

#file.py
from nezu import say

say('egg', hide=1)
say('ham', hide=2)
say('spam', hide=3)
say('bacon', hide=4)
say('lobster', hide=5)
$ python file.py --nezu-seek=3
@4      u  egg
@5      u  ham
@6      u  spam

TO DO

  • add class method support?
  • add coloring
  • add classes parameter (so you can print only group of logs)
  • indicate shadowing
  • write docstring for say
    • write test for multiline output
  • write tests for name parser
  • write tests for say
  • automate testing with Github actions?
  • automate deployment to PyPI with Github actions?
  • publish to Conda
  • test on different CPython versions
  • test on Pypy
  • test on Anaconda
  • add badges
  • format files with blue
  • remove obsolete tests
  • gitignore .vscode, __pycache, dist
  • write proper documentation
    • How to interpret output
    • Configuration
    • Explain arguments
      • Hiding
      • Notes
      • args
    • Note args
    • brag in readme about being on pypy and and conda
  • make a helper function, that returns dictionary (so it's easier to assert and doesn't require --nezu)
    • write function
    • write docstring for it
    • write tests for it
    • document it in README
  • Write code of conduct
  • Write/generate TOC
  • Update README about configuration
  • Write docstrings to configuration functions

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

nezu-0.3.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nezu-0.3.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file nezu-0.3.0.tar.gz.

File metadata

  • Download URL: nezu-0.3.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.7 Windows/10

File hashes

Hashes for nezu-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0db6be5808488ba95e949d646c3429ce3985befe10cebb16260170a0be5172f3
MD5 4ccfa0806d144e191532ea5794c5c096
BLAKE2b-256 d6a4e77d0f3932f47a2a59728f8dd2355573258ea24ffbb27bf349dc9eaeb348

See more details on using hashes here.

File details

Details for the file nezu-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: nezu-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.7 Windows/10

File hashes

Hashes for nezu-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f7b2bf50f21db475752773e478fd6844fdcab85d7b33765f84f402e4ee397133
MD5 6fba15a9b8d98ae8c93904227b6a0eb5
BLAKE2b-256 c814e24dfc9f2b127c74bea5fc4bb1e53f321397b35dd2e591b8f80933f15dfe

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