text
stringlengths
0
828
sym.datatable = Table(sym.name, Base.metadata, autoload=True)
sym.datatable.drop(self.eng, checkfirst=True)
except NoSuchTableError:
print ""No worries, {} never existed to begin with."".format(sym.name)
self.ses.delete(sym)
self.ses.commit()"
1843,"def exists(self, symbol):
""""""Checks to if a symbol exists, by name.
Parameters
----------
symbol : str or Symbol
Returns
-------
bool
""""""
if isinstance(symbol, str):
sym = symbol
elif isinstance(symbol, Symbol):
sym = symbol.name
syms = self.ses.query(Symbol).filter(Symbol.name == sym).all()
if len(syms) == 0:
return False
else:
return True"
1844,"def get(self, symbol):
"""""" Gets a Symbol based on name, which is expected to exist.
Parameters
----------
symbol : str or Symbol
Returns
-------
Symbol
Raises
------
Exception
If it does not exist. Use .try_to_get(),
if the symbol may or may not exist.
""""""
syms = self.try_to_get(symbol)
if syms is None:
raise Exception(""Symbol {} does not exist"".format(symbol))
else:
return syms"
1845,"def try_to_get(self, symbol):
"""""" Gets a Symbol based on name, which may or may not exist.
Parameters
----------
symbol : str
Returns
-------
Symbol or None.
Note
----
Use .get(), if the symbol should exist, and an exception
is needed if it doesn't.
""""""
syms = self.ses.query(Symbol).filter(Symbol.name == symbol).all()
if len(syms) == 0:
return None
else:
return syms[0]"
1846,"def search_meta(self, attr, value=None, stronly=False):
"""""" Get a list of Symbols by searching a specific meta
attribute, and optionally the value.
Parameters
----------
attr : str
The meta attribute to query.
value : None, str or list
The meta attribute to query. If you pass a float, or an int,
it'll be converted to a string, prior to searching.
stronly : bool, optional, default True
Return only a list of symbol names, as opposed
to the (entire) Symbol objects.
Returns
-------
List of Symbols or empty list
""""""
if stronly:
qry = self.ses.query(Symbol.name).join(SymbolMeta)
else:
qry = self.ses.query(Symbol).join(SymbolMeta)
crits = []