seedir
seedir is a Python package designed for creating, editing, and displaying folder tree diagrams. It provides a straightforward way to visualize directory structures, supporting both real file systems and 'fake' directory objects for testing or presentation. The library is actively maintained, with its current version being 0.5.1, and receives regular updates.
Warnings
- breaking The `seedir.command_line` module was removed and the command-line interface was revamped.
- breaking The `emoji` package is no longer a core dependency for all installations.
- deprecated The `slash` parameter for defining folder endings has been deprecated.
- gotcha The `itemlimit` parameter for restricting the number of items now accepts a 2-tuple.
- gotcha New parameters were introduced for handling errors during directory listing.
- gotcha The `seedir()` function now directly accepts `pathlib.Path` objects.
Install
-
pip install seedir -
pip install seedir[emoji]
Imports
- seedir
import seedir as sd
- seedir.seedir
from seedir.seedir import seedir
from seedir.realdir import seedir
- seedir.command_line
import seedir.command_line
N/A (removed)
Quickstart
import seedir as sd
import os
# Create a dummy directory structure for demonstration
# In a real scenario, you'd point to an existing path.
# Create a temporary directory and some files/folders
current_dir = os.getcwd()
dummy_path = os.path.join(current_dir, 'seedir_example')
os.makedirs(os.path.join(dummy_path, 'folder1', 'subfolder_a'), exist_ok=True)
os.makedirs(os.path.join(dummy_path, 'folder2'), exist_ok=True)
with open(os.path.join(dummy_path, 'file1.txt'), 'w') as f: f.write('content')
with open(os.path.join(dummy_path, 'folder1', 'file2.txt'), 'w') as f: f.write('content')
# Generate and print the directory tree
print(f"\nDirectory tree for '{dummy_path}':")
sd.seedir(path=dummy_path, style='lines', depthlimit=3)
# Clean up the dummy directory
import shutil
shutil.rmtree(dummy_path)
print("\nCleaned up dummy directory.")