From e8d563f39195fd6e337c0efd05727cf54d9b1193 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Sun, 26 Jul 2009 21:46:07 +0200
Subject: [PATCH] Add a Copy method to object.ConfigObject

This small patch adds a simple Copy method that is can be used for
'throw-away' copies of objects.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/objects.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/objects.py b/lib/objects.py
index 8106287e8..cc3307dce 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -153,6 +153,14 @@ class ConfigObject(object):
                       " _ContainerFromDicts" % c_type)
     return ret
 
+  def Copy(self):
+    """Makes a deep copy of the current object and its children.
+
+    """
+    dict_form = self.ToDict()
+    clone_obj = self.__class__.FromDict(dict_form)
+    return clone_obj
+
   def __repr__(self):
     """Implement __repr__ for ConfigObjects."""
     return repr(self.ToDict())
-- 
GitLab