Commit 52f27dae authored by Luis Araujo's avatar Luis Araujo

Deep copy the 'original' hash on merge profiles operation

- Create a deep copy of the original hash during merging profiles
  avoiding to modify it for future calls.

- Split merge_profiles definition into a new utils module.

- Bump version to 20150124.0
parent fa933cb7
......@@ -28,6 +28,7 @@ import os.path
from xmlrpclib import ServerProxy, Fault
from argparse import ArgumentParser
import lqa_tool.utils
from lqa_tool.version import __version__
CONFIG_PATH='/etc/lqa/'
......@@ -138,7 +139,7 @@ class Lava(object):
if self.args.profile and not profile['name'] in self.args.profile:
continue
# Merge main-profile with available profiles and run!
self._run(_merge_profiles(main_profile, profile))
self._run(utils.merge_profiles(main_profile, profile))
else:
self._run()
......@@ -354,14 +355,3 @@ def find_config_file(arg_config, default_config, logger):
exit(1)
return config
def _merge_profiles(original, update):
"""Merge two hashes.
This is used to merge profiles.
"""
for k, v in update.iteritems():
if type(v) == dict and (k in original and type(original[k]) == dict):
_merge_profiles(original[k], update[k])
else:
original[k] = update[k]
return original
#!/usr/bin/env python
###################################################################################
# Utilities for the LAVA QA tool
# Copyright (C) 2015 Luis Araujo <luis.araujo@collabora.co.uk>
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US
###################################################################################
import copy
def merge_profiles(original, update):
"""Merge two hashes. This is used to merge profiles."""
def _merge_profiles(original, update):
for k, v in update.iteritems():
if type(v) == dict and (k in original and type(original[k]) == dict):
_merge_profiles(original[k], update[k])
else:
original[k] = update[k]
return original
original_copy = copy.deepcopy(original)
return _merge_profiles(original_copy, update)
# Version variable
__version__='20150120.0'
__version__='20150124.0'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment