Load a Linux/Unix/Windows directory tree into a nested Python dictionary
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dirtree
LICENSE
README.md
setup.py

README.md

python-dirtree

Load a Linux/Unix/Windows directory tree into a nested Python dictionary

Example

from dirtree import Walk

dirtree = Walk('/etc')

# move the file virtually (in the nested dictionary, not in the disk)
dirtree.move('fstab', 'moved-fstab')

# create virtually /etc/another-dir
#
# create a directory in the virtual tree. The directory' path will be
# /etc/another-dir (because 'dirtree' represents the root path /etc/)
dirtree.mkdir('another-dir')

# remove the directory /etc/systemd/ from 'dirtee'
dirtree.remove('systemd')

# show the tree
print(dirtree)