Yield all nodes that provide an import
540489
def yield_module_imports_nodes(root, checks=import_nodes()):
    

    if not isinstance(root, asttypes.Node):
        raise TypeError('provided root must be a node')

    for child in yield_function(root, deep_filter):
        for f, condition in checks:
            if condition(child):
                for name in f(child):
                    yield name
                continue
1346241
def each_object(collection):
    """"""
    c_path = collection_path(collection)
    paths = glob('%s/*.%s' % (c_path, _ext))
    for path in paths:
        yield load_object_at_path(path)
550802
def find_all(root, path):
  """"""
  path = parse_path(path)

  if len(path) == 1:
    yield from get_children(root, path[0])
  else:
    for child in get_children(root, path[0]):
      yield from find_all(child, path[1:])
741124
def get_all_nodes(self, addr, is_syscall=None, anyaddr=False):
        
        results = [ ]

        for cfg_node in self.graph.nodes():
            if cfg_node.addr == addr or (anyaddr and
                                         cfg_node.size is not None and
                                         cfg_node.addr <= addr < (cfg_node.addr + cfg_node.size)
                                         ):
                if is_syscall and cfg_node.is_syscall:
                    results.append(cfg_node)
                elif is_syscall is False and not cfg_node.is_syscall:
                    results.append(cfg_node)
                else:
                    results.append(cfg_node)

        return results
1121698
def iter_child_nodes(node):
    """"""
    for name, field in iter_fields(node):
        if isinstance(field, AST):
            yield field
        elif isinstance(field, list):
            for item in field:
                if isinstance(item, AST):
                    yield item
683432
def visit_importfrom(self, node):
        """"""
        return "from %s import %s" % (
            "." * (node.level or 0) + node.modname,
            _import_string(node.names),
        )
843781
def run(self):
        """"""
        paths = [x for x in practices.__dict__.values()
                 if hasattr(x, 'code')]

        for node in ast.walk(self.tree):
            try:
                lineno, col_offset = node.lineno, node.col_offset
            except AttributeError:
                # Not all nodes have coordinates, e.g.: ast.Module
                continue

            for checker in paths:
                if checker(node):
                    message = self.build_message(checker)
                    yield lineno, col_offset, message, type(self)
205092
def get_ipaths(self):
        
        for node in itertools.chain(self.added, self.changed, self.removed):
            yield node.path
319202
function collectImports(items, children) {
	const result = Promise.map(items, (item) => {
		const name = item.name;
		const parent = cbuild.path2url(item.path);
		const pos = name.indexOf('.') + 1;
		const ext = name.substr(pos);

		if(!item.isFile || !pos || ext != 'ts') return(null);

		const result = fs.readFileAsync(
			item.path,
			{ encoding: 'utf-8' }
		).then((source) => {
			const importList = [];

			for(let line of source.split(/[;\n]+\s*/)) {
				const match = line.match(/^import[ \t]+([ \t$*,-.0-9A-Z_a-z{}]+[ \t]+from[ \t+])?['"]([^'"]+)['"]/);

				if(match) importList.push(match[2]);
			}

			const result = Promise.map(importList, (relative, resolved) =>
				Promise.try(
					() => System.normalize(relative, parent, parent)
				).then((result) => {
					let ready;

					result = result.replace(/\!.*/, '');

					if(result.substr(0, 5) == 'npm:/') {
						resolved = path.resolve(basePath, result.substr(5));

						ready = fs.statAsync(
							resolved
						).catch((err) => {
							resolved += '.js';
							return(fs.statAsync(resolved));
						}).catch((err) => {
							resolved = result;
							return(cbuild.findPackage(result.substr(5), parent, '/'));
						});
					} else {
						resolved = cbuild.url2path(result);

						ready = fs.statAsync(
							resolved
						).catch((err) => {
							resolved += '.ts';
							return(fs.statAsync(resolved));
						});
					}

					return(ready);
				}).then((result) => {
					if(resolved.substr(0, 5) == 'npm:/') resolved = result;

					let isModule = false;
					let name = '';

					for(let part of resolved.replace(/\!.*/, '').split('/')) {
						if(part.toLowerCase() == 'node_modules') {
							// New deepest node_modules directory was found.
							// Start looking for name of NPM package
							// actually containing this file.
							isModule = true;
							name = '';
						} else if(isModule) {
							if(part.charAt(0) == '@') {
								// Handle scoped packages:
								// After scope name the package name still follows.
								name = part + '/';
							} else {
								// Get package name and stop appending to it.
								name += part;
								isModule = false;
							}
						}
					}

					return(name);
				}).catch((err) => {
					// console.log(err);
				})
			);

			return(result);
		});

		return(result);
	}).then((parsedImportList) => {
		const nameTbl = {};

		// Dependencies of source files in this directory.

		for(let dependencyList of parsedImportList) {
			for(let dependency of dependencyList || []) {
				if(dependency) nameTbl[dependency] = true;
			}
		}

		// Dependencies of files in subdirectories.

		for(let dependencyList of children) {
			for(let dependency of dependencyList || []) {
				nameTbl[dependency] = true;
			}
		}

		return(Object.keys(nameTbl).sort());
	});

	return(result);
}
338102
def iter_child_nodes(self, exclude=None, only=None):
        
        for field, item in self.iter_fields(exclude, only):
            if isinstance(item, list):
                for n in item:
                    if isinstance(n, Node):
                        yield n
            elif isinstance(item, Node):
                yield item
