Skip to main content

Buildout recipe to create directories.

Project description

Introduction

This recipe can be used to generate directories.

A short example:

[buildout]
parts = var

[var]
recipe = z3c.recipe.mkdir

This will create a directory named var/ in the buildout parts/ directory. If you want a different path, you can set the path option:

[buildout]
parts = foo

[foo]
recipe = z3c.recipe.mkdir
path = foo/bar

which will create ‘foo/bar/’ in the buildout root directory (not the parts/ directory). Also intermediate directories are created (if they do not exist).

Detailed Description

Simple creation of directories via buildout

Lets create a minimal buildout.cfg file:

>>> write('buildout.cfg',
... '''
... [buildout]
... parts = mydir
... offline = true
...
... [mydir]
... recipe = z3c.recipe.mkdir
... ''')

Now we can run buildout:

>>> print system(join('bin', 'buildout')),
Installing mydir.

The directory was indeed created in the parts directory:

>>> ls('parts')
d  mydir

As we did not specify a special path, the name of the created directory is like the section name mydir.

Creating a directory in a given path

Lets create a minimal buildout.cfg file. This time the directory has a name different from section name and we have to tell explicitly, that we want it to be created in the parts/ directory:

>>> write('buildout.cfg',
... '''
... [buildout]
... parts = mydir
... offline = true
...
... [mydir]
... recipe = z3c.recipe.mkdir
... path = ${buildout:parts-directory}/myotherdir
... ''')

Now we can run buildout:

>>> print system(join('bin', 'buildout')),
Uninstalling mydir.
Installing mydir.

The directory was indeed created:

>>> ls('parts')
d  myotherdir

Creating relative paths

If we specify a relative path, this path will be read relative to the buildout directory:

>>> write('buildout.cfg',
... '''
... [buildout]
... parts = mydir
... offline = true
...
... [mydir]
... recipe = z3c.recipe.mkdir
... path = myrootdir
... ''')
>>> print system(join('bin', 'buildout')),
Uninstalling mydir.
Installing mydir.
>>> ls('.')
-  .installed.cfg
d  bin
-  buildout.cfg
d  develop-eggs
d  eggs
d  myrootdir
d  parts

The old directory will vanish:

>>> ls('parts') is None
True

Creating intermediate paths

If we specify several levels of directories, the intermediate parts will be created for us as well:

>>> write('buildout.cfg',
... '''
... [buildout]
... parts = mydir
... offline = true
...
... [mydir]
... recipe = z3c.recipe.mkdir
... path = myrootdir/other/dir/finaldir
... ''')
>>> print system(join('bin', 'buildout')),
Uninstalling mydir.
Installing mydir.
>>> ls('myrootdir', 'other', 'dir')
d  finaldir

Changes

0.1 (2009-08-17)

Initial release.

Project details


Download files

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

Source Distribution

z3c.recipe.mkdir-0.1.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file z3c.recipe.mkdir-0.1.tar.gz.

File metadata

File hashes

Hashes for z3c.recipe.mkdir-0.1.tar.gz
Algorithm Hash digest
SHA256 38097db0a9fd65b2edc4682d8d84a47616fc89bfedaaa8f934c6ae66e9401b9b
MD5 bea3a3044f1d450a2f69c33ae3e3b946
BLAKE2b-256 6c73a168baa733eb7dca8879293c816d9358e519abeb9ea392bc9693f73b6178

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page