def generate_listing(src):
    """Compile all regular expressions in a RETF listing."""
    logger = logging.getLogger('retf')
    result = []

    soup = soupify_listing(src)

    for typo in soup.findAll('typo'):
        try:
            word = typo.attrs.get('word').encode('utf8')
            find = typo.attrs.get('find').encode('utf8')
            replace = typo.attrs.get('replace').encode('utf8')
            replace = replace.replace(b'$', b'\\')
        except __HOLE__:
            continue

        # pylint: disable=W0703
        try:
            logger.debug("Compiling regular expression: %s.", find)
            compiled = regex.compile(find, flags=regex.V1)
        except Exception:
            logger.error("Compilation of regular expression %f failed.", find)
            continue
        # pylint: enable=W0703

        entry = {
            'description': word,
            'find': find,
            'replace': replace,
            'regex': compiled
        }

        result.append(entry)

    logger.debug("Compiled %d regular expression(s).", len(result))

    return result
dataset/ETHPy150Open openstack/openstack-doc-tools/cleanup/retf/retf.py/generate_listing