Ejemplo n.º 1
0
def parse_releases(info):
    try:
        releases = info['releases']
    except KeyError:
        raise exception.MissingRequiredSection(section='releases')
    if not isinstance(releases, Iterable):
        raise exception.InvalidInfoFormat(
            msg="'releases' section must be iterable")
    if isinstance(releases, dict):
        releases = releases.values()
    for rls in releases:
        try:
            rls_name = rls['name']
        except KeyError:
            raise exception.MissingRequiredItem(item='release.name in %s' %
                                                rls)
        try:
            repos = rls['repos']
        except KeyError:
            raise exception.MissingRequiredItem(
                item='release.repos for release %s' % rls_name)
        default_branch = rls.get('branch')
        for repo in repos:
            parse_release_repo(repo, default_branch)
    return releases
Ejemplo n.º 2
0
def parse_release_repo(repo, default_branch=None):
    if 'name' not in repo:
        raise exception.MissingRequiredItem(item='repo.name')
    if 'branch' not in repo:
        if default_branch:
            repo['branch'] = default_branch
        else:
            raise exception.MissingRequiredItem(item='repo.branch')
    return repo
Ejemplo n.º 3
0
def parse_package(pkg, info, apply_tag=None):
    pkddefault, pkgconfs = parse_package_configs(info)
    # start with default package config
    parsed_pkg = copy.deepcopy(pkddefault)
    if 'conf' in pkg:
        # apply package configuration template
        conf_id = pkg['conf']
        try:
            conf = pkgconfs[conf_id]
        except KeyError:
            raise exception.UndefinedPackageConfig(conf=conf_id)
        parsed_pkg.update(conf)
    parsed_pkg.update(pkg)
    if apply_tag:
        tags = parsed_pkg.get('tags', {})
        tagdict = tags.get(apply_tag)
        if tagdict:
            parsed_pkg.update(tagdict)
    pkg = substitute_package(parsed_pkg)

    try:
        name = pkg['name']
    except KeyError:
        raise exception.MissingRequiredItem(item='package.name in %s' % pkg)
    if 'project' not in pkg:
        raise exception.MissingRequiredItem(item="project for '%s' package" %
                                            name)
    try:
        maints = pkg['maintainers']
    except KeyError:
        raise exception.MissingRequiredItem(
            item="maintainers for '%s' package" % name)
    if not maints:
        raise exception.MissingRequiredItem(
            item="at least one maintainer for '%s' package" % name)
    try:
        for maint in maints:
            if '@' not in maint:
                raise exception.InvalidInfoFormat(
                    msg="'%s' doesn't look like maintainer's email." % maint)
    except TypeError:
        raise exception.InvalidInfoFormat(
            msg='package.maintainers must be a list of email addresses')

    return pkg