[Checkins] SVN: z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/ Better newline addition in front of BUILDOUT= by only doing it the first time.

Reinout van Rees reinout at vanrees.org
Mon Jun 15 11:13:23 EDT 2009


Log message for revision 101011:
  Better newline addition in front of BUILDOUT= by only doing it the first time.

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

-=-
Modified: z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/README.txt
===================================================================
--- z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/README.txt	2009-06-15 15:03:24 UTC (rev 101010)
+++ z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/README.txt	2009-06-15 15:13:23 UTC (rev 101011)
@@ -131,6 +131,7 @@
     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")
@@ -138,6 +139,7 @@
     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"
@@ -147,10 +149,12 @@
     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"
 
@@ -165,10 +169,12 @@
     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
@@ -186,11 +192,13 @@
     @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:
+item should now be inside the environment, without a double (and with a
+newline before the BUILDOUT environment variable for better readability):
 
     >>> c.add_entry('@reboot echo nothing happens', BUILDOUT="my/buildout")
     >>> print c # doctest: +REPORT_NDIFF
     WARNING=The entries below were generated by buildout, do not modify
+    <BLANKLINE>
     BUILDOUT=my/buildout
     @reboot echo nothing happens
 
@@ -276,11 +284,8 @@
 The entries are grouped per buildout (with a blank line in front of every
 BUILDOUT line for better readability):
 
-    >>> print c # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
-    WARNING=The entries below were generated by buildout, do not modify
-    <BLANKLINE>
-    BUILDOUT=.../sample-buildout
-    # @reboot   echo nothing happens
+    >>> '\n\nBUILDOUT=' in repr(c)
+    True
 
 Uninstall the recipe:
 

Modified: z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/usercrontab.py
===================================================================
--- z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/usercrontab.py	2009-06-15 15:03:24 UTC (rev 101010)
+++ z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/usercrontab.py	2009-06-15 15:13:23 UTC (rev 101011)
@@ -96,9 +96,6 @@
     def write_crontab(self):
         fd = os.popen(self.writecrontab, "w")
         for l in self.crontab:
-            if l.startswith('BUILDOUT='):
-                # empty line for better between-buildout visual separation.
-                fd.write('\n')
             fd.write("%s\n" % l)
         fd.close()
 
@@ -144,6 +141,9 @@
         if (not done):
             for (k, v) in env.iteritems():
                 if k not in cur_env or cur_env[k] != v:
+                    if k == 'BUILDOUT':
+                        # empty line for better between-buildout visual separation.
+                        new_crontab.append('')
                     new_crontab.append('%s=%s' % (escape_string(k),
                                                   escape_string(v)))
             new_crontab.append(entry)



More information about the Checkins mailing list