def create_repo(name, attributes):

    config_parser = ConfigParser.RawConfigParser()

    values = ("name",
              "baseurl",
              "metalink",
              "mirrorlist",
              "gpgcheck",
              "gpgkey",
              "exclude",
              "includepkgs",
              "enablegroups",
              "enabled",
              "failovermethod",
              "keepalive",
              "timeout",
              "enabled",
              "http_caching",
              "retries",
              "throttle",
              "bandwidth",
              "sslcacert",
              "sslverify",
              "sslclientcert",
              "metadata_expire",
              "mirrorlist_expire",
              "proxy",
              "proxy_username",
              "proxy_password",
              "cost",
              "skip_if_unavailable")

    baseurl = None
    try:
        baseurl = attributes['baseurl'].split()[0]
    except (KeyError, __HOLE__) as err:
        raise ResourceException("Wrong baseurl attribute [%s]" % err)

    # Check if repo already exists
    repo = get_repos(name)

    # If it exists, get the filename in which the repo is defined
    # If not, check if a filename is user provided
    # If no filename is provided, create one based on the repo name
    if repo.get('present'):
        filename = repo.get("filename")
    elif attributes.get("filename"):
        filename = attributes["filename"]
    else:
        filename = "%s.repo" % name

    # Read the config file (empty or not) and load it in a ConfigParser
    # object
    repo_file_path = os.path.join(repo_path, filename)
    config_parser.read(repo_file_path)

    # Check if the repo is define in the ConfigParser context.
    # If not, add a section based on the repo name.
    if not config_parser.has_section(name):
        config_parser.add_section(name)
        config_parser.set(name, "name", name)

    # Set gpgcheck to 0 by default to bypass some issues
    config_parser.set(name, 'gpgcheck', 0)

    # Update the section with not None fields provided by the user
    for key, value in attributes.items():
        if value is not None and key in values:
            config_parser.set(name, key, value)

    config_parser.set(name, 'baseurl', baseurl)

    # Write changes to the repo file.
    with open(repo_file_path, 'wb') as repofile:
        config_parser.write(repofile)
dataset/ETHPy150Open comodit/synapse-agent/synapse/resources/repos-plugin/yum-repos.py/create_repo