text
stringlengths
0
828
ret = self._check_self_replicate(myntr)
if ret == 1:
change = 1
elif ret != 0:
return ret
if optimized and self._check_intemediate(
myntr, self.maxstate):
change = 1
break"
1840,"def project_workspace_addsitedir(sitedir):
""""""
Similar to site.addsitedir() but prefers new sitedir over existing ones.
Therefore, prefers local packages over installed packages.
.. note::
This allows to support *.pth files and zip-/egg-imports
similar to an installed site-packages directory.
""""""
assert os.path.isdir(sitedir)
try:
from site import addsitedir
except ImportError:
# -- USE: Python2.7 site.py package
from pysite import addsitedir
next_package_pos = len(sys.path)
addsitedir(sitedir)
# -- POST-PROCESS: Move new packages from end to begin of sys.path list.
pos = 0
new_packages = sys.path[next_package_pos:]
del sys.path[next_package_pos:]
sys.path[pos:pos] = new_packages"
1841,"def create(self, name, description=None, units=None,
agg_method=""priority_fill"", overwrite=False):
"""""" Create, or get if exists, a Symbol.
Parameters
----------
name : str
A symbol's name is a primary key, used across
the Trump ORM.
description : str, optional
An arbitrary string, used to store user information
related to the symbol.
units : str, optional
This is a string used to denote the units of the final
data Series.
agg_method : str, optional
The aggregation method, used to calculate
the final feed. Defaults to priority_fill.
overwrite : bool, optional
Set to True, to force deletion an existing symbol.
defaults to False.
Returns
-------
Symbol
""""""
sym = self.try_to_get(name)
if sym is not None:
if overwrite:
print ""Deleting {}"".format(sym.name)
self.ses.delete(sym)
self.ses.commit()
else:
msg = 'Symbol {} already exists.\n' + \
'Consider setting overwrite to True.'
msg = msg.format(name)
raise Exception(msg)
sym = Symbol(name, description, units, agg_method)
self.ses.add(sym)
print ""Creating {}"".format(sym.name)
sym.add_alias(name)
sym.handle = SymbolHandle(sym=sym)
self.ses.commit()
return sym"
1842,"def delete(self, symbol):
""""""
Deletes a Symbol.
Parameters
----------
symbol : str or Symbol
""""""
if isinstance(symbol, (str, unicode)):
sym = self.get(symbol)
elif isinstance(symbol, Symbol):
sym = symbol
else:
raise Exception(""Invalid symbol {}"".format((repr(symbol))))
# Has to handle the case where the table would exist already
# and where it wouldn't.
try: