From b111040a9308d9c25a8e05f0ba76c54b15d1e642 Mon Sep 17 00:00:00 2001 From: Yonghee Han Date: Tue, 14 Mar 2017 20:59:00 +0900 Subject: [PATCH] Delete duplicate items for the abs and prerelease Delete prerelease items. Choice the abs item. Remove the duplicate function Change-Id: I8f878eb33768e97397a7906542b94e45cd3f51ba --- common/mapping.py | 65 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/common/mapping.py b/common/mapping.py index ba6d93b..a357fc1 100644 --- a/common/mapping.py +++ b/common/mapping.py @@ -214,6 +214,43 @@ class MappingV2(object): return mapping +def remove_overlaps(orig_list): + """docstring for make_unique""" + result = [] + [result.append(obj) for obj in orig_list if obj not in result] + # Delete duplicate items for the abs and prerelease + # Delete prerelease items. Choice the abs item. + prjs = {} + for obj in result: + if obj.get('OBS_project') not in prjs: + prjs[obj.get('OBS_project')] = [ prj for prj in result \ + if prj.get('OBS_project') == obj.get('OBS_project') ] + for obj in prjs: + prerelease_index = abs_index = -1 + i = 0 + for prj in prjs[obj]: + if 'prerelease' == prj.get('OBS_staging_project'): + prerelease_index = i + if 'abs' == prj.get('OBS_staging_project'): + abs_index = i + i += 1 + if prerelease_index != -1 and abs_index != -1: + prjs[obj].pop(prerelease_index) + + result = [] + [ result.append(prj) for obj in prjs for prj in prjs[obj] ] + + return result + +def get_xml_file_list(path): + """ get list of xml files """ + file_list = [] + for root, dirs, files in os.walk(path): + for file in files: + if file.endswith('.xml'): + file_list.append(os.path.join(path, file)) + return file_list + def git_obs_map(gerrit_prj, gerrit_branch=None, gitcache=None, \ gerrit_hostname=None, gerrit_username=None, gerrit_sshport=None): """ @@ -221,20 +258,6 @@ def git_obs_map(gerrit_prj, gerrit_branch=None, gitcache=None, \ by parsing git-obs-mapping.xml. """ - def remove_overlaps(orig_list): - """docstring for make_unique""" - result = [] - [result.append(obj) for obj in orig_list if obj not in result] - return result - - def get_xml_file_list(path): - file_list = [] - for root, dirs, files in os.walk(path): - for file in files: - if file.endswith('.xml'): - file_list.append(os.path.join(path, file)) - return file_list - if gitcache: git_cache = gitcache else: @@ -328,20 +351,6 @@ def git_obs_map_full_list(obs_project=None, staging_project=None, gitcache=None, by parsing git-obs-mapping.xml. """ - def remove_overlaps(orig_list): - """docstring for make_unique""" - result = [] - [result.append(obj) for obj in orig_list if obj not in result] - return result - - def get_xml_file_list(path): - file_list = [] - for root, dirs, files in os.walk(path): - for file in files: - if file.endswith('.xml'): - file_list.append(os.path.join(path, file)) - return file_list - if gitcache: git_cache = gitcache else: -- 2.7.4