Implement xmlrpc search command.

    This only searches through the mirrored and private packages
965317
def search(spec, operator='and'):
    
    field_map = {
        'name': 'name__icontains',
        'summary': 'releases__summary__icontains',
    }

    query_filter = None
    for field, values in spec.items():
        for value in values:
            if field not in field_map:
                continue

            field_filter = Q(**{field_map[field]: value})
            if not query_filter:
                query_filter = field_filter
                continue

            if operator == 'and':
                query_filter &= field_filter
            else:
                query_filter |= field_filter

    result = []
    packages = models.Package.objects.filter(query_filter).all()[:20]
    for package in packages:
        release = package.releases.all()[0]
        result.append({
            'name': package.name,
            'summary': release.summary,
            'version': release.version,
            '_pypi_ordering': 0,
        })
    return result
490248
@Override
    public synchronized void searchMCS(boolean shouldMatchBonds) {
        List<List<Integer>> mappings = null;
        try {
            if (source.getAtomCount() >= target.getAtomCount()) {
                mappings = new MCSPlus().getOverlaps(source, target, shouldMatchBonds);
            } else {
                flagExchange = true;
                mappings = new MCSPlus().getOverlaps(target, source, shouldMatchBonds);
            }
            PostFilter.filter(mappings);
            setAllMapping();
            setAllAtomMapping();
            setFirstMapping();
            setFirstAtomMapping();
        } catch (CDKException e) {
            mappings = null;
        }
    }
712148
def transport_xmlrpc(self):
        
        # Install the bundle
        self.context.install_bundle("pelix.remote.xml_rpc").start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(
                rs.FACTORY_TRANSPORT_XMLRPC_EXPORTER, "pelix-xmlrpc-exporter"
            )
            ipopo.add(
                rs.FACTORY_TRANSPORT_XMLRPC_IMPORTER, "pelix-xmlrpc-importer"
            )
1019230
private ShareTarget findShareTarget(String pkg) {
        for (ShareTarget target : mShareTargets) {
            if (pkg.equals(target.packageName)) {
                return target;
            }
        }
        return null;
    }
891080
def resolve_any_xref(self, env, fromdocname, builder, target,
                         node, contnode):
        
        modname = node.get('chpl:module')
        clsname = node.get('chpl:class')
        results = []

        # Always search in "refspecific" mode with the :any: role.
        matches = self.find_obj(env, modname, clsname, target, None, 1)
        for name, obj in matches:
            if obj[1] == 'module':
                results.append(('chpl:mod',
                                self._make_module_refnode(builder, fromdocname,
                                                          name, contnode)))
            else:
                results.append(
                    ('chpl:' + self.role_for_objtype(obj[1]),
                     make_refnode(builder, fromdocname, obj[0], name,
                                  contnode, name)))

        return results
879843
def _detect(env):
    
    global prefer_xsltproc
    
    if env.get('DOCBOOK_PREFER_XSLTPROC',''):
        prefer_xsltproc = True
        
    if ((not has_libxml2 and not has_lxml) or (prefer_xsltproc)):
        # Try to find the XSLT processors
        __detect_cl_tool(env, 'DOCBOOK_XSLTPROC', xsltproc_com, xsltproc_com_priority)
        __detect_cl_tool(env, 'DOCBOOK_XMLLINT', xmllint_com)

    __detect_cl_tool(env, 'DOCBOOK_FOP', fop_com, ['fop','xep','jw'])
1134388
def _findSwiplDar():
    

    # If the exec is in path
    (path, swiHome) = _findSwiplFromExec()
    if path is not None:
        return (path, swiHome)

    # If it is not, use  find_library
    path = _findSwiplPathFromFindLib()
    if path is not None:
        return (path, swiHome)

    # Last guess, searching for the file
    paths = ['.', './lib', '/usr/lib/', '/usr/local/lib', '/opt/local/lib']
    names = ['libswipl.dylib', 'libpl.dylib']

    for name in names:
        for path in paths:
            path = os.path.join(path, name)
            if os.path.exists(path):
                return (path, None)

    return (None, None)
1075394
def search(cls, query, search_opts=None):
        

        if search_opts is None:
            search_opts = {}

        xmlrpc = XMLRPCConnection()
        try:
            search_result = xmlrpc.connection.search_tag(
                {
                    'query': query,
                    'search_options': search_opts,
                    'auth': AuthOptions().options
                })
        except xmlrpclib.Fault as xml_fault:
            raise _fault_to_exception(xml_fault)

        result = dict()
        result['result'] = []
        result['search_options'] = search_result['search_options']
        for xml_tag in search_result['result']:
            result['result'].append(Tag.from_dict(xml_tag))

        return result
