def _ast_scan_file_re(filename):
    try:
        with io.open(filename, 'rt', encoding='utf8') as fp:
            script = fp.read()
            normalized = ''
            for imp in _fallback_re.finditer(script):
                imp_line = imp.group(1)
                try:
                    imp_line = imp_line.decode('utf8')
                except AttributeError:
                    pass
                except UnicodeEncodeError:
                    log.warn('Unicode import failed: %s', imp_line)
                    continue
                imp_line = re.sub(r'[\(\)]', '', imp_line)
                normalized += ' '.join(imp_line.split()).strip(',') + '\n'
            log.debug('Normalized imports:\n%s', normalized)

            try:
                root = ast.parse(normalized, filename=filename)
            except SyntaxError:
                log.error('Could not parse file using regex scan: %s', filename)
                log.info('Exception:', exc_info=True)
                return None, None

            log.debug('Starting AST Scan (regex): %s', filename)
            ast_visitor.reset(filename)
            ast_visitor.visit(root)
            return ast_visitor.scope, ast_visitor.imports
    except __HOLE__:
        log.warn('Could not open file: %s', filename)

    return None, None
dataset/ETHPy150Open tweekmonster/moult/moult/ast_scanner.py/_ast_scan_file_re