# Path: openid/test/discoverdata.py
# def getDataName(*components):
# def getExampleXRDS():
# def readTests(filename):
# def getData(filename, name):
# def fillTemplate(test_name, template, base_url, example_xrds):
# def generateSample(test_name, base_url,
#                    example_xrds=example_xrds,
#                    filename=default_test_file):
# def generateResult(base_url, input_name, id_name, result_name, success):


import os.path
    import sys
from six.moves.urllib.parse import urljoin
from openid.test import discoverdata


def buildDiscover(base_url, out_dir):
    """Convert all files in a directory to apache mod_asis files in
    another directory."""
    test_data = discoverdata.readTests(discoverdata.default_test_file)

    def writeTestFile(test_name):
        template = test_data[test_name]

        data = discoverdata.fillTemplate(
            test_name, template, base_url, discoverdata.example_xrds)

        out_file_name = os.path.join(out_dir, test_name)
        out_file = open(out_file_name, 'w')
        out_file.write(data)

    manifest = [manifest_header]
    for success, input_name, id_name, result_name in discoverdata.testlist:
        if not success:
            continue
        writeTestFile(input_name)

        input_url = urljoin(base_url, input_name)
        id_url = urljoin(base_url, id_name)
        result_url = urljoin(base_url, result_name)

        manifest.append('\t'.join((input_url, id_url, result_url)))
        manifest.append('\n')


# Path: openid/test/discoverdata.py
# def getDataName(*components):
# def getExampleXRDS():
# def readTests(filename):
# def getData(filename, name):
# def fillTemplate(test_name, template, base_url, example_xrds):
# def generateSample(test_name, base_url,
#                    example_xrds=example_xrds,
#                    filename=default_test_file):
# def generateResult(base_url, input_name, id_name, result_name, success):


# Path: admin/builddiscover.py
import os.path
    import sys
from six.moves.urllib.parse import urljoin
from openid.test import discoverdata



def buildDiscover(base_url, out_dir):
    """Convert all files in a directory to apache mod_asis files in
    another directory."""
    test_data = discoverdata.readTests(discoverdata.default_test_file)

    def writeTestFile(test_name):
        template = test_data[test_name]

        data = discoverdata.fillTemplate(
            test_name, template, base_url, discoverdata.example_xrds)

        out_file_name = os.path.join(out_dir, test_name)
        out_file = open(out_file_name, 'w')
        out_file.write(data)

    manifest = [manifest_header]
    for success, input_name, id_name, result_name in discoverdata.testlist:
        if not success:
            continue
        writeTestFile(input_name)

        input_url = urljoin(base_url, input_name)
        id_url = urljoin(base_url, id_name)
        result_url = urljoin(base_url, result_name)

        manifest.append('\t'.join((input_url, id_url, result_url)))
        manifest.append('\n')


    manifest_file_name = os.path.join(out_dir, 'manifest.txt')