Search notes for a given (possibly abbreviated) hash
10961
def find_by_hash(self, hash=None, book=-1):
        ''''''
        if hash:
            self.fyi("nota.find_by_hash() with abbreviated hash %s; book=%s" % (hash, book))
        try:
            if book < 0:
                rows = self.cur.execute("SELECT noteId, hash FROM note WHERE book > 0;").fetchall()
            else:
                rows = self.cur.execute("SELECT noteId, hash FROM note WHERE book=?;", [book]).fetchall()
        except:
            self.error("nota.find_by_hash() cannot look up note list")
        # Possibly save time by finding IDs first.
        noteIds = []
        if hash:
            l = len(hash)
            for r in rows:
                if hash == r[1][0:l]:
                    noteIds.append((r[0],))
        else:
            for r in rows:
                noteIds.append((r[0],))
        self.fyi("noteIds: %s" % noteIds)
        rval = []
        for n in noteIds:
            try:
                note = self.cur.execute("SELECT noteId, authorId, date, title, content, due, privacy, modified, hash, book FROM note WHERE noteId=?;", n).fetchone()
            except:
                self.warning("Problem extracting note %s from database" % n)
                next
            if note:
                date = note[2]
                due = note[5]
                privacy = note[6]
                keywordIds = []
                keywordIds.extend(self.con.execute("SELECT keywordid FROM notekeyword WHERE notekeyword.noteid=?;", n))
                keywords = []
                for k in keywordIds:
                    keywords.append(self.cur.execute("SELECT keyword FROM keyword WHERE keywordId=?;", k).fetchone()[0])
                rval.append({"noteId":note[0], "title":note[3], "keywords":keywords,
                    "content":note[4], "due":note[5], "privacy":note[6],
                    "date":note[2], "modified":note[7], "hash":note[8], "book":note[9]})
        return rval
788362
def search(text, start, wdic, result)
      if RUBY_VERSION >= '1.9.0'
        txt = text.bytes.to_a
      else
        txt = text.unpack('C*')
      end
      txtu = text.unpack("U*")
      length = txtu.size
      ch = txtu[start]
      ct = @category.category(ch)
    
      if !result.empty? and !ct.invoke
        return
      end
    
      is_space = (ct.id == @space_id)
      limit = [length, ct.length + start].min
    
      for i in start..(limit - 1)
        wdic.search_from_trie_id(ct.id, start, (i - start) + 1, is_space, result)
        
        if((i + 1) != limit and !(@category.compatible?(ch, txt[i + 1])))
          return
        end
      end
    
      if ct.group and limit < length
        for i in limit..(length - 1)
          if not @category.compatible?(ch, txtu[i])
            wdic.search_from_trie_id(ct.id, start, i - start, is_space, result)
            return
          end
        end
        wdic.search_from_trie_id(ct.id, start, length - start, is_space, result)
      end
    end
630289
def search(index, query, snippet_folder=SNIPPET_FOLDER, term_freq=term_freq):
    
    fallback_log = []
    code_list = []
    tokens = tokenize(query)
    tokens, abbr_log = abbr_expand(tokens)
    tokens, correct_log = correct(tokens, term_freq)
    tokens = lemmatize(tokens)
    tokens = filterout(tokens)
    while len(tokens) > 0: # Fallback mechanism
        code_list = fetch(index, tokens)
        if len(code_list) > 0:
            break
        tokens.sort(key=lambda tk:len(index.get(tk, [])))
        remove = tokens.pop()
        fallback_log.append(remove)
    snippets = get_snippets(code_list, snippet_folder)
    hints, hint_scores = get_hints(code_list, current_tokens=tokens)
    response = list(zip(code_list, snippets))
    response.sort(key=result_sort_key, reverse=True)

    # Count search_frequency
    if len(response) <= MAX_RESULT: # the respone can be shown in one page
        search_freq.update(code_list)
        with open(SEARCH_FREQ_JSON, 'w') as f:
            json.dump(search_freq, f, indent=2)

    return response, tokens, hints, hint_scores, \
           abbr_log, correct_log, fallback_log
425318
def compiled_hash_func(self):
        """"""

        def get_primary_key_str(pkey_name):
            return "str(self.{})".format(pkey_name)

        hash_str = "+ ".join([get_primary_key_str(n) for n in self.primary_keys])
        return ALCHEMY_TEMPLATES.hash_function.safe_substitute(concated_primary_key_strs=hash_str)
633226
def notes(self):
        """"""
        endpoint = '/'.join((self.endpoint, self.id, 'notes'))
        return self.noteFactory.find(
            endpoint=endpoint,
            api_key=self.api_key,
        )
1095421
def note_adapter(obj, request):
    '''
    
    '''
    return {
        'note': obj.note,
        'type': obj.type,
        'language': obj.language,
        'markup': obj.markup
    }
974576
def notes(self):
        """"""
        return tuple(self._get_note_data(note) for note in self.root.iter('note'))
930768
def get_citation_by_hash(self, citation_hash: str) -> Optional[Citation]:
        """"""
        return self.session.query(Citation).filter(Citation.sha512 == citation_hash).one_or_none()
526409
def hash_coloured_escapes(text):
    """"""
    ansi_code = int(sha256(text.encode('utf-8')).hexdigest(), 16) % 230
    prefix, suffix = colored('SPLIT', ansi_code=ansi_code).split('SPLIT')
    return prefix, suffix
10860
function(z_query) {
			
			// hash query
			if(typeof z_query == 'object') {
				return query_hash(z_query);
			}
			// string
			else if(typeof z_query == 'string') {

				if(z_query[0] == ':' || z_query[0] == '?') {
					return qb({
						select: '',
						where: '\n'+z_query,
						tail: '',
						group: '',
						order: '',
						limit: '',
					});
				}

				return query_string(z_query);
			}
		}
986438
def notes(element_key)
      parameter = { basic_auth: @auth }

      response = self.class.get("/elements/#{element_key}/notes", parameter)
      if response.success?
        search_response_header = SearchResponseHeader.new(response)
        search_response_header.elementList
      end
    end
613104
def is_hash(fhash):
    """"""

    # Intentionally doing if/else statement for ease of testing and reading
    if re.match(re_md5, fhash):
        return True
    elif re.match(re_sha1, fhash):
        return True
    elif re.match(re_sha256, fhash):
        return True
    elif re.match(re_sha512, fhash):
        return True
    elif re.match(re_ssdeep, fhash):
        return True
    else:
        return False
941942
def get_note_names(self):
        """"""
        res = []
        for cont in self.bar:
            for x in cont[2].get_note_names():
                if x not in res:
                    res.append(x)
        return res
499558
def findByBiSearch(self, strSeq) :
		""""""
		arr = self.encode(strSeq)
		return self._dichFind(arr[0], self, 0, lst = None)
73822
def search_in(label, string)
      raise(ArgumentError, "Unknown key: #{label}") unless LABELS.include?(label.to_sym)

      find_all do |entry|
        text = entry.send(label).str
        text.match(/#{string}/i)
      end
    end
289126
def find_this(search, source=SOURCE):
    """"""
    print("Searching for {what}.".format(what=search))
    if not search or not source:
        print("Not found on source: {what}.".format(what=search))
        return ""
    return str(re.compile(r'.*__{what}__ = "(.*?)"'.format(
        what=search), re.S).match(source).group(1)).strip()
630328
def _hits_hashed_by_query(self, hits):
        ''''''
        d = {}
        for hit in hits:
            if hit.qry_name not in d:
                d[hit.qry_name] = []
            d[hit.qry_name].append(hit)
        return d