Query database for unique tag types.
164774
def _ListTags(self):
    """"""
    all_tags = []
    self._cursor.execute('SELECT DISTINCT tag FROM log2timeline')

    # This cleans up the messy SQL return.
    tag_row = self._cursor.fetchone()
    while tag_row:
      tag_string = tag_row[0]
      if tag_string:
        tags = tag_string.split(',')
        for tag in tags:
          if tag not in all_tags:
            all_tags.append(tag)
      tag_row = self._cursor.fetchone()
    # TODO: make this method an iterator.
    return all_tags
1185290
def tags_from_hit(self, tag_ids):
        
        ids = []
        for t in tag_ids.split():
            t = t.strip()
            try:
                t = int(t)
            except ValueError:
                pass
            else:
                ids.append(t)

        if not ids:
            return []

        return Tag.query.filter(Tag.id.in_(ids)).all()
359506
def query(self, querystring):
        
        mode = Database.MODE.READ_ONLY
        db = Database(path=self.path, mode=mode)
        q = db.create_query(querystring)
        # add configured exclude tags
        for tag in settings.get('exclude_tags'):
            q.exclude_tag(tag)
        return q
708619
def get_episode_types(db) -> Iterator[EpisodeType]:
    """"""
    cur = db.cursor()
    cur.execute('SELECT id, name, prefix FROM episode_type')
    for type_id, name, prefix in cur:
        yield EpisodeType(type_id, name, prefix)
1121879
def all_sample_md5s(self, type_tag=None):
        

        if type_tag:
            cursor = self.database[self.sample_collection].find({'type_tag': type_tag}, {'md5': 1, '_id': 0})
        else:
            cursor = self.database[self.sample_collection].find({}, {'md5': 1, '_id': 0})
        return [match.values()[0] for match in cursor]
1079237
def searchTag(self,HTAG="#arenaNETmundial"):
        """"""
        search = t.search(q=HTAG,count=100,result_type="recent")
        ss=search[:]
        search = t.search(q=HTAG,count=150,max_id=ss[-1]['id']-1,result_type="recent")
        #search = t.search(q=HTAG,count=150,since_id=ss[-1]['id'],result_type="recent")
        while seach:
            ss+=search[:]
            search = t.search(q=HTAG,count=150,max_id=ss[-1]['id']-1,result_type="recent")
563452
def query(name):
    """"""
    collection = Collection.query.filter_by(name=name).one()
    click.echo(collection.dbquery)
1253705
def get_database_tag(self):
        '''
        
        '''

        def parse_response(doc):
            self._database_tag = doc['tag']
            return self._database_tag

        def create_new(fail):
            fail.trap(NotFoundError)
            doc = {'_id': doc_id, 'tag': unicode(uuid.uuid1())}
            return self.save_document(doc)

        def conflict_handler(fail):
            fail.trap(ConflictError)
            return self.get_database_tag()


        if not hasattr(self, '_database_tag'):
            doc_id = u'_local/database_tag'
            d = self.get_document(doc_id)
            d.addErrback(create_new)
            d.addErrback(conflict_handler)
            d.addCallback(parse_response)
            return d
        else:
            return defer.succeed(self._database_tag)
667765
def tagged(self, other_model=None, queryset=None):
        
        tags = self._taglist(other_model, queryset)
        return self.get_queryset().filter(tags__in=tags).distinct()
49040
def v_unique_name_defintions(ctx, stmt):
    """"""
    defs = [('typedef', 'TYPE_ALREADY_DEFINED', stmt.i_typedefs),
            ('grouping', 'GROUPING_ALREADY_DEFINED', stmt.i_groupings)]
    def f(s):
        for (keyword, errcode, dict) in defs:
            if s.keyword == keyword and s.arg in dict:
                err_add(ctx.errors, dict[s.arg].pos,
                        errcode, (s.arg, s.pos))

    for i in stmt.search('include'):
        submodulename = i.arg
        subm = ctx.get_module(submodulename)
        if subm is not None:
            for s in subm.substmts:
                for ss in s.substmts:
                    iterate_stmt(ss, f)
951372
def _get_unique_child(xtag, eltname):
    """"""
    try:
        results = xtag.findall(eltname)
        if len(results) > 1:
            raise Exception("Multiple elements found where 0/1 expected")
        elif len(results) == 1:
            return results[0]
        else:
            return None
    except Exception:
        return None
7191
def list_unique(cls):
		'''

		'''
		query = meta.Session.query(Predicate).distinct(Predicate.namespace)
		return query.all()
1009037
function(db) {
		return db.query('SELECT name FROM types WHERE name IS NOT NULL').then(function(db) {
			var types = db.fetch();
			debug.assert(types).is('array');

			var queries = ARRAY(types).map(function step_builder(type) {
				if(type && type.name) {
					return NoPg.createTriggerQueriesForType(type.name);
				}
				return [];
			}).reduce(function(a, b) {
				return a.concat(b);
			}, []);

			return queries.map(function(q) {
				return db.query(q);
			}).reduce(_Q.when, _Q(db));
		});
	}
238443
def query_all(kind='1', by_count=False, by_order=True):
        '''
        
        '''
        if by_count:
            recs = TabTag.select().where(TabTag.kind == kind).order_by(TabTag.count.desc())
        elif by_order:
            recs = TabTag.select().where(TabTag.kind == kind).order_by(TabTag.order)
        else:
            recs = TabTag.select().where(TabTag.kind == kind).order_by(TabTag.uid)
        return recs
157057
def where_entry_tag(query, tag):
    
    if isinstance(tag, (list, set, tuple)):
        tags = [t.lower() for t in tag]
        return orm.select(e for e in query for t in e.tags if t.key in tags)
    return orm.select(e for e in query for t in e.tags if t.key == tag.lower())
242957
function findAll(tags, key) {
  return tags
    .filter(function(tag) {
      return tag && tag.type === key
    })
    .map(function(tag) {
      return tag.string
    })
}
52227
def unique(seq):
    """"""
    seen = {}
    result = []
    for item in seq:
        marker = item
        if marker in seen:
            continue
        seen[marker] = 1
        result.append(item)
    return result