Read and parse a YANG module or submodule.
189238
def _load_module(self, name: YangIdentifier,
                     rev: RevisionDate) -> Statement:
        """"""
        for d in self.module_search_path:
            run = 0
            while run < 2:
                fn = f"{d}/{name}"
                if rev and run == 0:
                    fn += "@" + rev
                fn += ".yang"
                try:
                    with open(fn, encoding='utf-8') as infile:
                        res = ModuleParser(infile.read(), name, rev).parse()
                except (FileNotFoundError, PermissionError, ModuleContentMismatch):
                    run += 1
                    continue
                return res
        raise ModuleNotFound(name, rev)
488775
function getModule(name, loader) {
    var exports;
    var entry = loader.defined[name];

    if (!entry) {
      exports = loader.get(name);
      if (!exports)
        throw new Error('Unable to load dependency ' + name + '.');
    }

    else {
      if (entry.declarative)
        ensureEvaluated(name, entry, [], loader);
    
      else if (!entry.evaluated)
        linkDynamicModule(entry, loader);

      exports = entry.module.exports;
    }

    if ((!entry || entry.declarative) && exports && exports.__useDefault)
      return exports['default'];
    
    return exports;
  }
27441
def get_submodule_list(package_path: str) -> Tuple[ModuleDescription, ...]:
    """"""
    pkg = importlib.import_module(package_path)

    subs = (
        ModuleDescription(
            name=modname,
            path="{}.{}".format(package_path, modname), is_package=ispkg
        )
        for importer, modname, ispkg in pkgutil.iter_modules(pkg.__path__)
    )
    result = tuple(subs)
    return result
1040547
def _parse_from_file(self, filepath, fname,
                         dependencies, recursive, greedy):
        """"""
        #Now that we have the file contents, we can parse them using the parsers
        string = self.tramp.read(filepath)
        pmodules = self.modulep.parse(string, self, filepath=filepath)
        file_mtime = self._get_mod_mtime(filepath)

        for module in pmodules:
            module.change_time = file_mtime
            self.modules[module.name.lower()] = module
            self._modulefiles[fname].append(module.name.lower())

        pprograms = self.modulep.parse(string, self, False)
        for program in pprograms:
            program.change_time = file_mtime
            self.programs[program.name.lower()] = program
            self._programfiles[fname].append(program.name.lower())

        #There may be xml files for the docstrings that also need to be parsed.
        self._parse_docstrings(filepath)
        
        return (pmodules, pprograms)
461235
def compile(self, module):
        '''
        '''

        imports, depends = self.get_dependencies(module)
        file_list = list(imports | depends) + [module]
        cmd_list = ['pyang', '-f', 'cxml', '--plugindir', self.pyang_plugins]
        cmd_list += ['-p', self.dir_yang]
        cmd_list += [self.dir_yang + '/' + f + '.yang' for f in file_list]
        logger.info('Compiling {}.yang: {}'.format(module,
                                                   ' '.join(cmd_list)))
        p = Popen(' '.join(cmd_list), shell=True, stdout=PIPE, stderr=PIPE)
        stdout, stderr = p.communicate()
        logger.info('pyang return code is {}'.format(p.returncode))
        if p.returncode == 0:
            logger.debug(stderr.decode())
        else:
            logger.error(stderr.decode())
        parser = etree.XMLParser(remove_blank_text=True)
        tree = etree.XML(stdout.decode(), parser)
        return Model(tree)
1204216
def __check_submodules(self):
        
        if not os.path.exists('.git'):
            return
        with open('.gitmodules') as f:
            for l in f:
                if 'path' in l:
                    p = l.split('=')[-1].strip()
                    if not os.path.exists(p):
                        raise ValueError('Submodule %s missing' % p)

        proc = subprocess.Popen(['git', 'submodule', 'status'],
                                stdout=subprocess.PIPE)
        status, _ = proc.communicate()
        status = status.decode("ascii", "replace")
        for line in status.splitlines():
            if line.startswith('-') or line.startswith('+'):
                raise ValueError('Submodule not clean: %s' % line)