1098931
def visit_generatorexp(self, node):
        """"""
        return "(%s %s)" % (
            node.elt.accept(self),
            " ".join(n.accept(self) for n in node.generators),
        )
70754
def path_iter(self, include_self=True):
        """"""
        if include_self:
            node = self
        else:
            node = self.parent
        while node is not None:
            yield node
            node = node.parent
1144089
def from_nodes(cls, nodes, new_nodes, max_slaves_limit=None):
        '''
        '''
        param = gen_distribution(nodes, new_nodes)
        param['max_slaves_limit'] = max_slaves_limit
        return cls(**param)
105005
function importGenerator( array $current_import ) : \Generator {
		yield 10 => __( 'Opening EPUB file', 'pressbooks' );
		$this->setCurrentZip( $current_import['file'] );

		$xml = $this->getOpf();
		$match_ids = array_flip( array_keys( $current_import['chapters'] ) );
		$chapter_parent = $this->getChapterParent();

		yield 30 => __( 'Reading metadata', 'pressbooks' );
		$this->parseMetadata( $xml );

		yield from $this->parseManifestGenerator( $xml, $match_ids, $chapter_parent, $current_import );

		// Done
		yield 95 => __( 'Deleting temporary files', 'pressbooks' );
		if ( ! $this->revokeCurrentImport() ) {
			throw new \Exception();
		}
	}
786645
def visit_Import(self, node):
        
        for alias in node.names:
            current_module = MODULES
            # Recursive check for submodules
            for path in alias.name.split('.'):
                if path not in current_module:
                    raise PythranSyntaxError(
                        "Module '{0}' unknown.".format(alias.name),
                        node)
                else:
                    current_module = current_module[path]
205874
def iter_modules(self, module=None, filename=None, source=None, excludes=None):
    

    if excludes is None:
      excludes = self.excludes

    if not filename:
      if not module:
        raise ValueError('need either module or filename parameter')
      module = self.find_module(module)
      if not module.filename or module.type == 'native':
        return
    else:
      module = ModuleInfo('__main__', filename, ModuleInfo.SRC)

    seen = set()
    stack = collections.deque()

    for imp in get_imports(module.filename, source):
      stack.appendleft((module.join_import_from(imp.name), [module.name]))

    yield module
    while stack:
      import_name, imported_from = stack.pop()
      if import_name in seen:
        continue
      seen.add(import_name)
      if check_module_exclude(import_name, excludes):
        continue

      module = self.find_module(import_name)
      module.imported_from[:] = imported_from
      yield module

      if module.type == ModuleInfo.SRC:
        imported_from = [module.name] + imported_from
        for imp in get_imports(module.filename):
          stack.append((module.join_import_from(imp.name), imported_from))
927104
def imports():
    
    from .core.import_hooks import ExtensionImporter
    importer = ExtensionImporter()
    sys.meta_path.append(importer)
    yield
    sys.meta_path.remove(importer)