Skip to main content

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

Metadata

Release files for digup 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for digup 0.0.8
File Size Uploaded Provenance
digup-0.0.8.tar.gz 64.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for digup 0.0.8
File Interpreter ABI Platform
digup-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 76.0 kB

Release files / digup-0.0.8.tar.gz

Download URL digup-0.0.8.tar.gz
Size 64.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6a926faaaa28baa8b1e3b5b169aa6daf5d26ea7ad321fe9ed361b04af6467ba6
BLAKE2b-256 checksum
How to use checksums
291a590c260f08d802e9a8a6af106bbdc5aebacb1e02c0c529d8709a2761e3e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.4

Release files / digup-0.0.8-py3-none-any.whl

Download URL digup-0.0.8-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
936e33f3dc2c4ebcb7c6bb95b8b281677ffcecc33e5ee7198e1f2b7c500dcf4e
BLAKE2b-256 checksum
How to use checksums
6ef034274d6e6b4bbb1d0519b8e2675c78eacafcdb3d37be00d3e66828d2ab98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.4

Security for digup 0.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page