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/digup312
source ../venvs/digup312
python -m ensurepip --upgrade
python -m pip install setuptools --upgrade
python -m pip install -r 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.7.tar.gz (63.6 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.7-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: digup-0.0.7.tar.gz
  • Upload date:
  • Size: 63.6 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.7.tar.gz
Algorithm Hash digest
SHA256 5de654a5d09be0a6fd25989eb9dbd1b3a60c426bd5201bb9185525eb38dad552
MD5 1f1aac4e982e1d9b3800159376cb1fcd
BLAKE2b-256 5913f4b7290c867a9b4d34c5b9f6cf17ff7dcb96a7086fd271a6818e2367cda0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: digup-0.0.7-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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 8431a1b5258e5438556fb28f878fd273848826a556c4ed21fe659f602d898503
MD5 0317884967f2ba1b2ab7b0551dc5400e
BLAKE2b-256 46e8dc4bbdbd21572839c8daa22fada04357daa77bf96e5bd1e16fcde34ad75d

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