[Checkins] SVN: z3c.recipe.usercrontab/trunk/ Reverted the "BUILDOUT=..." environment variable, including migration. I'll

Reinout van Rees reinout at vanrees.org
Tue Jun 16 04:56:18 EDT 2009


Log message for revision 101047:
  Reverted the "BUILDOUT=..." environment variable, including migration.  I'll
  add a better way after this release.
  

Changed:
  U   z3c.recipe.usercrontab/trunk/CHANGES.txt
  U   z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/README.txt
  U   z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/__init__.py
  U   z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/usercrontab.py

-=-
Modified: z3c.recipe.usercrontab/trunk/CHANGES.txt
===================================================================
--- z3c.recipe.usercrontab/trunk/CHANGES.txt	2009-06-16 08:44:57 UTC (rev 101046)
+++ z3c.recipe.usercrontab/trunk/CHANGES.txt	2009-06-16 08:56:18 UTC (rev 101047)
@@ -4,7 +4,8 @@
 0.6 (unreleased)
 ----------------
 
-- Nothing changed yet.
+- Reverted the "BUILDOUT=..." environment variable, including migration.  I'll
+  add a better way after this release.  [reinout] 
 
 
 0.5 (2009-06-15)

Modified: z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/README.txt
===================================================================
--- z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/README.txt	2009-06-16 08:44:57 UTC (rev 101046)
+++ z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/README.txt	2009-06-16 08:56:18 UTC (rev 101047)
@@ -1,3 +1,5 @@
+.. -*- mode: doctest -*-
+
 # Copyright (c) 2009 Zope Foundation and contributors.
 # All Rights Reserved.
 #
@@ -118,88 +120,22 @@
     MAILTO=""
     @reboot echo "No-one will see this"
 
-When introducing a new environment variable to leave markers which buildout is
-used, the mix between the environment is right:
+Briefly in the 0.5 version, a 'BUILDOUT' environment variable was used for
+grouping items per buildout. Now for some up/downgrade testing.  0.5.1 removes
+the environment variable again. We'll add an entry with such a (now
+deprecated) "grouping environment variable". First the start situation:
 
-    >>> c.crontab = ['MAILTO=""', 'BUILDOUT=my/path', '@reboot echo "no mailto, my/path"']
-    >>> print c
-    MAILTO=""
-    BUILDOUT=my/path
-    @reboot echo "no mailto, my/path"
-    >>> c.add_entry('@reboot echo "no mailto, my/other"', MAILTO="", BUILDOUT="my/other")
-    >>> print c
-    MAILTO=""
-    BUILDOUT=my/path
-    @reboot echo "no mailto, my/path"
-    <BLANKLINE>
-    BUILDOUT=my/other
-    @reboot echo "no mailto, my/other"
-    >>> c.add_entry('@reboot echo "no mailto, my/other, bla"', MAILTO="", BUILDOUT="my/other")
-    >>> print c
-    MAILTO=""
-    BUILDOUT=my/path
-    @reboot echo "no mailto, my/path"
-    <BLANKLINE>
-    BUILDOUT=my/other
-    @reboot echo "no mailto, my/other, bla"
-    @reboot echo "no mailto, my/other"
-    >>> c.add_entry('@reboot echo "mailto example, my/path"',
-    ...             MAILTO="something at example.com", BUILDOUT="my/path")
-    >>> print c
-    MAILTO=""
-    BUILDOUT=my/path
-    @reboot echo "no mailto, my/path"
-    <BLANKLINE>
-    BUILDOUT=my/other
-    @reboot echo "no mailto, my/other, bla"
-    @reboot echo "no mailto, my/other"
-    MAILTO=something at example.com
-    <BLANKLINE>
-    BUILDOUT=my/path
-    @reboot echo "mailto example, my/path"
-
-Adding an extra environment variable to an existing entry results in a second
-entry, but with the extra environment variable.  This is technically correct,
-but it might warrant an exception. TODO.
-
-    >>> c.add_entry('@reboot echo "mailto example, my/path"',
-    ...             MAILTO="something at example.com", BUILDOUT="my/path",
-    ...             BLA='bla')
-    >>> print c
-    MAILTO=""
-    BUILDOUT=my/path
-    @reboot echo "no mailto, my/path"
-    <BLANKLINE>
-    BUILDOUT=my/other
-    @reboot echo "no mailto, my/other, bla"
-    @reboot echo "no mailto, my/other"
-    MAILTO=something at example.com
-    <BLANKLINE>
-    BUILDOUT=my/path
-    @reboot echo "mailto example, my/path"
-    BLA=bla
-    @reboot echo "mailto example, my/path"
-
-The environment variable is mainly used for grouping items per buildout. Now
-for some upgrade testing.  Pre-0.5 versions of this recipe did not group
-entries per buildout.  We'll add an entry without such a "grouping environment
-variable". First the start situation:
-
-    >>> c.crontab=['WARNING=The entries below were generated by buildout, do not modify',
-    ...            '@reboot echo nothing happens']
+    >>> c.crontab=[
+    ...     'BUILDOUT=my/buildout',
+    ...     '@reboot echo nothing happens']
     >>> print c # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
