Skip to main content

treeshape

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

For example:

from treeshape import (
    CONTENT,
    make_tree,
    PERMISSIONS,
    )

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 .
.
./logs
./data
./data/input
./README
$ 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 (
    from_rough_spec,
    make_tree,
    )

make_tree('.', from_rough_spec([
    'logs/',
    ('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):
    self.useFixture(FileTree(from_rough_spec([
        'logs/',
        ('README', "A simple directory layout\n"),
        ('data/input', "All of our input data\n"),
        ])))
    # your test here

Metadata

Release files for treeshape 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for treeshape 0.2.1
File Size Uploaded Provenance Actions
treeshape-0.2.1.tar.gz 9.5 kB Without provenance Details for treeshape-0.2.1.tar.gz

Release files / treeshape-0.2.1.tar.gz

Download URL treeshape-0.2.1.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5afaf99c277e35e1f18d75af8f6d35c089353302dada35de51d9a1869377a0e8
BLAKE2b-256 checksum
How to use checksums
b5449d3b3a60c7e65b062ab58927bd0a20faf038888783e94bd77992304cede2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for treeshape 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page