def import_matches(query, prefix=''):
    matches = set(re.findall(r"(%s[a-zA-Z_][a-zA-Z0-9_]*)\.?" % prefix, query))
    for raw_module_name in matches:
        if re.match('np(\..*)?$', raw_module_name):
            module_name = re.sub('^np', 'numpy', raw_module_name)
        elif re.match('pd(\..*)?$', raw_module_name):
            module_name = re.sub('^pd', 'pandas', raw_module_name)
        else:
            module_name = raw_module_name
        try:
            module = __import__(module_name)
            globals()[raw_module_name] = module
            import_matches(query, prefix='%s.' % module_name)
        except __HOLE__ as e:
            pass
dataset/ETHPy150Open Russell91/pythonpy/pythonpy/__main__.py/import_matches