146487
function readDefaultModules (pkgDir) { return function (pkg, cb) {
  log.verbose(pkg._id, "readDefaultModules")
  var lib = pkg.directories && pkg.directories.lib || pkg.lib
    , libDir = path.join(pkgDir, lib).replace(/\/+$/, '')
  if (!lib) return cb(null, pkg)
  // create a modules hash from the lib folder.
  pkg.modules = {}
  var cut = pkgDir === "." ? 0 : pkgDir.length + 1
    , libCut = pkgDir === "." ? lib.length - 1 : libDir.length + 1
  find(libDir, function (er, filenames) {
    if (er) return cb(er)
    filenames.filter(function (f) {
      return !f.substr(libCut).match(/(^|\/)\./)
    }).forEach(function (filename) {
      // filename = path.basename(filename, path.extname(filename))
      var key = filename.substr(libCut)
        , val = filename.substr(cut)
      key = key.replace(/\.node$/, ".js")
      if (key.length && val.length) pkg.modules[key] = val
    })
    // require("foo/foo") is dumb, and happens a lot.
    var nameMod = pkg.modules[pkg.name] || pkg.modules[pkg.name+".js"]
    if (!pkg.main
        && !pkg.modules.index
        && !pkg.modules["index.js"]
        && nameMod) {
      pkg.modules["index.js"] = nameMod
    }
    log.silly(pkg.modules, pkg._id+".modules")
    return cb(null, pkg)
  })
}}
1373852
@Beta
    // TODO maybe load with PELoader
    public MSDOSLoadModule readMSDOSLoadModule() throws IOException {
        MSDOSLoadModule module = new MSDOSLoadModule(msdos, file);
        module.read();
        return module;
    }
563322
def from_yang(self, text: str) -> Optional[QualName]:
        """"""
        try:
            return self.sctx.schema_data.translate_pname(text, self.sctx.text_mid)
        except (ModuleNotRegistered, UnknownPrefix):
            raise InvalidArgument(text)
1238524
def find_module(module, paths=None):
    """"""

    parts = module.split('.')

    while parts:
        part = parts.pop(0)
        f, path, (suffix, mode, kind) = info = imp.find_module(part, paths)

        if kind == PKG_DIRECTORY:
            parts = parts or ['__init__']
            paths = [path]

        elif parts:
            raise ImportError("Can't find %r in %s" % (parts, module))

    return info
392091
def load_models(module):
    """"""
    modules = _import_submodules(module)
    return {m for module in modules for m in filter(
        _check_model, (getattr(module, name) for name in dir(module))
    )}
90118
def main_module(self):
        """"""
        if self.i_module.keyword == "submodule":
            return self.i_module.i_ctx.get_module(
                self.i_module.i_including_modulename)
        return self.i_module
1038130
function parseModuleSpecifier() {
        var node = new Node();

        if (lookahead.type !== Token.StringLiteral) {
            throwError(Messages.InvalidModuleSpecifier);
        }
        return node.finishLiteral(lex());
    }
876692
function analyzeModuleDefinition(node) {
	var args = node.arguments;
	var arg = 0;
	if ( arg < args.length
		 && args[arg].type === Syntax.Literal && typeof args[arg].value === 'string' ) {
		warning("module explicitly defined a module name '" + args[arg].value + "'");
		currentModule.name = args[arg].value;
		arg++;
	}
	if ( arg < args.length && args[arg].type === Syntax.ArrayExpression ) {
		currentModule.dependencies = convertValue(args[arg], "string[]");
		arg++;
	}
	if ( arg < args.length && args[arg].type === Syntax.FunctionExpression ) {
		currentModule.factory = args[arg];
		arg++;
	}
	if ( currentModule.dependencies && currentModule.factory ) {
		for ( var i = 0; i < currentModule.dependencies.length && i < currentModule.factory.params.length; i++ ) {
			var name = currentModule.factory.params[i].name;
			var module = resolveModuleName(currentModule.module, currentModule.dependencies[i]);
			debug("  import " + name + " from '" + module + "'");
			currentModule.localNames[name] = {
				module: module
				// no (or empty) path
			};
		}
	}
	if ( currentModule.factory ) {
		collectShortcuts(currentModule.factory.body);
	}
}
442672
def parse(mod, buff):
		
		mm = MinidumpUnloadedModule()
		mm.baseaddress = mod.BaseOfImage
		mm.size = mod.SizeOfImage
		mm.checksum = mod.CheckSum
		mm.timestamp = mod.TimeDateStamp
		mm.name = MINIDUMP_STRING.get_from_rva(mod.ModuleNameRva, buff)
		mm.endaddress = mm.baseaddress + mm.size
		return mm
404261
def _parse_module_list(module_list):
    ''''''
    for module_meta in module_list:
        name = module_meta['module']

        # Import & parse module
        module = import_module(name)
        output = parse_module(module)

        # Assign to meta.content
        module_meta['content'] = output
1097551
def _get_module(self, parser, module):
        
        dt = []
        lines = parser.clean_data(module)
        header = lines[0]
        for data in lines[1:]:
            if data[0].startswith("#"):  # some modules have two headers
                header = data
                continue
            if data[0].find("-") > -1:  # expand positions 1-3 to 1, 2, 3
                f, s = map(int, data[0].split("-"))
                for pos in range(f, s):
                    dt.append([str(pos)] + data[1:])
            else:
                dt.append(data)
        dt = pd.DataFrame(dt)
        dt.columns = [h.replace(" ", "_") for h in header]
        dt['sample'] = self.sample
        return dt