58905
def search_packages_info(query):
    
    installed = {}
    for p in pkg_resources.working_set:
        installed[canonicalize_name(p.project_name)] = p

    query_names = [canonicalize_name(name) for name in query]

    for dist in [installed[pkg] for pkg in query_names if pkg in installed]:
        package = {
            'name': dist.project_name,
            'version': dist.version,
            'location': dist.location,
            'requires': [dep.project_name for dep in dist.requires()],
        }
        file_list = None
        if isinstance(dist, pkg_resources.DistInfoDistribution):
            # RECORDs should be part of .dist-info metadatas
            if dist.has_metadata('RECORD'):
                lines = dist.get_metadata_lines('RECORD')
                paths = [l.split(',')[0] for l in lines]
                paths = [os.path.join(dist.location, p) for p in paths]
                file_list = [os.path.relpath(p, dist.location) for p in paths]
        else:
            # Otherwise use pip's log for .egg-info's
            if dist.has_metadata('installed-files.txt'):
                paths = dist.get_metadata_lines('installed-files.txt')
                paths = [os.path.join(dist.egg_info, p) for p in paths]
                file_list = [os.path.relpath(p, dist.location) for p in paths]

        if file_list:
            package['files'] = sorted(file_list)
        yield package
1304221
def search(self, *args, **kwargs):
        
        return self._get(self._build_url(self.endpoint.search(*args, **kwargs)))
118386
public function searchPackages($text, OnPackageFoundInterface $callback, $onlyName = false, $includeLocal = true) {
		$this->onPackageFoundCallback = $callback;
		$composer = $this->getComposer();
		$platformRepo = new PlatformRepository;

		$searched = array();
		
		if ($includeLocal) {
			$localRepo = $composer->getRepositoryManager()->getLocalRepository();
			$searched[] = $localRepo;
		}
		$searched[] = $platformRepo;
		$installedRepo = new CompositeRepository($searched);
		$repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
		
		//$this->onlyName = $input->getOption('only-name');
		$this->onlyName = $onlyName;
		//$this->tokens = $input->getArgument('tokens');
		$this->tokens = explode(" ", $text);
		
		//$this->output = $output;
		$repos->filterPackages(array($this, 'processPackage'), 'Composer\Package\CompletePackage');
		
		/*foreach ($this->lowMatches as $details) {
			$output->writeln($details['name'] . '<comment>:</comment> '. $details['description']);
		}*/
	}
1144748
private void searchSubPackage(String packageName,
                                  ListBuffer<String> packages,
                                  List<String> excludedPackages,
                                  Collection<File> pathnames) {
        if (excludedPackages.contains(packageName))
            return;

        String packageFilename = packageName.replace('.', File.separatorChar);
        boolean addedPackage = false;
        for (File pathname : pathnames) {
            File f = new File(pathname, packageFilename);
            String filenames[] = f.list();
            // if filenames not null, then found directory
            if (filenames != null) {
                for (String filename : filenames) {
                    if (!addedPackage
                            && (isValidJavaSourceFile(filename) ||
                                isValidJavaClassFile(filename))
                            && !packages.contains(packageName)) {
                        packages.append(packageName);
                        addedPackage = true;
                    } else if (isValidClassName(filename) &&
                               (new File(f, filename)).isDirectory()) {
                        searchSubPackage(packageName + "." + filename,
                                         packages, excludedPackages, pathnames);
                    }
                }
            }
        }
    }
329712
def _find_packages_iter(cls, where, exclude, include):
        
        for root, dirs, files in os.walk(where, followlinks=True):
            # Copy dirs to iterate over it, then empty dirs.
            all_dirs = dirs[:]
            dirs[:] = []

            for dir in all_dirs:
                full_path = os.path.join(root, dir)
                rel_path = os.path.relpath(full_path, where)
                package = rel_path.replace(os.path.sep, '.')

                # Skip directory trees that are not valid packages
                if ('.' in dir or not cls._looks_like_package(full_path)):
                    continue

                # Should this package be included?
                if include(package) and not exclude(package):
                    yield package

                # Keep searching subdirectories, as there may be more packages
                # down there, even if the parent was excluded.
                dirs.append(dir)
