def _get_lossy_domain(domain):
    """
    A lossy version of a domain/host to use as lookup in the ``_engines``
    dict.

    :param domain: A string that is the ``netloc`` portion of a URL.
    :type domain:  ``bytes``
    """
    global _domain_cache, _get_lossy_domain_regex

    if _domain_cache in domain:
        return _domain_cache[domain]

    if not _get_lossy_domain_regex:
        codes = '|'.join(_country_codes)
        _get_lossy_domain_regex = re.compile(
                r'^' # start of string
                r'(?:w+\d*\.|search\.|m\.)*' + # www. www1. search. m.
                r'((?P<ccsub>{})\.)?'.format(codes) + # country-code subdomain
                r'(?P<domain>.*?)' + # domain
                r'(?P<tld>\.(com|org|net|co|edu))?' + # tld
                r'(?P<tldcc>\.({}))?'.format(codes) + # country-code tld
                r'$') # all done

    res = _get_lossy_domain_regex.match(domain).groupdict()
    output = u'%s%s%s' % ('{}.' if res['ccsub'] else '',
                          res['domain'],
                          '.{}' if res['tldcc'] else res['tld'] or '')
    _domain_cache[domain] = output # Add to LRU cache
    return output
dataset/ETHPy150Open Parsely/serpextract/serpextract/serpextract.py/_get_lossy_domain/swapped operands of `in`