text
stringlengths
0
828
Returns
-------
TrumpReport
""""""
syms = self.search_tag(tag)
name = 'Bulk Cache of Symbols tagged {}'.format(tag)
tr = TrumpReport(name)
for sym in syms:
sr = sym.cache()
tr.add_symbolreport(sr)
return tr"
1852,"def build_view_from_tag(self, tag):
""""""
Build a view of group of Symbols based on their tag.
Parameters
----------
tag : str
Use '%' to enable SQL's ""LIKE"" functionality.
Note
----
This function is written without SQLAlchemy,
so it only tested on Postgres.
""""""
syms = self.search_tag(tag)
names = [sym.name for sym in syms]
subs = [""SELECT indx, '{}' AS symbol, final FROM {}"".format(s, s) for s in names]
qry = "" UNION ALL "".join(subs)
qry = ""CREATE VIEW {} AS {};"".format(tag, qry)
self.ses.execute(""DROP VIEW IF EXISTS {};"".format(tag))
self.ses.commit()
self.ses.execute(qry)
self.ses.commit()"
1853,"def _add_orfs(self, which, symbol, ind, val, dt_log=None, user=None, comment=None):
""""""
Appends a single indexed-value pair, to a symbol object, to be
used during the final steps of the aggregation of the datatable.
See add_override and add_fail_safe.
Parameters
----------
which : str
Fail Safe or Override?
symbol : Symbol or str
The Symbol to apply the fail safe
ind : obj
The index value where the fail safe should be applied
val : obj
The data value which will be used in the fail safe
dt_log : datetime
A log entry, for saving when this fail safe was created.
user : str
A string representing which user made the fail safe
comment : str
A string to store any notes related to this fail safe.
""""""
if not isinstance(symbol, (str, unicode)):
symbol = symbol.name
if not dt_log:
dt_log = dt.datetime.now()
if which.lower() == 'override':
qry = self.ses.query(func.max(Override.ornum).label('max_ornum'))
override = True
elif which.lower() == 'failsafe':
qry = self.ses.query(func.max(FailSafe.fsnum).label('max_fsnum'))
override = False
qry = qry.filter_by(symname = symbol)
cur_num = qry.one()
if cur_num[0] is None:
next_num = 0
else:
next_num = cur_num[0] + 1
if override:
tmp = Override(symname=symbol,
ind=ind,
val=val,
dt_log=dt_log,
user=user,
comment=comment,
ornum=next_num)