From 74b0444def78dd3def1a94bb4b0da1a4d1cf6336 Mon Sep 17 00:00:00 2001 From: Hyokeun Jeon Date: Fri, 6 Sep 2019 10:41:19 +0900 Subject: [PATCH] Add OBS functions for meta change Change-Id: Idaca67b82755461f95bf55b1c9a06c289c8e074e --- common/buildservice.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/common/buildservice.py b/common/buildservice.py index 868d18a..a304a2b 100755 --- a/common/buildservice.py +++ b/common/buildservice.py @@ -1495,3 +1495,58 @@ class BuildService(OSC): path_project.append(element.get('project')) return list(set(path_project)) + def add_repositoris(self, prj, repo_arch_data): + """ + add repository - architecture to a project + repo_arch_data = {'repository': ['arch1', 'arch2', ...], ...} + """ + + path = core.quote_plus(prj), + kind = 'prj' + data = core.meta_exists(metatype=kind, + path_args=path, + template_args=None, + create_new=False) + if not data: + return + + root = ElementTree.fromstring(''.join(data)) + for repo in repo_arch_data: + repo_elem = ElementTree.Element('repository', name=repo) + for arch in repo_arch_data[repo]: + arch_elem = ElementTree.Element('arch') + arch_elem.text = arch + repo_elem.insert(100, arch_elem) + root.insert(100, repo_elem) + + core.edit_meta(metatype=kind, + path_args=path, + data=ElementTree.tostring(root)) + + def add_path_project(self, prj, base_project): + """ + add path project to each repository + """ + + base_repo_list = self.get_repositories(base_project) + + path = core.quote_plus(prj), + kind = 'prj' + data = core.meta_exists(metatype=kind, + path_args=path, + template_args=None, + create_new=False) + if not data: + return + + root = ElementTree.fromstring(''.join(data)) + + for repo in root.findall('repository'): + for r in base_repo_list: + path_elem = ElementTree.Element('path', project=base_project, repository=r) + repo.insert(100, path_elem) + + core.edit_meta(metatype=kind, + path_args=path, + data=ElementTree.tostring(root)) + -- 2.7.4