Skip to main content

Your cli buddy to dig up knowledge from legacy code

Project description

Dig up

A cli-tool that helps you dig up knowledge from Python legacy code.

How to use

Install it along your python project:

pip install digup

Word count

Display the word count at the codebase level:

digup wc | head -n 20

# (digup312) lxnd@dune digup % digup wc | head -n 15
# 38 modules
# --------------------------------------------------
# word                                    occurences
# --------------------------------------------------
# self                                            81
# str                                             59
# node                                            52
# int                                             50
# code                                            48
# list                                            38
# Word                                            38
# WordCount                                       36
# args                                            36
# Path                                            30
# functions                                       26

Display the wordcount of a long function:

digup wc -f my_long_function
#demo.py::my_long_function: 
#------------------------------------------------------------------------
#word                                             #      span  proportion
#------------------------------------------------------------------------
#print                                           11        22         34%
#count                                            8        15         23%
#match                                            6         8         12%
#status                                           6        26         40%
#ip_counts                                        4        37         57%
#defaultdict                                      4         4          6%
#int                                              4         4          6%
#ip                                               4        20         31%
#url                                              4        22         34%
#day                                              4        23         35%

💡 A high number of occurrences with a low proportion is a sign of something that can be extracted.

Display the help:

digup wc --help

List the modules, the classes, the functions

digup ls     # list of modules of the current directory (recursively)
digup ls -f  # list of modules of the current directory (recursively)
digup ls -c  # list of modules of the current directory (recursively)

List the 10 longest functions, sorted by length:

digup ls -f --sort -n 10

# 10/99 functions
# ------------------------------------------------------------------------------------------------------------------------
# functions                                                                                                         length
# ------------------------------------------------------------------------------------------------------------------------
# src/cli.py::main                                                                                                      87
# drafts/my_long_function.py::my_long_function                                                                          65
# src/termcolor.py::colored                                                                                             58
# src/highlight_identifiers.py::highlight_identifiers                                                                   43
# src/termcolor.py::_can_do_colour                                                                                      31
# drafts/test_compute_word_count_with_parso.py::word_counts                                                             29
# src/termcolor.py::cprint                                                                                              28
# src/count_words.py::word_count                                                                                        27
# tests/word_count/test_compute_word_count_on_a_function.py::test_a_complex_case                                        27
# src/colors.py::_hsv_to_rgb                                                                                            26

Display the help:

digup ls -h

Highlight the identifiers

digup hi -f highlight_identifiers

Developer documentation

How to install the project

python -m venv ../venvs/digup_312
source ../venvs/digup_312/bin/activate
python -m ensurepip --upgrade
python -m pip install setuptools --upgrade
python -m pip install -r dev-requirements.txt

# To be able to run `digup` cli in the project
python -m pip install -e .

How to publish a new version

  1. Increment the version in pyproject.toml.
  2. Type make release

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

digup-0.0.8.tar.gz (64.8 kB view details)

Uploaded Source

Built Distribution

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

digup-0.0.8-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file digup-0.0.8.tar.gz.

File metadata

  • Download URL: digup-0.0.8.tar.gz
  • Upload date:
  • Size: 64.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for digup-0.0.8.tar.gz
Algorithm Hash digest
SHA256 6a926faaaa28baa8b1e3b5b169aa6daf5d26ea7ad321fe9ed361b04af6467ba6
MD5 8c76be4278da97636046baac6ff611a8
BLAKE2b-256 291a590c260f08d802e9a8a6af106bbdc5aebacb1e02c0c529d8709a2761e3e7

See more details on using hashes here.

File details

Details for the file digup-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: digup-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for digup-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 936e33f3dc2c4ebcb7c6bb95b8b281677ffcecc33e5ee7198e1f2b7c500dcf4e
MD5 c07543a906cf1484e1499320043a2ca6
BLAKE2b-256 6ef034274d6e6b4bbb1d0519b8e2675c78eacafcdb3d37be00d3e66828d2ab98

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