Skip to main content

Shell-like tool to make it easier to develop python code

Project description

devshell

View API documentation

devshell is my python development workflow helper.

Navigating Code Trees

There's normal basic shell navigation with cd, ls, pwd, and then there are python versions of those for navigating through a code tree: pcd, pls, ppwd.

What is a code tree? It is the following types of code blocks:

  1. Package
  2. Module
  3. Class
  4. Function/Method/Coroutine
$ cd ~/projects/statopy
$ ls
LICENSE  __pycache__  statopy.py
$ python3 -m devshell
Starting devshell command line interface...
devshell version 0.0.3
Welcome to devshell. Type help or ? to list commands. Start a line with ! to execute a shell command in a sub-shell (does not retain environmental variables).

(devshell)$                                                                                         

If a package or module in your current working directory (the normal type affected by cd and reported with pwd), then those will show up when you type pls. You can enter your "python location" into it via pcd and check your current python location with ppwd.

Autocompletion works as usual for cd and ls. For the python versions, autocompletion shows you what your options are in terms of child code blocks (e.g. methods in the current class).

(devshell)$ pls                                                                                                                                                                                   
    statopy                       module                        directory
(devshell)$ pcd statopy                                                                                                                                                                           
(devshell)$ pls                                                                                                                                                                                   
    ScalarProbModel               class                         directory
    ScalarRegression              class                         directory
    ScalarStats                   class                         directory
    VectorStats                   class                         directory
(devshell)$ pcd ScalarStats                                                                                                                                                                       
(devshell)$ pls                                                                                                                                                                                   
    __add__                       function                      non-directory
    __init__                      function                      non-directory
    __setattr__                   function                      non-directory
    consume                       function                      non-directory
    update                        function                      non-directory
(devshell)$ ppwd                                                                                                                                                                                  
/statopy.ScalarStats           (class)
(devshell)$  

Commands

That's nice, but what can you do besides inspecting what code blocks exist?

Type help to see a list of commands. Calling programs with arguments/redirection works as usual.

(devshell)$ help                                                                                                                                                                                  

Documented commands (type help <topic>):
========================================
EOF       deactivate  edit     help         pcd   pytest  restart  venv
activate  debug       editvim  interactive  pip   python  rm     
cd        doc         exit     ls           pls   q       rmtree 
coverage  doctest     grep     mkdir        ppwd  quit    run    
cp        doctestify  h        mv           pwd   read    source 

Doctests

If you navigate to a code block, you can examine the docstring and function definition using the doc command. You can run any doctests present in that code block by using the doctest command. You can call doctestify to enter into an interactive session with the module's contents imported. All input and output in this session is recorded, and when the session is closed via CTRL+D, the input/output is appended to the docstring of the current code block as an additional set of doctests.

doctestify resume will open the interactive session and execute all existing doctest commands in the current docstring before turning interactive control over to you. This is useful if you are tweaking code while repeatedly running some test. You don't have to rewrite any setup code multiple times, just use what is in the docstring.

Pytest/Coverage

pytest and coverage - pretty self-explanatory. Coverage runs pytest and doctests and produces a combined report.

Debugging

debug(5,'hello',[1,2,3]) takes the current function or class and calls it like <current_func>(5,'hello',[1,2,3]), entering debug mode on the first line. You can put any python calling expression and as many arguments as you want. If the current code block is a module or package, it requires no inputs, just call debug. For a module, it will enter debug mode on the first line of the module. For a package, it will enter debug mode for the first line of the __init__.py file.

Looking at code

grep pattern [OPTIONS] runs a grep-like function that is filtered on the current code block.

editvim opens vim to the line corresponding to the currently targeted code block.

source opens a paginated view with the text of the current code block (excludes the rest of the file).

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

devshell-0.0.7.tar.gz (100.3 kB view details)

Uploaded Source

Built Distribution

devshell-0.0.7-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file devshell-0.0.7.tar.gz.

File metadata

  • Download URL: devshell-0.0.7.tar.gz
  • Upload date:
  • Size: 100.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.3

File hashes

Hashes for devshell-0.0.7.tar.gz
Algorithm Hash digest
SHA256 dc09f2ca99cb840caf7be65e5412dba8a039fb60594a114c037431812467e25e
MD5 e3fd683a5cf17955e6dbdac9b84a3851
BLAKE2b-256 9d35e24d54f99fd3aa1f36dc28e88f136ca370fb0c42491760fd7bc6c64f464e

See more details on using hashes here.

File details

Details for the file devshell-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: devshell-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.3

File hashes

Hashes for devshell-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 3563377f8c811e3d9ee940660113fe07dd7237b67728017d52ce3bcaed01bef6
MD5 044cb8ad7e1b2e07d9406df7f55b9bde
BLAKE2b-256 b60c38809571eb9c5724c0e9c1c86873e52b6daf9fdbdd1c684625b5360e91b8

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