[Checkins] SVN: lovely.recipe/trunk/ see changes

Bernd Dorn bernd.dorn at lovelysystems.com
Thu Feb 5 10:35:13 EST 2009


Log message for revision 96135:
  see changes

Changed:
  U   lovely.recipe/trunk/CHANGES.txt
  U   lovely.recipe/trunk/buildout.cfg
  U   lovely.recipe/trunk/src/lovely/recipe/egg/README.txt
  U   lovely.recipe/trunk/src/lovely/recipe/fs/README.txt
  U   lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py
  U   lovely.recipe/trunk/src/lovely/recipe/fs/mkfile.py

-=-
Modified: lovely.recipe/trunk/CHANGES.txt
===================================================================
--- lovely.recipe/trunk/CHANGES.txt	2009-02-05 15:22:54 UTC (rev 96134)
+++ lovely.recipe/trunk/CHANGES.txt	2009-02-05 15:35:12 UTC (rev 96135)
@@ -5,8 +5,13 @@
 After
 =====
 
-- added the lovely.recipe:eggbox recipe 
+- do the same upon install in update, to recreate directories in
+  mkdir. fixes https://bugs.launchpad.net/lovely.recipe/+bug/322275
 
+- added the variation option to the mkfile recipe
+
+- added the lovely.recipe:eggbox recipe
+
 - INCOMPATIBLE CHANGE: moved zope recipies into an extra called "zope"
   this requires one to write the extra in the recipe declaraion like
   this lovely.recipe[zope]:<name>

Modified: lovely.recipe/trunk/buildout.cfg
===================================================================
--- lovely.recipe/trunk/buildout.cfg	2009-02-05 15:22:54 UTC (rev 96134)
+++ lovely.recipe/trunk/buildout.cfg	2009-02-05 15:35:12 UTC (rev 96135)
@@ -2,8 +2,7 @@
 develop = .
 parts = test
 
-
 [test]
 recipe = zc.recipe.testrunner
 eggs = lovely.recipe[zope]
-
+defaults = ['--auto-color']

Modified: lovely.recipe/trunk/src/lovely/recipe/egg/README.txt
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/egg/README.txt	2009-02-05 15:22:54 UTC (rev 96134)
+++ lovely.recipe/trunk/src/lovely/recipe/egg/README.txt	2009-02-05 15:35:12 UTC (rev 96135)
@@ -23,6 +23,7 @@
     ...        pytz
     ... """)
     >>> print system(buildout),
+    Getting...
     Installing packages.
 
 We now have a zip file for each top-level directory. Note that the
@@ -30,17 +31,7 @@
 
     >>> ls(sample_buildout + '/parts/packages')
     -  BTrees.egg
-    -  RestrictedPython.egg
-    -  ThreadedAsync.egg
-    -  ZConfig.egg
-    -  ZEO.egg
-    -  ZODB.egg
-    -  ZopeUndo.egg
-    -  persistent.egg
-    -  pytz.egg
-    -  transaction.egg
-    -  zdaemon.egg
-    -  zodbcode.egg
+    -  RestrictedPython.egg...
     -  zope.egg
 
 It is possible to disable zipping. And also to exclude or include

Modified: lovely.recipe/trunk/src/lovely/recipe/fs/README.txt
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/fs/README.txt	2009-02-05 15:22:54 UTC (rev 96134)
+++ lovely.recipe/trunk/src/lovely/recipe/fs/README.txt	2009-02-05 15:35:12 UTC (rev 96135)
@@ -106,7 +106,16 @@
     >>> ls(sample_buildout + '/with')
     d  subdir
 
+There is no update method so the install method is used upon update
+and the directories get recreated.
 
+    >>> rmdir(sample_buildout + '/with')
+    >>> print system(buildout),
+    Updating data-dir.
+    The recipe for data-dir doesn't define an update method. Using its install method.
+    data-dir: Creating parent directory /sample-buildout/with
+    data-dir: Creating directory /sample-buildout/with/subdir
+
 We can change the owner of the created directory if run as root. This is tested
 in mkdir-root.txt.
 
@@ -157,7 +166,7 @@
 Creating Files
 ==============
 
-The mkfile recipe creates a file with a given path, content and
+The mkfile recipe creates one or more files with a given path, content and
 permissions.
 
     >>> write(sample_buildout, 'buildout.cfg',
@@ -255,3 +264,34 @@
     >>> ls(sample_buildout + '/subdir/for/file')
     -  file.sh
 
+
+File Variations
+---------------
+
+A common use-case is to have variations of a file, for example if init
+scripts have to be created. As an example we create two files with
+variations "1" and "2". These variations can be used in the file path
+and in the content of the file via normal string formatting notation.
+
+    >>> write(sample_buildout, 'buildout.cfg',
+    ... """
+    ... [buildout]
+    ... parts = script
+    ...
+    ... [script]
+    ... recipe = lovely.recipe:mkfile
+    ... variations = 1 2
+    ... path = prod_%(variation)s.ini
+    ... content = hoschi variation %(variation)s
+    ... mode = 0755
+    ... """)
+    >>> print system(buildout)
+    Uninstalling script.
+    Installing script.
+    script: Writing file ...sample-buildout/prod_1.ini
+    script: Writing file ...sample-buildout/prod_2.ini
+
+    >>> cat(sample_buildout, 'prod_1.ini')
+    hoschi variation 1
+    >>> cat(sample_buildout, 'prod_2.ini')
+    hoschi variation 2

Modified: lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py	2009-02-05 15:22:54 UTC (rev 96134)
+++ lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py	2009-02-05 15:35:12 UTC (rev 96135)
@@ -51,6 +51,3 @@
             os.chown(path, uid, -1)
         return ()
 
-    def update(self):
-        pass
-

Modified: lovely.recipe/trunk/src/lovely/recipe/fs/mkfile.py
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/fs/mkfile.py	2009-02-05 15:22:54 UTC (rev 96134)
+++ lovely.recipe/trunk/src/lovely/recipe/fs/mkfile.py	2009-02-05 15:35:12 UTC (rev 96135)
@@ -9,18 +9,20 @@
         self.name = name
         self.options = options
         self.mode = int(options.get('mode', '0644'), 8)
+        self.variations = options.get('variations', '').strip().split()
         options['content']
         self.originalPath = options['path']
         options['path'] = os.path.join(
                               buildout['buildout']['directory'],
                               self.originalPath,
                               )
-        self.createPath = options.get('createpath', 'False').lower() in ['true', 'on', '1']
+        self.createPath = options.get('createpath', 'False').lower() \
+            in ['true', 'on', '1']
 
-    def install(self):
-        filename = self.options['path']
+    def _write(self, variation):
+        d = dict(variation=variation)
+        filename = self.options['path'] % d
         dirname = os.path.dirname(self.options['path'])
-
         if not os.path.isdir(dirname):
             if self.createPath:
                 logging.getLogger(self.name).info(
@@ -35,7 +37,16 @@
         f = file(filename, 'w')
         logging.getLogger(self.name).info(
             'Writing file %s', filename)
-        f.write(self.options['content'])
+        f.write(self.options['content'] % d)
         f.close()
         os.chmod(filename, self.mode)
         return filename
+
+    def install(self):
+        res = []
+        if self.variations:
+            for v in self.variations:
+                res.append(self._write(v))
+        else:
+            res.append(self._write(None))
+        return res



More information about the Checkins mailing list