def get_branch(node, repositories, default_repo, config): """Scan for a <branch> element and create a corresponding Branch object.""" name = node.getAttribute('id') childnode = find_first_child_node(node, 'branch') if childnode is None: raise FatalError(_('no <branch> element found for %s') % name) # look up the repository for this branch ... if childnode.hasAttribute('repo'): try: repo = repositories[childnode.getAttribute('repo')] except KeyError: repo_names = ', '.join([r.name for r in repositories.values()]) raise UndefinedRepositoryError( _('Repository=%(missing)s not found for module id=%(module)s. Possible repositories are %(possible)s' % {'missing': childnode.getAttribute('repo'), 'module': name, 'possible': repo_names})) elif default_repo: repo = repositories[default_repo] else: raise UndefinedRepositoryError( _('No repository for module id=%(module)s. Either set branch/repo or default repository.' % {'module': name})) if repo.mirrors: mirror_type = config.mirror_policy if name in config.module_mirror_policy: mirror_type = config.module_mirror_policy[name] if mirror_type in repo.mirrors: repo = repo.mirrors[mirror_type] return repo.branch_from_xml(name, childnode, repositories, default_repo)
def get_branch(node, repositories, default_repo, config): """Scan for a <branch> element and create a corresponding Branch object.""" name = node.getAttribute('id') for childnode in node.childNodes: if (childnode.nodeType == childnode.ELEMENT_NODE and childnode.nodeName == 'branch'): break else: raise FatalError(_('no <branch> element found for %s') % name) # look up the repository for this branch ... if childnode.hasAttribute('repo'): try: repo = repositories[childnode.getAttribute('repo')] except KeyError: raise UndefinedRepositoryError( _('Repository=%s not found for module id=%s. Possible repositories are %s' ) % (childnode.getAttribute('repo'), name, repositories)) else: try: repo = repositories[default_repo] except KeyError: raise UndefinedRepositoryError( _('Default Repository=%s not found for module id=%s. Possible repositories are %s' ) % (default_repo, name, repositories)) if repo.mirrors: mirror_type = config.mirror_policy if name in config.module_mirror_policy: mirror_type = config.module_mirror_policy[name] if mirror_type in repo.mirrors: repo = repo.mirrors[mirror_type] return repo.branch_from_xml(name, childnode, repositories, default_repo)