-    WARNING=The entries below were generated by buildout, do not modify
-    @reboot echo nothing happens    
+    BUILDOUT=my/buildout
+    @reboot echo nothing happens
 
-Now we add a similar entry, but with a BUILDOUT environment variable.  The old
-item should now be inside the environment, without a double (and with a
-newline before the BUILDOUT environment variable for better readability):
+Now we add a similar entry. The BUILDOUT statement is removed:
 
-    >>> c.add_entry('@reboot echo nothing happens', BUILDOUT="my/buildout")
+    >>> c.add_entry('@reboot echo nothing happens')
     >>> print c # doctest: +REPORT_NDIFF
-    WARNING=The entries below were generated by buildout, do not modify
-    <BLANKLINE>
-    BUILDOUT=my/buildout
     @reboot echo nothing happens
 
 
@@ -281,12 +217,6 @@
     >>> 'WARNING=The entries below were generated by buildout, do not modify' in c.crontab
     True
 
-The entries are grouped per buildout (with a blank line in front of every
-BUILDOUT line for better readability):
-
-    >>> '\n\nBUILDOUT=' in repr(c)
-    True
-
 Uninstall the recipe:
 
     >>> print system(os.path.join('bin', 'buildout')+' buildout:parts=')

Modified: z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/__init__.py
===================================================================
--- z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/__init__.py	2009-06-16 08:44:57 UTC (rev 101046)
+++ z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/__init__.py	2009-06-16 08:56:18 UTC (rev 101047)
@@ -25,7 +25,7 @@
         self.env = {
             'WARNING':
             'The entries below were generated by buildout, do not modify',
-            'BUILDOUT': buildout['buildout']['directory']
+            #'BUILDOUT': buildout['buildout']['directory']
             }
 
     def install(self):

Modified: z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/usercrontab.py
===================================================================
--- z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/usercrontab.py	2009-06-16 08:44:57 UTC (rev 101046)
+++ z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/usercrontab.py	2009-06-16 08:56:18 UTC (rev 101047)
@@ -117,25 +117,17 @@
                 # We have an environment statement ('MAILTO=something')
                 env_key = match.group(1)
                 env_value = match.group(2)
+                if env_key == 'BUILDOUT':
+                    # Feature only available in 0.5, reverted in 0.5.1: we
+                    # omit this environment variable now.
+                    continue
                 cur_env[unescape_string(env_key)] = unescape_string(env_value)
-            if (entry == line and
-                'BUILDOUT' in env and
-                'BUILDOUT' not in cur_env):
-                # Possibly line we have to migrate post-0.4.
-                temp_env = cur_env.copy()
-                temp_env['BUILDOUT'] = env['BUILDOUT']
-                if dict_pmatch(env, temp_env):
-                    # Don't copy the entry, it will be added in the proper
-                    # environment later.
-                    pass
-                else:
-                    # Normal behaviour, just copy the line.
-                    new_crontab.append(line)
-            else:
-                # Normal behaviour, just copy the line.
-                new_crontab.append(line)
+
+            new_crontab.append(line)
             if not done and dict_pmatch(env, cur_env):
-                new_crontab.append(entry)
+                if line != entry:
+                    # Not already added 3 lines above...
+                    new_crontab.append(entry)
                 done = True
 
         if (not done):



More information about the Checkins mailing list