Shows a fact stored for a given term, using a case-insensitive search.
    If a fact has an author, it will be shown. If it has a timestamp, that will
    also be shown.
326268
def show_fact(term):
    
    logger.info('Showing fact %s', term)
    record = db.facts.find_one({'term': term_regex(term)})

    if record is None:
        return None

    # Fix double spacing in older facts
    if record['fact']:
        record['fact'] = record['fact'].replace('  ', ' ')

    # If it isn't authored
    if not record.get('set_by', ''):
        return record['fact']

    if 'set_date' not in record:
        return '{fact} ({set_by})'.format(**record)

    # Otherwise, do normal formatting
    tz = getattr(settings, 'TIMEZONE', 'US/Eastern')
    try:
        timestamp = datetime.fromtimestamp(record['set_date'], tz=pytz.timezone(tz))
    except TypeError:
        timestamp = record['set_date'].replace(tzinfo=pytz.timezone(tz))
    record['fmt_dt'] = datetime.strftime(timestamp, '%m/%d/%Y %I:%M%p')

    return '{fact} ({set_by} on {fmt_dt})'.format(**record)
271254
def fact_fqn(name, prefix)
      prefix.empty? ? name : prefix + FactName::SEPARATOR + name
    end
1361218
def query_facts(query, facts = [])
      fields = Hash[facts.collect { |fact| [fact.to_sym, 1] }]
      collection = connection[nodes_collection]
      result = {}
      collection.find(query).batch_size(999).projection(fields).each do |values|
        id = values.delete('_id')
        result[id] = values
      end
      result
    end
79250
def lookup(self):
        
        print "%s by %s, size: %s, uploaded %s ago" % (self.name, self.author,
                                                       self.size, self.age)
1360904
def str_search(self, search: str) -> List[HistoryItem]:
        
        def isin(history_item):
            """filter function for string search of history"""
            sloppy = utils.norm_fold(search)
            return sloppy in utils.norm_fold(history_item) or sloppy in utils.norm_fold(history_item.expanded)
        return [item for item in self if isin(item)]
1336206
def search(self, term, keywords=None, sortAscending=True):
        
        if sortAscending:
            direction = 'ASC'
        else:
            direction = 'DESC'

        return [_SQLiteResultWrapper(r[0]) for r in
                self.store.querySQL(self.searchSQL % (direction,), (term,))]
485005
def show_item(h):
    
    if isinstance(h, rf.Rar3Info):
        show_item_v3(h)
    elif isinstance(h, rf.Rar5Info):
        show_item_v5(h)
    else:
        xprint('Unknown info record')
979938
private static <T> String name(T item, String name) {
    if (name != null && !name.isEmpty()) {
      return name;
    } else if (item instanceof HasMetadata) {
      HasMetadata h = (HasMetadata) item;
      return h.getMetadata() != null ? h.getMetadata().getName() : null;
    }
    return null;
  }
1318220
def select_authors_by_epithet(query):
    

    for epithet, ids in AUTHOR_EPITHET.items():
        if epithet.casefold() == query.casefold():
            return set(ids)
1271936
String showDetail() {
        if (isDefault() || isEmpty()) {
            return "";
        } else {
            return entries.stream()
                    .map(sue -> "---- " + sue.name
                            + (sue.timeStamp.isEmpty()
                                    ? ""
                                    : " @ " + sue.timeStamp)
                            + " ----\n" + sue.content)
                    .collect(joining());
        }
    }
46931
def _metadata_is_invalid(cls, fact):
        
        return (MetadataCache._metadata_is_invalid(fact)
                or any(isinstance(token, BNode) for token in fact))
373025
def search(self, terms):
        
        # load the search information
        if not self._searchurls:
            base = self.tempFilepath()
            root_url = projex.text.underscore(self.text(0))
            for root, folders, files in os.walk(base):
                if '_static' in root:
                    continue
                
                for file in files:
                    if not file.endswith('.html'):
                        continue
                    
                    filename = os.path.join(root, file)
                    url = filename[len(base)+1:].replace('\\', '/')
                    url = root_url + '/' + url.strip('/')
                    url = url.replace('.html', '')
                    
                    f = open(filename, 'r')
                    content = f.read()
                    f.close()
                    
                    self._searchurls[url] = content

        # search for the contents
        output = [] # [(<int> strength>
        term_list = nativestring(terms).split(' ')
        for url, html in self._searchurls.items():
            title           = self.titleForFilepath(url)
            strength        = 0
            all_title_found = True
            all_found       = True
            
            for term in term_list:
                if ( term == title ):
                    strength += 5
                
                elif ( term.lower() == title.lower() ):
                    strength += 4
                    
                elif ( term in title ):
                    strength += 3
                
                elif ( term.lower() in title.lower() ):
                    strength += 2
                
                else:
                    all_title_found = False
                
                if ( not term in html ):
                    all_found = False
                else:
                    strength += 1
            
            if ( all_title_found ):
                strength += len(terms) * 2
            
            if ( all_found ):
                strength += len(terms)
            
            # determine the strength
            if ( strength ):
                output.append({'url': url, 
                               'title': self.titleForFilepath(url),
                               'strength': strength})
        
        return output
1009818
private Set<String> searchForIds(Context context, TermQuery query, ConsistencyLevel readConsistency) {
        Set<String> ids = Sets.newTreeSet();

        BoundStatement bindStatement = m_searchStatement.bind();
        bindStatement.setString(Schema.C_TERMS_CONTEXT, context.getId());
        bindStatement.setString(Schema.C_TERMS_FIELD, query.getTerm().getField(Constants.DEFAULT_TERM_FIELD));
        bindStatement.setString(Schema.C_TERMS_VALUE, query.getTerm().getValue());
        bindStatement.setConsistencyLevel(readConsistency);

        for (Row row : m_session.execute(bindStatement)) {
            ids.add(row.getString(Constants.Schema.C_TERMS_RESOURCE));
        }

        return ids;
    }
157446
def view_entries(search_query=None):
    """"""
    query = Entry.select().order_by(Entry.timestamp.desc())
    if search_query:
        query = query.where(Entry.content.contains(search_query))

    for entry in query:
        timestamp = entry.timestamp.strftime('%A %B %d, %Y %I:%M%p')
        print(timestamp)
        print('=' * len(timestamp))
        print(entry.content)
        print('n) next entry')
        print('d) delete entry')
        print('q) return to main menu')
        action = raw_input('Choice? (Ndq) ').lower().strip()
        if action == 'q':
            break
        elif action == 'd':
            entry.delete_instance()
            break
568959
def contains_case_insensitive(adict, akey):
    """"""
    for key in adict:
        if key.lower() == akey.lower():
            return True
    return False
536452
def process(self, tup):
        
        term, timestamp, search_result = tup.values
        self.log(
            'lookup: {term}, {timestamp}'
            .format(term=term, timestamp=timestamp))
        lookup_result = self.manager.lookup_search_result(search_result)
        self.emit([term, timestamp, lookup_result])
814058
function showFields (data, version, fields) {
  var o = {}
  ;[data,version].forEach(function (s) {
    Object.keys(s).forEach(function (k) {
      o[k] = s[k]
    })
  })
  return search(o, fields.split("."), version._id, fields)
}