def create_repo(name, attributes={}):
    # Initialize the repo dictionnary
    repo = {}
    repo_file = os.path.join(src_dir, name + '.list')

    # If the file already exists, load repo into a dict
    if os.path.isfile(repo_file):
        repo = _load_repo(repo_file)

    newrepo = {}

    try:
        # baseurl attr is mandatory
        baseurl = attributes['baseurl']

        # if the full entry is not provided (i.e "deb url dist [components]")
        # distribution and components attr are mandatory
        if not _full_entry(baseurl):
            url = baseurl
            distribution = attributes['distribution']
            components = attributes['components']
            if not isinstance(components, list):
                components = set(''.join(components.split()).split(','))

        # If the full entry is provided, just split it into required elements
        else:
            url = baseurl.split()[0]
            distribution = baseurl.split()[1]
            components = set(baseurl.split()[2:])

        # Build the new repo dict
        newrepo = {'baseurl': url,
                   'distribution': distribution,
                   'components': components}

    except KeyError as err:
        raise ResourceException("Missing mandatory attribute [%s]" % err)

    # If that repo already exist, del entry and add the new one
    if name in repo:
        for index, rep in enumerate(repo[name]):
            if (rep['baseurl'] == newrepo['baseurl'] and
                rep['distribution'] == newrepo['distribution']):

                del repo[name][index]

        repo[name].append(newrepo)
    else:
        repo[name] = [newrepo]

    _dump_repo(repo)
dataset/ETHPy150Open comodit/synapse-agent/synapse/resources/repos-plugin/apt-repos.py/create_repo/original