Skip to content
Snippets Groups Projects
Commit e8d563f3 authored by Iustin Pop's avatar Iustin Pop
Browse files

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: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 2503680f
No related branches found
No related tags found
No related merge requests found
...@@ -153,6 +153,14 @@ class ConfigObject(object): ...@@ -153,6 +153,14 @@ class ConfigObject(object):
" _ContainerFromDicts" % c_type) " _ContainerFromDicts" % c_type)
return ret 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): def __repr__(self):
"""Implement __repr__ for ConfigObjects.""" """Implement __repr__ for ConfigObjects."""
return repr(self.ToDict()) return repr(self.ToDict())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment