Extract query pattern from operations.
555904
def sort_pattern(self):
        """"""
        if not self._sort_pattern:

            # trigger evaluation of operation
            if self.operation in ['query', 'getmore']:
                self._sort_pattern = self._find_pattern('orderby: ')

        return self._sort_pattern
761032
def _annotate_query(query, generate_dict):
    """"""
    annotate_key_list = []
    for field_name, annotate_dict in generate_dict.items():
        for annotate_name, annotate_func in annotate_dict["annotate_dict"].items():
            query = annotate_func(query)
            annotate_key_list.append(annotate_name)
    return query, annotate_key_list
1090394
def clean_query_Dict(cls, query_Dict):
    
    return {k: v for k, v in query_Dict.items() if v}
89363
def extract_queries(self, args, kwargs):
        '''
            
        '''
        return super(MySQLExtPillar, self).extract_queries(args, kwargs)
1017787
def invenio_query_factory(parser=None, walkers=None):
    """"""
    parser = parser or Main
    walkers = walkers or [PypegConverter()]
    walkers.append(ElasticSearchDSL())

    def invenio_query(pattern):
        query = pypeg2.parse(pattern, parser, whitespace="")
        for walker in walkers:
            query = query.accept(walker)
        return query
    return invenio_query
487282
def PATTERN(self):
        
        """
        self.update_mapping()
        return u" |\n".join([pattern_unformatted % (f.name, f._pattern) for f in iter(self)])
447699
def __build_query(self, routine, parameters):
        """"""

        parameter_names = []
        replacements = {}
        for i, value in enumerate(parameters):
            name = 'arg' + str(i)

            parameter_names.append(name)
            replacements[name] = value

        parameter_pieces = []
        for i, name in enumerate(parameter_names):
            if i > 0:
                parameter_pieces.append(', ')

            # Embed encoded blobs directly.
            if issubclass(replacements[name].__class__, _BlobArgumentWrapper) is True:
                parameter_pieces.append(replacements[name].encoded)
                del replacements[name]
            else:
                parameter_pieces.append(':' + name)

        query = "CALL " + routine + "(" + ''.join(parameter_pieces) + ")"

        return (query, replacements)
96503
def query(self,query_string,toprint=False):
		""""""
		qq=SearchTerm(query_string)
		matchcount=0
		matches=[]
		for word in self.words():
			for match in word.search(qq):
				matches.append(match)
				matchcount+=1
				if "Word" in str(type(match)):
					matchstr=""
				else:
					matchstr=str(match)
				if toprint:
					word.om(makeminlength(str(matchcount),int(being.linelen/6))+"\t"+makeminlength(str(word),int(being.linelen))+"\t"+matchstr)
		return matches
1055314
def canned_query(n,s):
    
    qobj = qmap[n]
    chain = qobj['chain']
    prefix = qobj['prefix']
    whr = chain2where(chain + [prefix], 'x')
    query = """
    SELECT * WHERE {{
    <{s}> {w}
    }}
    """.format(s=s, w=whr)
    bindings = run_sparql(query)
    rows = [ensure_prefixed(r['x']['value'], prefix) for r in bindings]
    return rows
1011231
public function extractGraphs($query)
    {
        $graphs = [];

        /**
         * Matches the following pattern: Graph <http://uri/>.
         */
        $result = preg_match_all('/GRAPH\s*\<([a-z0-9\:\/]+)\>/si', $query, $matches);

        if (false !== $result && true === isset($matches[1])) {
            foreach ($matches[1] as $graph) {
                $graphs[] = $graph;
            }
        }

        return $graphs;
    }
57796
def query(self):
        """"""

        if not hasattr(self, '_decoded_query'):
            self._decoded_query = list(urls._url_decode_impl(
                self.querystr.split('&'), 'utf-8', False, True, 'strict'))
        return self.query_cls(self._decoded_query)
85335
def find(self, pattern):
        """"""

        if not os.path.exists(environ.index_db):
            raise RuntimeError("can't find index.db")

        conn = sqlite3.connect(environ.index_db)
        cursor = conn.cursor()
        selected = cursor.execute(
            'SELECT * FROM "%s" WHERE name '
            'LIKE "%%%s%%" ORDER BY LENGTH(name)'
            % (environ.source, pattern)).fetchall()

        pat = re.compile('(%s)' % re.escape(pattern), re.I)

        if selected:
            for name, url, std in selected:
                if os.isatty(sys.stdout.fileno()):
                    print(pat.sub(r'\033[1;31m\1\033[0m', name) +
                          (' \033[1;33m[%s]\033[0m' % std if std else ''))
                else:
                    print(name + (' [%s]' % std if std else ''))
        else:
            raise RuntimeError('%s: nothing appropriate.' % pattern)
1269300
def query(wosclient, wos_query, xml_query=None, count=5, offset=1, limit=100):
    """"""
    results = [single(wosclient, wos_query, xml_query, min(limit, count-x+1), x)
               for x in range(offset, count+1, limit)]
    if xml_query:
        return [el for res in results for el in res]
    else:
        pattern = _re.compile(r'^<\?xml.*?\n<records>\n|\n</records>$.*')
        return ('<?xml version="1.0" ?>\n<records>' +
                '\n'.join(pattern.sub('', res) for res in results) +
                '</records>')
1071660
def iter_query(query):
    """"""
    try:
        itr = click.open_file(query).readlines()
    except IOError:
        itr = [query]
    return itr
1001433
def parse_query(self, query):
        """"""
        tree = pypeg2.parse(query, Main, whitespace="")
        return tree.accept(self.converter)
1106604
def query_string_parser(search_pattern):
    """"""
    if not hasattr(current_oaiserver, 'query_parser'):
        query_parser = current_app.config['OAISERVER_QUERY_PARSER']
        if isinstance(query_parser, six.string_types):
            query_parser = import_string(query_parser)
        current_oaiserver.query_parser = query_parser
    return current_oaiserver.query_parser('query_string', query=search_pattern)
160892
def parse_query_output(cls, out):
        
        query_data = {}

        for line in out.strip().split("\n"):
            parts = line.split()
            if len(parts) < 6:
                continue

            job_id = parts[0]
            status_flag = parts[2]

            # map the status
            status = cls.map_status(status_flag)

            # save the result
            query_data[job_id] = cls.job_status_dict(job_id=job_id, status=status)

        return query_data