def METHOD_NAME(directory):
    """Returns path to the primary repository data file.
    :param directory: repository directory that contains the repodata subdirectory
    :return:  path to primary repository data file
    :rtype: str
    :raise IOError: if repomd.xml contains no primary location
    """
    metaDataPath = os.path.join(directory, "repodata", "repomd.xml")
    elementTree = ET.parse(metaDataPath)
    root = elementTree.getroot()
    for dataElement in root:
        if dataElement.get("type") == "primary":
            locationElement = dataElement.find(namespace("repo") + "location")
            # even though the repomd.xml file is under repodata, the location a
            # attribute is relative to parent directory (directory).
            METHOD_NAME = os.path.join(directory, locationElement.get("href"))
            break
    else:
        raise OSError("'%s' contains no primary location" % metaDataPath)
    return METHOD_NAME