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))
+