Skip to content

Commit

Permalink
base: add PropertyHolder.clone_properties
Browse files Browse the repository at this point in the history
Be compatible with core-admin
  • Loading branch information
marmarek committed Jun 19, 2017
1 parent 12fd4eb commit e94bdca
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions qubesadmin/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,23 @@ def property_is_default(self, item):
assert isinstance(is_default, bool)
return is_default

def clone_properties(self, src, proplist=None):
'''Clone properties from other object.
:param PropertyHolder src: source object
:param list proplist: list of properties \
(:py:obj:`None` or omit for all properties)
'''

if proplist is None:
proplist = self.property_list()

for prop in proplist:
try:
setattr(self, prop, getattr(src, prop))
except AttributeError:
continue

def __getattr__(self, item):
# pylint: disable=too-many-return-statements
if item.startswith('_'):
Expand Down

0 comments on commit e94bdca

Please sign in to comment.