[Checkins] SVN: z3c.recipe.filetemplate/trunk/ add work by Bruno Binet for excluding directories from a source directory and prepare for release
Gary Poster
gary.poster at canonical.com
Thu Sep 1 17:02:39 EST 2011
Log message for revision 122714:
add work by Bruno Binet for excluding directories from a source directory and prepare for release
Changed:
U z3c.recipe.filetemplate/trunk/CHANGES.txt
U z3c.recipe.filetemplate/trunk/setup.py
U z3c.recipe.filetemplate/trunk/z3c/recipe/filetemplate/README.txt
U z3c.recipe.filetemplate/trunk/z3c/recipe/filetemplate/__init__.py
-=-
Modified: z3c.recipe.filetemplate/trunk/CHANGES.txt
===================================================================
--- z3c.recipe.filetemplate/trunk/CHANGES.txt 2011-09-01 19:18:54 UTC (rev 122713)
+++ z3c.recipe.filetemplate/trunk/CHANGES.txt 2011-09-01 22:02:38 UTC (rev 122714)
@@ -2,13 +2,16 @@
Changes
=======
-2.1.1 (Unreleased)
+2.2.0 (2011-09-01)
==================
--------
Features
--------
+- Add support for excluding some subdirectories of the ``source-directory``
+ with the ``exclude-directories`` option. [Bruno Binet]
+
-----
Fixes
-----
Modified: z3c.recipe.filetemplate/trunk/setup.py
===================================================================
--- z3c.recipe.filetemplate/trunk/setup.py 2011-09-01 19:18:54 UTC (rev 122713)
+++ z3c.recipe.filetemplate/trunk/setup.py 2011-09-01 22:02:38 UTC (rev 122714)
@@ -19,7 +19,7 @@
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='z3c.recipe.filetemplate',
- version = '2.1.1dev',
+ version = '2.2.0',
license='ZPL 2.1',
url='http://pypi.python.org/pypi/z3c.recipe.filetemplate',
description="zc.buildout recipe for creating files from file templates",
Modified: z3c.recipe.filetemplate/trunk/z3c/recipe/filetemplate/README.txt
===================================================================
--- z3c.recipe.filetemplate/trunk/z3c/recipe/filetemplate/README.txt 2011-09-01 19:18:54 UTC (rev 122713)
+++ z3c.recipe.filetemplate/trunk/z3c/recipe/filetemplate/README.txt 2011-09-01 22:02:38 UTC (rev 122714)
@@ -106,7 +106,8 @@
First, we specify a ``source-directory`` in the buildout. You can specify
``files`` as a filter if desired, but by default it will find any file (ending
-with ".in").
+with ".in"). You can also specify ``exclude-directories`` option if you want
+to exclude some paths from the ``source-directory`` search path.
>>> write(sample_buildout, 'buildout.cfg',
... """
@@ -224,6 +225,45 @@
Also note that, if you use a source directory and your ``files`` specify a
directory, the directory must match precisely.
+With the ``exclude-directories`` parameter, we specify one or more directories
+(separated by whitespace) in which the recipe will not look for template
+files. The ``exclude-directories`` option should be used along with the
+``source-directory`` option.
+Therefore, if we set ``exclude-directories`` to ``bin``, the
+``bin/helloworld.sh`` file will disappear.
+
+ >>> write(sample_buildout, 'buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts = message
+ ...
+ ... [message]
+ ... recipe = z3c.recipe.filetemplate
+ ... source-directory = template
+ ... exclude-directories = bin
+ ... world = Philipp
+ ... """)
+
+ >>> print system(buildout)
+ Uninstalling message.
+ Installing message.
+ >>> ls(sample_buildout)
+ - .installed.cfg
+ d bin
+ - buildout.cfg
+ d develop-eggs
+ d eggs
+ d etc
+ - helloworld.txt.in
+ d parts
+ d template
+
+ >>> ls(sample_buildout, 'etc')
+ - helloworld.conf
+
+ >>> ls(sample_buildout, 'bin')
+ - buildout
+
>>> # Clean up for later test.
>>> import shutil
>>> shutil.rmtree(os.path.join(sample_buildout, 'template', 'etc'))
Modified: z3c.recipe.filetemplate/trunk/z3c/recipe/filetemplate/__init__.py
===================================================================
--- z3c.recipe.filetemplate/trunk/z3c/recipe/filetemplate/__init__.py 2011-09-01 19:18:54 UTC (rev 122713)
+++ z3c.recipe.filetemplate/trunk/z3c/recipe/filetemplate/__init__.py 2011-09-01 22:02:38 UTC (rev 122714)
@@ -77,6 +77,7 @@
# get and check the files to be created
self.filenames = self.options.get('files', '*').split()
self.source_dir = self.options.get('source-directory', '').strip()
+ self.exclude_dirs = self.options.get('exclude-directories', '').split()
here = zc.buildout.easy_install.realpath(
self.buildout['buildout']['directory'])
self.destination_dir = here
@@ -111,6 +112,10 @@
if self.recursive:
def visit(ignored, dirname, names):
relative_prefix = dirname[len(self.source_dir)+1:]
+ if relative_prefix in self.exclude_dirs:
+ # exclude current directory and its subdirectories
+ del names[:]
+ return
file_info = {}
for name in names:
val = os.path.join(relative_prefix, name)
More information about the checkins
mailing list