Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Quickly make files and directory structures.

Project Description

treeshape allows you to quickly make file and directory structures on disk.

For example:

from treeshape import (

make_tree('.', {
    'logs/': None,
    'README': {CONTENT: "A simple directory layout\n"},
    'data/input': {CONTENT: "All of our input data\n"},
    'bin/script': {CONTENT: "#!/bin/sh\necho 'Hello'\n", PERMISSIONS: 0755},

Will create a directory structure that looks like this:

$ find .
$ cat README
A simple directory layout
$ cat data/input
All of our input data

This is particularly useful for tests that touch the disk.

If being explicit isn’t really your thing, you can also create the same directory structure from a rough specification:

from treeshape import (

make_tree('.', from_rough_spec([
    ('README', "A simple directory layout\n"),
    ('data/input', "All of our input data\n"),
    ('bin/script', "#!/bin/sh\necho 'Hello'\n", 0755),

This is also provided as a Fixture (see python-fixtures). Thus, if you are using testtools, then you can also do this during your tests:

def test_a_thing(self):
        ('README', "A simple directory layout\n"),
        ('data/input', "All of our input data\n"),
    # your test here

Release History

This version
History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(9.5 kB) Copy SHA256 Hash SHA256
Source None Sep 3, 2012

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers