Determines whether a module exists with the given modpath.
200
def find_module(modpath):
    """"""
    module_path = modpath.replace('.', '/') + '.py'
    init_path = modpath.replace('.', '/') + '/__init__.py'
    for root_path in sys.path:
        path = os.path.join(root_path, module_path)
        if os.path.isfile(path):
            return path
        path = os.path.join(root_path, init_path)
        if os.path.isfile(path):
            return path
1267530
def _path_exists(path):
    """"""
    return os.path.exists(path) or os.path.islink(path)
272976
def is_module_or_package(path):
    """"""
    is_module = osp.isfile(path) and osp.splitext(path)[1] in ('.py', '.pyw')
    is_package = osp.isdir(path) and osp.isfile(osp.join(path, '__init__.py'))
    return is_module or is_package
1195311
def exists(self, relpath):
    """"""
    if self.isignored(self._append_slash_if_dir_path(relpath)):
      return False
    return self._exists_raw(relpath)
1488
public static ModuleItem findModuleItem(String[] path) {
        if (disabled)
            return null;
        if (path == null || path[0].equals(APPSERVER_MODULE)) {
            return moduleRoot;
        }
        return moduleRoot.find(path, 0);
    }
1172428
def has_attribute(module_name, attribute_name):
    """"""
    init_file = '%s/__init__.py' % module_name
    return any(
        [attribute_name in init_line for init_line in open(init_file).readlines()]
    )
1371681
private List<File> locateModules() {
    File[] files = modRoot.listFiles();
    List<File> modFiles = new ArrayList<>();
    for (File file : files) {
      if (file.isDirectory()) {
        // Check to determine whether the directory is a valid module directory.
        boolean isValid = true;
        try {
          new ModuleIdentifier(file.getName());
        } catch (Exception e) {
          isValid = false;
        }

        // If the directory is a valid module name then check for a mod.json file.
        if (isValid) {
          File modJson = new File(file, MOD_JSON_FILE);
          if (modJson.exists()) {
            modFiles.add(file);
          }
        }
      }
    }
    return modFiles;
  }
1047495
private File locateModule(ModuleIdentifier modID) {
    File modDir = new File(modRoot, modID.toString());
    if (modDir.exists()) {
      return modDir;
    }
    return null;
  }
169126
public function hasModule($module)
    {
        return $module instanceof ModuleInterface
            ? in_array($module, $this->modules)
            : isset($this->modules[$module]);
    }
782703
def _check_blacklisted_module(self, node, mod_path):
        ''''''
        for mod_name in self.blacklisted_modules:
            if mod_path == mod_name or mod_path.startswith(mod_name + '.'):
                names = []
                for name, name_as in node.names:
                    if name_as:
                        names.append('{0} as {1}'.format(name, name_as))
                    else:
                        names.append(name)
                try:
                    import_from_module = node.modname
                    if import_from_module == 'salttesting.helpers':
                        for name in names:
                            if name == 'ensure_in_syspath':
                                self.add_message('blacklisted-syspath-update', node=node)
                                continue
                            msg = 'Please use \'from tests.support.helpers import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if import_from_module in ('salttesting.mock', 'mock', 'unittest.mock', 'unittest2.mock'):
                        for name in names:
                            msg = 'Please use \'from tests.support.mock import {0}\''.format(name)
                            if import_from_module in ('salttesting.mock', 'unittest.mock', 'unittest2.mock'):
                                message_id = 'blacklisted-module'
                            else:
                                message_id = 'blacklisted-external-module'
                            self.add_message(message_id, node=node, args=(mod_path, msg))
                        continue
                    if import_from_module == 'salttesting.parser':
                        for name in names:
                            msg = 'Please use \'from tests.support.parser import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if import_from_module == 'salttesting.case':
                        for name in names:
                            msg = 'Please use \'from tests.support.case import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if import_from_module == 'salttesting.unit':
                        for name in names:
                            msg = 'Please use \'from tests.support.unit import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if import_from_module.startswith(('unittest', 'unittest2')):
                        for name in names:
                            msg = 'Please use \'from tests.support.unit import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if import_from_module == 'salttesting.mixins':
                        for name in names:
                            msg = 'Please use \'from tests.support.mixins import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if import_from_module == 'six':
                        for name in names:
                            msg = 'Please use \'from salt.ext.six import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if import_from_module == 'distutils.version':
                        for name in names:
                            msg = 'Please use \'from salt.utils.versions import {0}\''.format(name)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                        continue
                    if names:
                        for name in names:
                            if name in ('TestLoader', 'TextTestRunner', 'TestCase', 'expectedFailure',
                                        'TestSuite', 'skipIf', 'TestResult'):
                                msg = 'Please use \'from tests.support.unit import {0}\''.format(name)
                                self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                                continue
                            if name in ('SaltReturnAssertsMixin', 'SaltMinionEventAssertsMixin'):
                                msg = 'Please use \'from tests.support.mixins import {0}\''.format(name)
                                self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                                continue
                            if name in ('ModuleCase', 'SyndicCase', 'ShellCase', 'SSHCase'):
                                msg = 'Please use \'from tests.support.case import {0}\''.format(name)
                                self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                                continue
                            if name == 'run_tests':
                                msg = 'Please remove the \'if __name__ == "__main__":\' section from the end of the module'
                                self.add_message('blacklisted-test-module-execution', node=node, args=msg)
                                continue
                            if mod_name in ('integration', 'unit'):
                                if name in ('SYS_TMP_DIR',
                                            'TMP',
                                            'FILES',
                                            'PYEXEC',
                                            'MOCKBIN',
                                            'SCRIPT_DIR',
                                            'TMP_STATE_TREE',
                                            'TMP_PRODENV_STATE_TREE',
                                            'TMP_CONF_DIR',
                                            'TMP_SUB_MINION_CONF_DIR',
                                            'TMP_SYNDIC_MINION_CONF_DIR',
                                            'TMP_SYNDIC_MASTER_CONF_DIR',
                                            'CODE_DIR',
                                            'TESTS_DIR',
                                            'CONF_DIR',
                                            'PILLAR_DIR',
                                            'TMP_SCRIPT_DIR',
                                            'ENGINES_DIR',
                                            'LOG_HANDLERS_DIR',
                                            'INTEGRATION_TEST_DIR'):
                                    msg = 'Please use \'from tests.support.paths import {0}\''.format(name)
                                    self.add_message('blacklisted-import', node=node, args=(mod_path, msg))
                                    continue
                                msg = 'Please use \'from tests.{0} import {1}\''.format(mod_path, name)
                                self.add_message('blacklisted-import', node=node, args=(mod_path, msg))
                                continue
                            msg = 'Please report this error to SaltStack so we can fix it: Trying to import {0} from {1}'.format(name, mod_path)
                            self.add_message('blacklisted-module', node=node, args=(mod_path, msg))
                except AttributeError:
                    if mod_name in ('integration', 'unit', 'mock', 'six', 'distutils.version',
                                    'unittest', 'unittest2'):
                        if mod_name in ('integration', 'unit'):
                            msg = 'Please use \'import tests.{0} as {0}\''.format(mod_name)
                            message_id = 'blacklisted-import'
                        elif mod_name == 'mock':
                            msg = 'Please use \'import tests.support.{0} as {0}\''.format(mod_name)
                            message_id = 'blacklisted-external-import'
                        elif mod_name == 'six':
                            msg = 'Please use \'import salt.ext.{0} as {0}\''.format(name)
                            message_id = 'blacklisted-external-import'
                        elif mod_name == 'distutils.version':
                            msg = 'Please use \'import salt.utils.versions\' instead'
                            message_id = 'blacklisted-import'
                        elif mod_name.startswith(('unittest', 'unittest2')):
                            msg = 'Please use \'import tests.support.unit as {}\' instead'.format(mod_name)
                            message_id = 'blacklisted-import'
                        self.add_message(message_id, node=node, args=(mod_path, msg))
                        continue
                    msg = 'Please report this error to SaltStack so we can fix it: Trying to import {0}'.format(mod_path)
                    self.add_message('blacklisted-import', node=node, args=(mod_path, msg))
331332
function findModuleVersion(modulePath, load) {
  if (modulePath) {
    var pjson = path.join(modulePath, 'package.json');
    if (fs.existsSync(pjson)) {
      return load(pjson).version;
    }
  }
  return process.version;
}
1076822
def is_module_loaded(module):
    """"""
    matches = re.findall('^%s[ ]+' % module, lsmod(), re.M)
    return len(matches) > 0
442698
def for_name(modpath, classname):
    '''
    
    '''
    module = __import__(modpath, fromlist=[classname])
    classobj = getattr(module, classname)
    return classobj()
701093
def get_modpath_from_modname(modname, prefer_pkg=False, prefer_main=False):
    
    from os.path import dirname, basename, join, exists
    initname = '__init__.py'
    mainname = '__main__.py'
    if modname in sys.modules:
        modpath = sys.modules[modname].__file__.replace('.pyc', '.py')
    else:
        import pkgutil
        loader = pkgutil.find_loader(modname)
        modpath = loader.filename.replace('.pyc', '.py')
        if '.' not in basename(modpath):
            modpath = join(modpath, initname)
    if prefer_pkg:
        if modpath.endswith(initname) or modpath.endswith(mainname):
            modpath = dirname(modpath)
    if prefer_main:
        if modpath.endswith(initname):
            main_modpath = modpath[:-len(initname)] + mainname
            if exists(main_modpath):
                modpath = main_modpath
    return modpath
556339
def find_module(self, modname, folder=None):
        
        for src in self.get_source_folders():
            module = _find_module_in_folder(src, modname)
            if module is not None:
                return module
        for src in self.get_python_path_folders():
            module = _find_module_in_folder(src, modname)
            if module is not None:
                return module
        if folder is not None:
            module = _find_module_in_folder(folder, modname)
            if module is not None:
                return module
        return None
63697
function existence ( filepath ) {
		var does = grunt.file.exists ( filepath );
		if ( !does ) {
			grunt.log.warn ( filepath + " not found." );
		}
		return does;
	}
349023
def _check_parse_modtime(self, filepath, fname):
        """"""       
        #We also want to perform a reparse if the XML documentation file for the
        #module changed, since the docs are also cached.
        file_mtime = self._get_mod_mtime(filepath)
        
        #If we have parsed this file and have its modules in memory, its
        #filepath will be in self._parsed. Otherwise we can load it from
        #file or from a cached pickle version.
        if filepath.lower() in self._parsed: 
            #Get the name of the first module in that file from the modulefiles
            #list. Find out when it was last modified.
            module_mtime = None
            if fname in self._modulefiles:
                if len(self._modulefiles[fname]) == 0:
                    msg.warn("Module file {} has no modules defined inside of it!".format(fname))
                    return None
                
                modulename = self._modulefiles[fname][0]
                if modulename in self.modules:
                    #Make sure that if there are modules with the same name but different
                    #files, that we are working with the correct one.
                    if filepath.lower() != self.modules[modulename].filepath:
                        msg.warn("module {} parsed ".format(modulename) + 
                                 "from {}, not {}".format(self.modules[modulename].filepath,
                                                          filepath))
                    module_mtime = self.modules[modulename].change_time

            if module_mtime is not None:
                if module_mtime < file_mtime:
                    #The file has been modified since we reloaded the module.
                    #Return the two times we used for the comparison so the
                    #module file can be reloaded.
                    return [module_mtime, file_mtime]
                else:
                    return None
        else:
            #The file has never been parsed by this CodeParser. We can
            #either do a full parse or a pickle load.
            return [file_mtime]