450477
protected void searchAndReplace(List<CmsResource> resources) {

        // the file counter
        int counter = 0;
        int resCount = resources.size();
        I_CmsReport report = getReport();
        // iterate over the files in the selected path
        for (CmsResource resource : resources) {

            try {

                // get the content
                CmsFile file = getCms().readFile(resource);
                byte[] contents = file.getContents();

                // report the current resource
                ++counter;
                report(report, counter, resCount, resource);

                // search and replace
                byte[] result = null;
                boolean xpath = false;
                if ((CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_settings.getXpath())
                    || m_settings.isOnlyContentValues()) && CmsResourceTypeXmlContent.isXmlContent(resource)) {
                    xpath = true;
                }
                if (!xpath) {
                    result = replaceInContent(file, contents);
                } else {
                    result = replaceInXml(file);
                }

                if ((result != null) && (contents != null) && !contents.equals(result)) {
                    // rewrite the content
                    writeContent(file, result);
                } else {
                    getReport().println();
                }

            } catch (Exception e) {
                report.print(
                    org.opencms.report.Messages.get().container(Messages.RPT_SOURCESEARCH_COULD_NOT_READ_FILE_0),
                    I_CmsReport.FORMAT_ERROR);
                report.addError(e);
                report.println(
                    org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_FAILED_0),
                    I_CmsReport.FORMAT_ERROR);
                m_errorSearch += 1;
                LOG.error(
                    org.opencms.report.Messages.get().container(Messages.RPT_SOURCESEARCH_COULD_NOT_READ_FILE_0),
                    e);
                continue;
            }
        }

        // report results
        reportResults(resources.size());
    }
146650
def search(self, read_cache=True, ssl_verify=True, recid=None, **kwparams):
        
        parse_results = False
        of = kwparams.get('of', "")
        if of == "":
            parse_results = True
            of = "xm"
            kwparams['of'] = of
        params = kwparams
        cache_key = (json.dumps(params), parse_results)

        if cache_key not in self.cached_queries or \
                not read_cache:
            if recid:
                results = requests.get(self.server_url + '/record/' + recid,
                                       params=params, cookies=self.cookies,
                                       stream=True, verify=ssl_verify,
                                       allow_redirects=True)
                if results.history:
                    new_recid = urlparse(results.url).path.split('/')[-1]
                    raise InvenioConnectorServerError('The record has been'
                                                      'merged with recid ' +
                                                      new_recid)
            else:
                results = requests.get(self.server_url + "/search",
                                       params=params, cookies=self.cookies,
                                       stream=True, verify=ssl_verify)
            if 'youraccount/login' in results.url:
                # Current user not able to search collection
                raise InvenioConnectorAuthError(
                    "You are trying to search a restricted collection. "
                    "Please authenticate yourself.\n")
        else:
            return self.cached_queries[cache_key]

        if parse_results:
            # FIXME: we should not try to parse if results is string
            parsed_records = self._parse_results(results.raw,
                                                 self.cached_records)
            self.cached_queries[cache_key] = parsed_records
            return parsed_records
        else:
            # pylint: disable=E1103
            # The whole point of the following code is to make sure we can
            # handle two types of variable.
            try:
                res = results.content
            except AttributeError:
                res = results
            # pylint: enable=E1103

            if of == "id":
                try:
                    if isinstance(res, binary_type):
                        # Transform to list
                        res = [int(recid.strip()) for record_id in
                               res.decode('utf-8').strip("[]").split(",")
                               if record_id.strip() != ""]
                    res.reverse()
                except (ValueError, AttributeError):
                    res = []
            self.cached_queries[cache_key] = res
            return res
1098570
def search(self, term):
        
        packages = {}
        results = self._execute_pip(['search', term], log=False)  # Don't want to log searches
        for result in results.split(linesep):
            try:
                name, description = result.split(six.u(' - '), 1)
            except ValueError:
                # '-' not in result so unable to split into tuple;
                # this could be from a multi-line description
                continue
            else:
                name = name.strip()
                if len(name) == 0:
                    continue
                packages[name] = description.split(six.u('<br'), 1)[0].strip()
        return packages
1361468
def _get_splunk_search_props(search):
    '''
    
    '''
    props = search.content
    props["app"] = search.access.app
    props["sharing"] = search.access.sharing
    return props