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 hashes)

Uploaded Source

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