[Buildbot-commits] buildbot/buildbot/process properties.py, 1.7, 1.8

Brian Warner warner at users.sourceforge.net
Mon May 26 23:52:29 UTC 2008


Update of /cvsroot/buildbot/buildbot/buildbot/process
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv22252/buildbot/process

Modified Files:
	properties.py 
Log Message:
[project @ #124:properties_py_comments.patch]
Additional comments, docstrings in properties.py

Original author: dustin at v.igoro.us
Date: 2008-04-15 15:17:50+00:00

Index: properties.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/properties.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- properties.py	26 May 2008 23:52:23 -0000	1.7
+++ properties.py	26 May 2008 23:52:27 -0000	1.8
@@ -65,7 +65,6 @@
         return repr(dict([ (k,v[0]) for k,v in self.properties.iteritems() ]))
 
     def setProperty(self, name, value, source):
-        self._wpmap = None
         self.properties[name] = (value, source)
 
     def update(self, dict, source):
@@ -82,6 +81,8 @@
         Return a variant of value that has any WithProperties objects
         substituted.  This recurses into Python's compound data types.
         """
+        # we use isinstance to detect Python's standard data types, and call
+        # this function recursively for the values in those types
         if isinstance(value, (str, unicode)):
             return value
         elif isinstance(value, WithProperties):
@@ -96,6 +97,10 @@
             return value
 
 class PropertyMap:
+    """
+    Privately-used mapping object to implement WithProperties' substitutions,
+    including the rendering of None as ''.
+    """
     colon_minus_re = re.compile(r"(.*):-(.*)")
     colon_plus_re = re.compile(r"(.*):\+(.*)")
     def __init__(self, properties):
@@ -106,6 +111,8 @@
         properties = self.properties()
         assert properties is not None
 
+        # %(prop:-repl)s
+        # if prop exists, use it; otherwise, use repl
         mo = self.colon_minus_re.match(key)
         if mo:
             prop, repl = mo.group(1,2)
@@ -114,6 +121,8 @@
             else:
                 rv = repl
         else:
+            # %(prop:+repl)s
+            # if prop exists, use repl; otherwise, an empty string
             mo = self.colon_plus_re.match(key)
             if mo:
                 prop, repl = mo.group(1,2)
@@ -129,8 +138,9 @@
         return rv
 
 class WithProperties(util.ComparableMixin):
-    """This is a marker class, used in ShellCommand's command= argument to
-    indicate that we want to interpolate a build property.
+    """
+    This is a marker class, used fairly widely to indicate that we
+    want to interpolate build properties.
     """
 
     compare_attrs = ('fmtstring', 'args')





More information about the Commits mailing list