Coder Social home page Coder Social logo

lsapi's Introduction

lsapi

A quick script to display the public names exposed by a Python package as a tree.

setup

$ sudo pip install -r requirements.txt
$ ln -s $PWD/lsapi.py ~/bin/lsapi

usage

$ lsapi -h
usage: lsapi [-h] [-p] [-m] [-a] [-c] [-x] [-s] [-A] [-u] [-U] [-C]
             [-D MAX_DEPTH]
             package

Recursively list the public names exposed by a Python package, formatted as a
readable tree

positional arguments:
  package               package (or sub-package) to inspect

optional arguments:
  -h, --help            show this help message and exit
  -p, --private         show private names
  -m, --magic           show magic names
  -a, --all             show all names (equivalent to `-pm')
  -c, --canonical       try to show names under the namespace where they are
                        defined
  -x, --external        show names exposed by packages that are not under the
                        given root package
  -s, --signatures      show signatures for callables (functions, methods,
                        classes)
  -A, --aliases         show aliased (imported) namespaces
  -u, --ugly            use basic ASCII for tree drawing (for terminal
                        emulators with spotty unicode support)
  -U, --no-tree         do not draw trees
  -C, --no-color        do not colorize output
  -D MAX_DEPTH, --max-depth MAX_DEPTH
                        do not show names nested beyond this depth from the
                        given root package (which has depth 0)

notes

lsapi inspects packages by loading them through python's import mechanism and inspecting the result, instead of compiling and inspecting the AST. This allows for limited operability with packages distributed as wheels and C-language extensions, but also means that names imported elsewhere will likely be listed under the "wrong" namespace. In other words, this script tries to be complete and correct, but may be counterintuitive. With the -c flag, lsapi will attempt to show names where they were canonically defined, but it can't catch everything.

If you see strange symbols in lsapi's output, like �, ▯, or mojibake, it's probably because your terminal emulator doesn't know how to render the glyphs lsapi uses to draw trees. Use the -u or -U flags, but also consider switching to a modern terminal emulator.

lsapi's People

Contributors

robpkelly avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.