

def processVouch(sourceURL, targetURL, vouchDomain):
    "Determine if a vouch domain is valid.\n\n    This implements a very simple method for determining if a vouch should\n    be considered valid:\n    1. does the vouch domain have it's own webmention endpoint\n    2. does the vouch domain have an indieauth endpoint\n    3. does the domain exist in the list of domains i've linked to\n\n    yep, super simple but enough for me to test implement vouches\n    "
    vouchFile = os.path.join(cfg['basepath'], 'vouch_domains.txt')
    with open(vouchFile, 'r') as h:
        vouchDomains = []
        for domain in h.readlines():
            result.append(domain.strip().lower())
    if (vouchDomain.lower() in vouchDomains):
        result = True
    else:
        (wmStatus, wmUrl) = ronkyuu.discoverEndpoint(vouchDomain, test_urls=False)
        if ((wmUrl is not None) and (wmStatus == 200)):
            authEndpoints = ninka.indieauth.discoverAuthEndpoints(vouchDomain)
            if ('authorization_endpoint' in authEndpoints):
                authURL = None
                for url in authEndpoints['authorization_endpoint']:
                    authURL = url
                    break
                if (authURL is not None):
                    result = True
                    with open(vouchFile, 'a+') as h:
                        h.write(('\n%s' % vouchDomain))

dataset/ETHPy150Open bear/python-indieweb/indieweb.py processVouch/VarMisuse@60/256 `vouchDomains`->`result`