text
stringlengths
0
828
if value is None:
crits.append(SymbolMeta.attr == attr)
else:
if isinstance(value, str):
values = [value]
elif isinstance(value, (tuple, list)):
values = value
for v in values:
crits.append(and_(SymbolMeta.attr == attr, SymbolMeta.value.like(value)))
if len(crits):
qry = qry.filter(or_(*crits))
qry = qry.order_by(Symbol.name)
if stronly:
return [sym[0] for sym in qry.distinct()]
else:
return [sym for sym in qry.distinct()]"
1847,"def search(self, usrqry=None, name=False, desc=False, tags=False, meta=False, stronly=False, dolikelogic=True):
"""""" Get a list of Symbols by searching a combination of
a Symbol's name, description, tags or meta values.
Parameters
----------
usrqry : str
The string used to query. Appending '%' will use SQL's ""LIKE""
functionality.
name : bool, optional, default False
Search by symbol name.
desc : bool, optional, default False
Search by symbol descriptions.
tags : bool, optional, default False
Search by symbol tags.
meta : bool, optional, default False
Search within a symbol's meta attribute's value.
stronly : bool, optional, default True
Return only a list of symbol names, as opposed
to the (entire) Symbol objects.
dolikelogic :
Append '%' to either side of the string, if the string
doesn't already have % specified.
Returns
-------
List of Symbols or empty list
""""""
if stronly:
qry = self.ses.query(Symbol.name)
else:
qry = self.ses.query(Symbol)
if tags:
qry = qry.join(SymbolTag)
if meta:
qry = qry.join(SymbolMeta)
if dolikelogic:
if usrqry is not None:
if '%' not in usrqry:
usrqry = '%' + usrqry + '%'
crits = []
if name:
crits.append(Symbol.name.like(usrqry))
if tags:
crits.append(SymbolTag.tag.like(usrqry))
if desc:
crits.append(Symbol.description.like(usrqry))
if meta:
crits.append(SymbolMeta.value.like(usrqry))
if len(crits):
qry = qry.filter(or_(*crits))
qry = qry.order_by(Symbol.name)
if stronly:
return [sym[0] for sym in qry.distinct()]
else:
return [sym for sym in qry.distinct()]"
1848,"def search_tag(self, tag, symbols=True, feeds=False):
"""""" Get a list of Symbols by searching a tag or partial tag.
Parameters
----------
tag : str
The tag to search. Appending '%' will use SQL's ""LIKE""
functionality.
symbols : bool, optional
Search for Symbol's based on their tags.
feeds : bool, optional
Search for Symbol's based on their Feeds' tags.
Returns
-------
List of Symbols or empty list