seedir

0.5.1 · active · verified Wed Apr 15

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

Install

Imports

Quickstart

This quickstart demonstrates how to use `seedir.seedir()` to print a directory tree. It first creates a temporary directory structure and then visualizes it using the 'lines' style, limiting the depth for conciseness. Finally, it cleans up the created dummy directory.

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.")

view raw JSON →