snoopy
requires Python 3.10 or newer. For basic use, snoopy
does not require any other packages. Only to save directory trees as HTML files and for a nicer print output the rich
package is required.
$ pip install git+https://github.com/styfenschaer/Snoopy.git
$ snoopy
Welcome to Snoopy - Your loyal directory snooper!
/ \__
( @\___
/ O
/ (_____/
/_____/ U
Snoopy is here to help you sniff out the details in your directories, fetching the information you need with the precision and loyalty of man's best friend. Just give the command, and consider it found!
For help, type: snoopy --help
To start snooping, specify your directory: snoopy /path/to/directory
Version 0.0.2 (2024-02-22)
Copyright (c) 2024 Styfen SchΓ€r
Download-URL https://github.com/styfenschaer/Snoopy
$ snoopy --help
π snoopy
β π examples
β β π example0.py
β β π example1.py
β β π example2.py
β π snoopy
β β π __init__.py
β β π __main__.py
β β π _version.py
β β π core.py
β β π filtering.py
β β π formatting.py
β β π progress.py
β β π pruning.py
β β π sorting.py
β β π units.py
β π .gitignore
β π LICENSE
β π README.md
β π setup.py
import snoopy
# build a tree of the working directory
tree = snoopy.snoop()
# define the formatting of the tree
fmt = snoopy.Formatter(tree)
# print the tree
print(fmt)
from pathlib import Path
import snoopy
from snoopy import filtering, formatting, progress, sorting
# directory to be snooped
snoopy_path = Path(snoopy.__file__).parent.parent
# get a dog called Barky
barky = snoopy.Dog(
"Barky",
ignore_folder=filtering.chain(
filtering.Name(".git"),
filtering.GitIgnore(snoopy_path / ".gitignore"),
),
)
# let it snoop the directory
with progress.elapsed():
tree = barky.snoop(snoopy_path)
# sort alphabetically
tree = sorting.alphabetic(tree)
# folders come before files
tree = sorting.by_kind(tree)
# define the formatting of the tree
fmt = snoopy.Formatter(
tree,
format_folder=formatting.ItemName(),
format_file=formatting.ItemName(),
max_files_display=2,
)
# display the tree nicely
snoopy.display(fmt)
# save the tree to view it in the browser
snoopy.snapshot(fmt, filename=tree.name + ".html")
# let barky know that he did great!
snoopy.praise(barky)
π snoopy
β π examples
β β π example0.py
β β π example1.py
β β βοΈ [Folders: 0 | Files: 1 | Errors: 0]
β π snoopy
β β π __init__.py
β β π __main__.py
β β βοΈ [Folders: 0 | Files: 8 | Errors: 0]
β π .gitignore
β π LICENSE
β βοΈ [Folders: 0 | Files: 2 | Errors: 0]
Amidst the chaos of my overflowing Google Drive, I met Snoopy, a clever dog with an uncanny knack for data. With a few sniffs and paws at the keyboard, he quickly unearthed the forgotten dataset cluttering my storage. Thanks to Snoopy, my digital rescuer, I avoided the need to upgrade my storage plan.
$ snoopy --good-boy!
>> Woof woof! πΆ
Snoopy's line to also save you from extra charges:
from pathlib import Path
import snoopy
from snoopy import filtering, formatting, pruning, sorting
this_path = Path(__file__).parent
if __name__ == "__main__":
barky = snoopy.Dog(ignore_folder=filtering.hidden, verbosity=1)
tree = barky.snoop(this_path)
tree = sorting.by_size(tree)
tree = pruning.by_size(tree, "<1.0 GB")
fmt = snoopy.Formatter(
tree,
format_folder=formatting.ItemSize(unit="GB"),
format_file=formatting.ItemSize(unit="GB"),
)
snoopy.display(fmt)
snoopy.snapshot(fmt, filename=tree.name + ".html", silent=False)
(text generated by AI)
- Snoopy is an eager dog, which can sometimes be slow. But Snoopy has to be like this because he reports folder sizes, among other things.
- Documentation is currently missing. May your IDE be with you.
- This repository is 65 % useful and 35 % gimmicky.