input stringlengths 11 7.65k | target stringlengths 22 8.26k |
|---|---|
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def _db_schema_sanity_check(engine):
"""Ensure all database tables were created with required parameters.
:param engine: SQLAlchemy engine instance for a given database
"""
if engine.name == 'mysql':
onlyutf8_sql = ('SELECT TABLE_NAME,TABLE_COLLATION '
'from informati... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def get_revision_sha(cls, dest, rev):
"""
Return (sha_or_none, is_branch), where sha_or_none is a commit hash
if the revision names a remote branch or tag, otherwise None.
Args:
dest: the repository directory.
rev: the revision name.
"""
# Pass rev to... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def db_version(engine, abs_path, init_version):
"""Show the current version of the repository.
:param engine: SQLAlchemy engine instance for a given database
:param abs_path: Absolute path to migrate repository
:param version: Initial database version
"""
repository = _find_migrate_repo(abs_p... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def _should_fetch(cls, dest, rev):
"""
Return true if rev is a ref or is a commit that we don't have locally.
Branches and tags are not considered in this method because they are
assumed to be always available locally (which is a normal outcome of
``git clone`` and ``git fetch -... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def db_version_control(engine, abs_path, version=None):
"""Mark a database as under this repository's version control.
Once a database is under version control, schema changes should
only be done via change scripts in this repository.
:param engine: SQLAlchemy engine instance for a given database
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def resolve_revision(cls, dest, url, rev_options):
# type: (str, HiddenText, RevOptions) -> RevOptions
"""
Resolve a revision to a new RevOptions object with the SHA1 of the
branch, tag, or ref if found.
Args:
rev_options: a RevOptions object.
"""
rev =... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def is_commit_id_equal(cls, dest, name):
"""
Return whether the current commit hash equals the given name.
Args:
dest: the repository directory.
name: a string name.
"""
if not name:
# Then avoid an unnecessary subprocess call.
return ... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def fetch_new(self, dest, url, rev_options):
# type: (str, HiddenText, RevOptions) -> None
rev_display = rev_options.to_display()
logger.info('Cloning %s%s to %s', url, rev_display, display_path(dest))
self.run_command(make_command('clone', '-q', url, dest))
if rev_options.rev:
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def switch(self, dest, url, rev_options):
# type: (str, HiddenText, RevOptions) -> None
self.run_command(
make_command('config', 'remote.origin.url', url),
cwd=dest,
)
cmd_args = make_command('checkout', '-q', rev_options.to_args())
self.run_command(cmd_ar... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def update(self, dest, url, rev_options):
# type: (str, HiddenText, RevOptions) -> None
# First fetch changes from the default remote
if self.get_git_version() >= parse_version('1.9.0'):
# fetch tags in addition to everything else
self.run_command(['fetch', '-q', '--tags'... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def get_remote_url(cls, location):
"""
Return URL of the first remote encountered.
Raises RemoteNotFoundError if the repository does not have a remote
url configured.
"""
# We need to pass 1 for extra_ok_returncodes since the command
# exits with return code 1 if... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def has_commit(cls, location, rev):
"""
Check if rev is a commit that is available in the local repository.
"""
try:
cls.run_command(
['rev-parse', '-q', '--verify', "sha^" + rev],
cwd=location,
log_failed_cmd=False,
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def get_revision(cls, location, rev=None):
if rev is None:
rev = 'HEAD'
current_rev = cls.run_command(
['rev-parse', rev],
show_stdout=False,
stdout_only=True,
cwd=location,
)
return current_rev.strip() |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def get_subdirectory(cls, location):
"""
Return the path to setup.py, relative to the repo root.
Return None if setup.py is in the repo root.
"""
# find the repo root
git_dir = cls.run_command(
['rev-parse', '--git-dir'],
show_stdout=False,
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def get_url_rev_and_auth(cls, url):
# type: (str) -> Tuple[str, Optional[str], AuthInfo]
"""
Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'.
That's required because although they use SSH they sometimes don't
work with a ssh:// scheme (e.g. GitHub). But we nee... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def update_submodules(cls, location):
if not os.path.exists(os.path.join(location, '.gitmodules')):
return
cls.run_command(
['submodule', 'update', '--init', '--recursive', '-q'],
cwd=location,
) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def get_repository_root(cls, location):
loc = super(Git, cls).get_repository_root(location)
if loc:
return loc
try:
r = cls.run_command(
['rev-parse', '--show-toplevel'],
cwd=location,
show_stdout=False,
stdo... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def get_spec(field, limit=10, query='', query_dsl=''):
"""Returns aggregation specs for a term of filtered events.
The aggregation spec will summarize values of an attribute
whose events fall under a filter.
Args:
field (str): this denotes the event attribute that is used
for aggre... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def __call__(self, env, start_response):
return env |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def chart_title(self):
"""Returns a title for the chart."""
if self.field:
return 'Top filtered results for "{0:s}"'.format(self.field)
return 'Top results for an unknown field after filtering' |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def read(self, path):
raise Exception('read called with %r' % path) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def run(
self, field, query_string='', query_dsl='',
supported_charts='table', start_time='', end_time='', limit=10):
"""Run the aggregation.
Args:
field (str): this denotes the event attribute that is used
for aggregation.
query_string (s... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def read(self, path):
return False |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def items(self, section_name):
if section_name != section:
raise NoSectionError(section_name)
return {
'memcache_servers': memcache_servers,
'memcache_serialization_support':
memcache_serialization_support,
'memcache... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def read(self, path):
return True |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def get(self, section, option):
if _section == section:
if option == 'memcache_servers':
if _srvs == 'error':
raise NoOptionError(option, section)
return _srvs
elif option == 'memcache_serialization_support':
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def start_response(*args):
pass |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def setUp(self):
self.app = memcache.MemcacheMiddleware(FakeApp(), {}) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def test_cache_middleware(self):
req = Request.blank('/something', environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertTrue('swift.cache' in resp)
self.assertTrue(isinstance(resp['swift.cache'], MemcacheRing)) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def test_conf_inline_ratelimiting(self):
with mock.patch.object(memcache, 'ConfigParser', get_config_parser()):
app = memcache.MemcacheMiddleware(
FakeApp(),
{'error_suppression_limit': '5',
'error_suppression_interval': '2.5'})
self.assertEqu... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def test_conf_inline_tls(self):
fake_context = mock.Mock()
with mock.patch.object(ssl, 'create_default_context',
return_value=fake_context):
with mock.patch.object(memcache, 'ConfigParser',
get_config_parser()):
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def test_filter_factory(self):
factory = memcache.filter_factory({'max_connections': '3'},
memcache_servers='10.10.10.10:10',
memcache_serialization_support='1')
thefilter = factory('myapp')
self.assertEqual(thef... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def _loadapp(self, proxy_config_path):
"""
Load a proxy from an app.conf to get the memcache_ring
:returns: the memcache_ring of the memcache middleware filter
"""
with mock.patch('swift.proxy.server.Ring'):
app = loadapp(proxy_config_path)
memcache_ring = No... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def test_real_config(self, tempdir):
config = """
[pipeline:main]
pipeline = cache proxy-server
[app:proxy-server]
use = egg:swift#proxy
[filter:cache]
use = egg:swift#memcache
"""
config_path = os.path.join(tempdir, 'test.conf')
with ope... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def test_real_config_with_options(self, tempdir):
config = """
[pipeline:main]
pipeline = cache proxy-server
[app:proxy-server]
use = egg:swift#proxy
[filter:cache]
use = egg:swift#memcache
memcache_servers = 10.0.0.1:11211,10.0.0.2:11211,10.0.0.3:11211,... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def __init__(self):
# Fix some key bindings
self.bind("<Control-Key-a>", self.select_all)
# We will need Ctrl-/ for the "stroke", but it cannot be unbound, so
# let's prevent it from being passed to the standard handler
self.bind("<Control-Key-/>", lambda event: "break")
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def call_vision_api(image_filename, api_keys):
api_key = api_keys['microsoft']
post_url = "https://api.projectoxford.ai/vision/v1.0/analyze?visualFeatures=Categories,Tags,Description,Faces,ImageType,Color,Adult&subscription-key=" + api_key
image_data = open(image_filename, 'rb').read()
result = request... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def insert_accented(self, c, accent):
if c.isalpha():
if c.isupper():
cap = 'capital'
else:
cap = 'small'
try:
c = lookup("latin %s letter %c with %s" % (cap, c, accent))
self.insert(INSERT, c)
# ... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def get_standardized_result(api_result):
output = {
'tags' : [],
'captions' : [], |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def __init__(self, master=None, **kwargs):
Entry.__init__(self, master=None, **kwargs)
Diacritical.__init__(self) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def select_all(self, event=None):
self.selection_range(0, END)
return "break" |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def __init__(self, master=None, **kwargs):
ScrolledText.__init__(self, master=None, **kwargs)
Diacritical.__init__(self) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def select_all(self, event=None):
self.tag_add(SEL, "1.0", "end-1c")
self.mark_set(INSERT, "1.0")
self.see(INSERT)
return "break" |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def test():
frame = Frame()
frame.pack(fill=BOTH, expand=YES)
if os.name == "nt":
# Set default font for all widgets; use Windows typical default
frame.option_add("*font", "Tahoma 8")
# The editors
entry = DiacriticalEntry(frame)
entry.pack(fill=BOTH, expand=YES)
text = Diacr... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def loaded(cls):
return 'cudf' in sys.modules |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def applies(cls, obj):
if not cls.loaded():
return False
import cudf
return isinstance(obj, (cudf.DataFrame, cudf.Series)) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def init(cls, eltype, data, kdims, vdims):
import cudf
import pandas as pd
element_params = eltype.param.objects()
kdim_param = element_params['kdims']
vdim_param = element_params['vdims']
if isinstance(data, (cudf.Series, pd.Series)):
data = data.to_frame()... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def range(cls, dataset, dimension):
dimension = dataset.get_dimension(dimension, strict=True)
column = dataset.data[dimension.name]
if dimension.nodata is not None:
column = cls.replace_value(column, dimension.nodata)
if column.dtype.kind == 'O':
return np.NaN, np... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def values(cls, dataset, dim, expanded=True, flat=True, compute=True,
keep_index=False):
dim = dataset.get_dimension(dim, strict=True)
data = dataset.data[dim.name]
if not expanded:
data = data.unique()
return data.values_host if compute else data.values
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def groupby(cls, dataset, dimensions, container_type, group_type, **kwargs):
# Get dimensions information
dimensions = [dataset.get_dimension(d).name for d in dimensions]
kdims = [kdim for kdim in dataset.kdims if kdim not in dimensions]
# Update the kwargs appropriately for Element gro... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def select_mask(cls, dataset, selection):
"""
Given a Dataset object and a dictionary with dimension keys and
selection keys (i.e. tuple ranges, slices, sets, lists, or literals)
return a boolean mask over the rows in the Dataset object that
have been selected.
"""
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def select(cls, dataset, selection_mask=None, **selection):
df = dataset.data
if selection_mask is None:
selection_mask = cls.select_mask(dataset, selection)
indexed = cls.indexed(dataset, selection)
if selection_mask is not None:
df = df.loc[selection_mask]
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def concat_fn(cls, dataframes, **kwargs):
import cudf
return cudf.concat(dataframes, **kwargs) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def add_dimension(cls, dataset, dimension, dim_pos, values, vdim):
data = dataset.data.copy()
if dimension.name not in data:
data[dimension.name] = values
return data |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def aggregate(cls, dataset, dimensions, function, **kwargs):
data = dataset.data
cols = [d.name for d in dataset.kdims if d in dimensions]
vdims = dataset.dimensions('value', label='name')
reindexed = data[cols+vdims]
agg = function.__name__
if len(dimensions):
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def iloc(cls, dataset, index):
import cudf
rows, cols = index
scalar = False
columns = list(dataset.data.columns)
if isinstance(cols, slice):
cols = [d.name for d in dataset.dimensions()][cols]
elif np.isscalar(cols):
scalar = np.isscalar(rows)
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def sort(cls, dataset, by=[], reverse=False):
cols = [dataset.get_dimension(d, strict=True).name for d in by]
return dataset.data.sort_values(by=cols, ascending=not reverse) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def dframe(cls, dataset, dimensions):
if dimensions:
return dataset.data[dimensions].to_pandas()
else:
return dataset.data.to_pandas() |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def __init__(self, key):
self.key = key
self.prio = random.randint(0, 1000000000)
self.size = 1
self.left = None
self.right = None |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def GetCompletions_Basic_test( app ):
filepath = PathToTestFile( 'basic.py' )
completion_data = BuildRequest( filepath = filepath,
filetype = 'python',
contents = ReadFile( filepath ),
line_num = 7,
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def update(self):
self.size = 1 + size(self.left) + size(self.right) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def GetCompletions_UnicodeDescription_test( app ):
filepath = PathToTestFile( 'unicode.py' )
completion_data = BuildRequest( filepath = filepath,
filetype = 'python',
contents = ReadFile( filepath ),
force_semantic... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def size(treap):
return 0 if treap is None else treap.size |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def CombineRequest( request, data ):
kw = request
request.update( data )
return BuildRequest( **kw ) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def split(root, minRight):
if root is None:
return None, None
if root.key >= minRight:
left, right = split(root.left, minRight)
root.left = right
root.update()
return left, root
else:
left, right = split(root.right, minRight)
root.right = left
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def GetCompletions_NoSuggestions_Fallback_test( app ):
# Python completer doesn't raise NO_COMPLETIONS_MESSAGE, so this is a
# different code path to the Clang completer cases
# TESTCASE2 (general_fallback/lang_python.py)
RunTest( app, {
'description': 'param jedi does not know about (id). query="a_p"',
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def merge(left, right):
if left is None:
return right
if right is None:
return left
if left.prio > right.prio:
left.right = merge(left.right, right)
left.update()
return left
else:
right.left = merge(left, right.left)
right.update()
return ... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def insert(root, key):
left, right = split(root, key)
return merge(merge(left, Treap(key)), right) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def remove(root, key):
left, right = split(root, key)
return merge(left, split(right, key + 1)[1]) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def kth(root, k):
if k < size(root.left):
return kth(root.left, k)
elif k > size(root.left):
return kth(root.right, k - size(root.left) - 1)
return root.key |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def dfs_print(root):
if root is None:
return
dfs_print(root.left)
print(str(root.key) + ' ', end='')
dfs_print(root.right) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def test():
start = time.time()
treap = None
s = set()
for i in range(100000):
key = random.randint(0, 10000)
if random.randint(0, 1) == 0:
if key in s:
treap = remove(treap, key)
s.remove(key)
elif key not in s:
treap = ins... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def __init__(self, region, name, retention_in_days=7):
super(LogGroup, self).__init__()
self.region = region
self.name = name
self.retention_in_days = retention_in_days |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def _Create(self):
"""Create the log group."""
create_cmd = util.AWS_PREFIX + [
'--region', self.region,
'logs', 'create-log-group',
'--log-group-name', self.name
]
vm_util.IssueCommand(create_cmd) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def _Delete(self):
"""Delete the log group."""
delete_cmd = util.AWS_PREFIX + [
'--region', self.region,
'logs', 'delete-log-group',
'--log-group-name', self.name
]
vm_util.IssueCommand(delete_cmd, raise_on_failure=False) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def Exists(self):
"""Returns True if the log group exists."""
describe_cmd = util.AWS_PREFIX + [
'--region', self.region,
'logs', 'describe-log-groups',
'--log-group-name-prefix', self.name,
'--no-paginate'
]
stdout, _, _ = vm_util.IssueCommand(describe_cmd)
log_group... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def _PostCreate(self):
"""Set the retention policy."""
put_cmd = util.AWS_PREFIX + [
'--region', self.region,
'logs', 'put-retention-policy',
'--log-group-name', self.name,
'--retention-in-days', str(self.retention_in_days)
]
vm_util.IssueCommand(put_cmd) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def GetLogs(region, stream_name, group_name, token=None):
"""Fetches the JSON formatted log stream starting at the token."""
get_cmd = util.AWS_PREFIX + [
'--region', region,
'logs', 'get-log-events',
'--start-from-head',
'--log-group-name', group_name,
'--log-stream-name', stream_name... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def begin(self):
self.append({'cbs': [], 'dirty': False}) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def check_fresh_login():
"""Checks if the login is fresh for the current user, otherwise the user
has to reauthenticate."""
if not login_fresh():
return current_app.login_manager.needs_refresh() |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def commit(self):
context = self.pop()
if self:
# savepoint
self[-1]['cbs'].extend(context['cbs'])
self[-1]['dirty'] = self[-1]['dirty'] or context['dirty']
else:
# transaction
for func, args, kwargs in context['cbs']:
f... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def overview():
# user and group stats
banned_users = User.query.filter(
Group.banned == True,
Group.id == User.primary_group_id
).count()
if not current_app.config["REDIS_ENABLED"]:
online_users = User.query.filter(User.lastseen >= time_diff()).count()
else:
online_u... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def rollback(self):
self.pop() |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def settings(slug=None):
slug = slug if slug else "general"
# get the currently active group
active_group = SettingsGroup.query.filter_by(key=slug).first_or_404()
# get all groups - used to build the navigation
all_groups = SettingsGroup.query.all()
SettingsForm = Setting.get_form(active_group... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def push(self, item):
self[-1]['cbs'].append(item) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def users():
page = request.args.get("page", 1, type=int)
search_form = UserSearchForm()
if search_form.validate():
users = search_form.get_results().\
paginate(page, flaskbb_config['USERS_PER_PAGE'], False)
return render_template("management/users.html", users=users,
... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def mark_dirty(self):
self[-1]['dirty'] = True |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def edit_user(user_id):
user = User.query.filter_by(id=user_id).first_or_404()
if not Permission(CanEditUser, identity=current_user):
flash(_("You are not allowed to edit this user."), "danger")
return redirect(url_for("management.users"))
member_group = db.and_(*[db.not_(getattr(Group, p)... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def is_dirty(self):
return any(context['dirty'] for context in self) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def delete_user(user_id=None):
# ajax request
if request.is_xhr:
ids = request.get_json()["ids"]
data = []
for user in User.query.filter(User.id.in_(ids)).all():
# do not delete current user
if current_user.id == user.id:
continue
if ... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def __init__(self):
super(TransactionStates, self).__init__()
self._states = defaultdict(TransactionState) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def add_user():
form = AddUserForm()
if form.validate_on_submit():
form.save()
flash(_("User added."), "success")
return redirect(url_for("management.users"))
return render_template("management/user_form.html", form=form,
title=_("Add User")) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def __getitem__(self, key):
return self._states[key or DEFAULT_DB_ALIAS] |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def banned_users():
page = request.args.get("page", 1, type=int)
search_form = UserSearchForm()
users = User.query.filter(
Group.banned == True,
Group.id == User.primary_group_id
).paginate(page, flaskbb_config['USERS_PER_PAGE'], False)
if search_form.validate():
users = se... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def is_dirty(self, dbs):
return any(self[db].is_dirty() for db in dbs) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def ban_user(user_id=None):
if not Permission(CanBanUser, identity=current_user):
flash(_("You do not have the permissions to ban this user."), "danger")
return redirect(url_for("management.overview"))
# ajax request
if request.is_xhr:
ids = request.get_json()["ids"]
data =... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def queue_when_in_transaction(call):
if transaction_states[call.using]:
transaction_states[call.using].push((call, (), {}))
else:
return call() |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def unban_user(user_id=None):
if not Permission(CanBanUser, identity=current_user):
flash(_("You do not have the permissions to unban this user."),
"danger")
return redirect(url_for("management.overview"))
# ajax request
if request.is_xhr:
ids = request.get_json()["ids... |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def __enter__(self):
entering = not transaction_states[self.using]
transaction_states[self.using].begin()
self._no_monkey.__enter__(self)
if entering:
on_commit(transaction_states[self.using].commit, self.using) |
def getall(self):
try:
spec = {'data': {'$exists': 1}}
fields = {'_id': 0}
sort = [('tid', 1)]
cur = self.db.docs.find(spec, fields, sort=sort)
except Exception as e:
raise DatabaseException(e)
return [Document(**row) for row in cur] | def reports():
page = request.args.get("page", 1, type=int)
reports = Report.query.\
order_by(Report.id.asc()).\
paginate(page, flaskbb_config['USERS_PER_PAGE'], False)
return render_template("management/reports.html", reports=reports) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.