def test_is_module_or_submodule(): assert is_module_or_submodule('foo.bar', 'foo.bar') assert is_module_or_submodule('foo.bar.baz', 'foo.bar') assert not is_module_or_submodule('foo.bard', 'foo.bar') assert not is_module_or_submodule('foo', 'foo.bar')
# From __init__.py, starting at line 111:: # # BRAIN_MODULES_DIR = join(dirname(__file__), 'brain') # if BRAIN_MODULES_DIR not in sys.path: # # add it to the end of the list so user path take precedence # sys.path.append(BRAIN_MODULES_DIR) # # load modules in this directory # for module in listdir(BRAIN_MODULES_DIR): # if module.endswith('.py'): # __import__(module[:-3]) # # So, we need all the Python source in the ``brain/`` subdirectory, # since this is run-time discovered and loaded. Therefore, these # files are all data files. from PyInstaller.utils.hooks import collect_data_files, collect_submodules, \ is_module_or_submodule # Note that brain/ isn't a module (it lacks an __init__.py, so it can't be # referred to as astroid.brain; instead, locate it as package astriod, # subdirectory brain/. datas = collect_data_files('astroid', True, 'brain') # Update: in astroid v 1.4.1, the brain/ module import parts of astroid. Since # everything in brain/ is dynamically imported, these are hidden imports. For # simplicity, include everything in astroid. Exclude all the test/ subpackage # contents and the test_util module. hiddenimports = ['six'] + collect_submodules('astroid', lambda name: (not is_module_or_submodule(name, 'astroid.tests')) and (not name == 'test_util'))
# """ # imported = {} # for filename in os.listdir(directory): # base, extension = splitext(filename) # if base in imported or base == '__pycache__': # continue # if extension in PY_EXTS and base != '__init__' or ( # not extension and isdir(join(directory, base))): # try: # module = load_module_from_file(join(directory, filename)) # # # So, we need all the Python source in the ``checkers/`` and ``reporters/`` # subdirectories, since these are run-time discovered and loaded. Therefore, # these files are all data files. In addition, since this is a module, the # pylint/__init__.py file must be included, since submodules must be children of # a module. from PyInstaller.utils.hooks import collect_data_files, collect_submodules, is_module_or_submodule,\ get_module_file_attribute datas = ([(get_module_file_attribute('pylint.__init__'), 'pylint')] + collect_data_files('pylint.checkers', True) + collect_data_files('pylint.reporters', True)) # Add imports from dynamically loaded modules excluding tests and testutils hiddenimports = collect_submodules( 'pylint', lambda name: (not is_module_or_submodule(name, 'pylint.test')) and (not name == 'testutils'))
# From __init__.py, starting at line 111:: # # BRAIN_MODULES_DIR = join(dirname(__file__), 'brain') # if BRAIN_MODULES_DIR not in sys.path: # # add it to the end of the list so user path take precedence # sys.path.append(BRAIN_MODULES_DIR) # # load modules in this directory # for module in listdir(BRAIN_MODULES_DIR): # if module.endswith('.py'): # __import__(module[:-3]) # # So, we need all the Python source in the ``brain/`` subdirectory, # since this is run-time discovered and loaded. Therefore, these # files are all data files. from PyInstaller.utils.hooks import collect_data_files, collect_submodules, \ is_module_or_submodule # Note that brain/ isn't a module (it lacks an __init__.py, so it can't be # referred to as astroid.brain; instead, locate it as package astriod, # subdirectory brain/. datas = collect_data_files('astroid', True, 'brain') # Update: in astroid v 1.4.1, the brain/ module import parts of astroid. Since # everything in brain/ is dynamically imported, these are hidden imports. For # simplicity, include everything in astroid. Exclude all the test/ subpackage # contents and the test_util module. hiddenimports = ['six'] + collect_submodules('astroid', lambda name: (not is_module_or_submodule(name, 'astroid.tests')) and (not name == 'test_util'))
# imported = {} # for filename in os.listdir(directory): # base, extension = splitext(filename) # if base in imported or base == '__pycache__': # continue # if extension in PY_EXTS and base != '__init__' or ( # not extension and isdir(join(directory, base))): # try: # module = load_module_from_file(join(directory, filename)) # # # So, we need all the Python source in the ``checkers/`` and ``reporters/`` # subdirectories, since these are run-time discovered and loaded. Therefore, # these files are all data files. In addition, since this is a module, the # pylint/__init__.py file must be included, since submodules must be children of # a module. from PyInstaller.utils.hooks import collect_data_files, collect_submodules, is_module_or_submodule,\ get_module_file_attribute datas = ( [(get_module_file_attribute('pylint.__init__'), 'pylint')] + collect_data_files('pylint.checkers', True) + collect_data_files('pylint.reporters', True) ) # Add imports from dynamically loaded modules excluding tests and testutils hiddenimports = collect_submodules('pylint', lambda name: (not is_module_or_submodule(name, 'pylint.test')) and (not name == 'testutils'))
def test_is_module_or_submodule(): assert is_module_or_submodule('foo.bar', 'foo.bar') assert is_module_or_submodule('foo.bar.baz', 'foo.bar') assert not is_module_or_submodule('foo.bard', 'foo.bar') assert not is_module_or_submodule('foo', 'foo.bar')
def _filter_func(name): return (not is_module_or_submodule(name, 'pylint.test') and not is_module_or_submodule(name, 'pylint.testutils'))