[Checkins] SVN: z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/usercrontab.py regex is now verbose. I actually understand it now :-)

Reinout van Rees reinout at vanrees.org
Mon Jun 15 06:16:11 EDT 2009


Log message for revision 100964:
  regex is now verbose. I actually understand it now :-)
  

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

-=-
Modified: z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/usercrontab.py
===================================================================
--- z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/usercrontab.py	2009-06-15 10:14:26 UTC (rev 100963)
+++ z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/usercrontab.py	2009-06-15 10:16:10 UTC (rev 100964)
@@ -49,9 +49,30 @@
     return True
 
 
-env_re = re.compile(r'^("[^"]*"|\'[^\']*\'|[^\s]+)\s*='
-                     '\s*("[^"]*"|\'[^\']*\'|[^"\']+)?[^\s]*$')
+env_re = re.compile(
+    r'''
+    ^            # Start of line
+    (            # begin first group
+    "[^"]*"      #   something enclosed in double quotes
+    |\'[^\']*\'  #   OR something enclosed in single quotes
+    |[^\s]+      #   OR some non-space-containing string
+    )            # end first group
 
+    \s*=\s*      # "=" surrounded by spaces
+
+    (            # start second group
+    "[^"]*"      #   something enclosed in double quotes
+    |\'[^\']*\'  #   OR something enclosed in single quotes
+    |[^"\']+     #   OR something that does not have quotes
+    )?           # end of *optional* second group
+
+    [^\s]*       # trailing whitespace
+    $            # end of line
+    ''',
+    re.VERBOSE)
+
+
+
 defaultreadcrontab = "crontab -l"
 defaultwritecrontab = "crontab -"
 



More information about the Checkins mailing list