Add append_with_space method.
authorCarl Hetherington <cth@carlh.net>
Thu, 8 May 2014 23:37:14 +0000 (00:37 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 8 May 2014 23:37:14 +0000 (00:37 +0100)
cdist

diff --git a/cdist b/cdist
index a5e99636f3a6f9af3344b52b7f2b69c887cb3af3..89bc719350003f4588919ae6a45d87680818c938 100755 (executable)
--- a/cdist
+++ b/cdist
@@ -246,6 +246,12 @@ class Target(object):
     def get(self, a):
         return self.variables[a]
 
+    def append_with_space(self, k, v):
+        if not k in self.variables:
+            self.variables[k] = v
+        else:
+            self.variables[k] = '%s %s' % (self.variables[k], v)
+
     def variables_string(self, escaped_quotes=False):
         e = ''
         for k, v in self.variables.iteritems():