partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | missingkeys_nonstandard | This is an object list where thre is no first field name
to give a hint of what the first field name should be | eppy/iddgaps.py | def missingkeys_nonstandard(block, commdct, dtls, objectlist, afield='afiled %s'):
"""This is an object list where thre is no first field name
to give a hint of what the first field name should be"""
afield = 'afield %s'
for key_txt in objectlist:
key_i = dtls.index(key_txt.upper())
comm... | def missingkeys_nonstandard(block, commdct, dtls, objectlist, afield='afiled %s'):
"""This is an object list where thre is no first field name
to give a hint of what the first field name should be"""
afield = 'afield %s'
for key_txt in objectlist:
key_i = dtls.index(key_txt.upper())
comm... | [
"This",
"is",
"an",
"object",
"list",
"where",
"thre",
"is",
"no",
"first",
"field",
"name",
"to",
"give",
"a",
"hint",
"of",
"what",
"the",
"first",
"field",
"name",
"should",
"be"
] | santoshphilip/eppy | python | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/iddgaps.py#L152-L170 | [
"def",
"missingkeys_nonstandard",
"(",
"block",
",",
"commdct",
",",
"dtls",
",",
"objectlist",
",",
"afield",
"=",
"'afiled %s'",
")",
":",
"afield",
"=",
"'afield %s'",
"for",
"key_txt",
"in",
"objectlist",
":",
"key_i",
"=",
"dtls",
".",
"index",
"(",
"... | 55410ff7c11722f35bc4331ff5e00a0b86f787e1 |
train | get_event_loop | Return a EventLoop instance.
A new instance is created for each new HTTP request. We determine
that we're in a new request by inspecting os.environ, which is reset
at the start of each request. Also, each thread gets its own loop. | ndb/eventloop.py | def get_event_loop():
"""Return a EventLoop instance.
A new instance is created for each new HTTP request. We determine
that we're in a new request by inspecting os.environ, which is reset
at the start of each request. Also, each thread gets its own loop.
"""
ev = _state.event_loop
if not os.getenv(_EV... | def get_event_loop():
"""Return a EventLoop instance.
A new instance is created for each new HTTP request. We determine
that we're in a new request by inspecting os.environ, which is reset
at the start of each request. Also, each thread gets its own loop.
"""
ev = _state.event_loop
if not os.getenv(_EV... | [
"Return",
"a",
"EventLoop",
"instance",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L293-L309 | [
"def",
"get_event_loop",
"(",
")",
":",
"ev",
"=",
"_state",
".",
"event_loop",
"if",
"not",
"os",
".",
"getenv",
"(",
"_EVENT_LOOP_KEY",
")",
"and",
"ev",
"is",
"not",
"None",
":",
"ev",
".",
"clear",
"(",
")",
"_state",
".",
"event_loop",
"=",
"Non... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | EventLoop.clear | Remove all pending events without running any. | ndb/eventloop.py | def clear(self):
"""Remove all pending events without running any."""
while self.current or self.idlers or self.queue or self.rpcs:
current = self.current
idlers = self.idlers
queue = self.queue
rpcs = self.rpcs
_logging_debug('Clearing stale EventLoop instance...')
if curren... | def clear(self):
"""Remove all pending events without running any."""
while self.current or self.idlers or self.queue or self.rpcs:
current = self.current
idlers = self.idlers
queue = self.queue
rpcs = self.rpcs
_logging_debug('Clearing stale EventLoop instance...')
if curren... | [
"Remove",
"all",
"pending",
"events",
"without",
"running",
"any",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L90-L111 | [
"def",
"clear",
"(",
"self",
")",
":",
"while",
"self",
".",
"current",
"or",
"self",
".",
"idlers",
"or",
"self",
".",
"queue",
"or",
"self",
".",
"rpcs",
":",
"current",
"=",
"self",
".",
"current",
"idlers",
"=",
"self",
".",
"idlers",
"queue",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | EventLoop.insort_event_right | Insert event in queue, and keep it sorted assuming queue is sorted.
If event is already in queue, insert it to the right of the rightmost
event (to keep FIFO order).
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.
Args:
event: a (time in sec since u... | ndb/eventloop.py | def insort_event_right(self, event, lo=0, hi=None):
"""Insert event in queue, and keep it sorted assuming queue is sorted.
If event is already in queue, insert it to the right of the rightmost
event (to keep FIFO order).
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to ... | def insort_event_right(self, event, lo=0, hi=None):
"""Insert event in queue, and keep it sorted assuming queue is sorted.
If event is already in queue, insert it to the right of the rightmost
event (to keep FIFO order).
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to ... | [
"Insert",
"event",
"in",
"queue",
"and",
"keep",
"it",
"sorted",
"assuming",
"queue",
"is",
"sorted",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L113-L136 | [
"def",
"insort_event_right",
"(",
"self",
",",
"event",
",",
"lo",
"=",
"0",
",",
"hi",
"=",
"None",
")",
":",
"if",
"lo",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'lo must be non-negative'",
")",
"if",
"hi",
"is",
"None",
":",
"hi",
"=",
"len",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | EventLoop.queue_call | Schedule a function call at a specific time in the future. | ndb/eventloop.py | def queue_call(self, delay, callback, *args, **kwds):
"""Schedule a function call at a specific time in the future."""
if delay is None:
self.current.append((callback, args, kwds))
return
if delay < 1e9:
when = delay + self.clock.now()
else:
# Times over a billion seconds are ass... | def queue_call(self, delay, callback, *args, **kwds):
"""Schedule a function call at a specific time in the future."""
if delay is None:
self.current.append((callback, args, kwds))
return
if delay < 1e9:
when = delay + self.clock.now()
else:
# Times over a billion seconds are ass... | [
"Schedule",
"a",
"function",
"call",
"at",
"a",
"specific",
"time",
"in",
"the",
"future",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L138-L148 | [
"def",
"queue_call",
"(",
"self",
",",
"delay",
",",
"callback",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"if",
"delay",
"is",
"None",
":",
"self",
".",
"current",
".",
"append",
"(",
"(",
"callback",
",",
"args",
",",
"kwds",
")",
")",... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | EventLoop.queue_rpc | Schedule an RPC with an optional callback.
The caller must have previously sent the call to the service.
The optional callback is called with the remaining arguments.
NOTE: If the rpc is a MultiRpc, the callback will be called once
for each sub-RPC. TODO: Is this a good idea? | ndb/eventloop.py | def queue_rpc(self, rpc, callback=None, *args, **kwds):
"""Schedule an RPC with an optional callback.
The caller must have previously sent the call to the service.
The optional callback is called with the remaining arguments.
NOTE: If the rpc is a MultiRpc, the callback will be called once
for eac... | def queue_rpc(self, rpc, callback=None, *args, **kwds):
"""Schedule an RPC with an optional callback.
The caller must have previously sent the call to the service.
The optional callback is called with the remaining arguments.
NOTE: If the rpc is a MultiRpc, the callback will be called once
for eac... | [
"Schedule",
"an",
"RPC",
"with",
"an",
"optional",
"callback",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L150-L180 | [
"def",
"queue_rpc",
"(",
"self",
",",
"rpc",
",",
"callback",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"if",
"rpc",
"is",
"None",
":",
"return",
"if",
"rpc",
".",
"state",
"not",
"in",
"(",
"_RUNNING",
",",
"_FINISHING",
")... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | EventLoop.add_idle | Add an idle callback.
An idle callback can return True, False or None. These mean:
- None: remove the callback (don't reschedule)
- False: the callback did no work; reschedule later
- True: the callback did some work; reschedule soon
If the callback raises an exception, the traceback is logged a... | ndb/eventloop.py | def add_idle(self, callback, *args, **kwds):
"""Add an idle callback.
An idle callback can return True, False or None. These mean:
- None: remove the callback (don't reschedule)
- False: the callback did no work; reschedule later
- True: the callback did some work; reschedule soon
If the cal... | def add_idle(self, callback, *args, **kwds):
"""Add an idle callback.
An idle callback can return True, False or None. These mean:
- None: remove the callback (don't reschedule)
- False: the callback did no work; reschedule later
- True: the callback did some work; reschedule soon
If the cal... | [
"Add",
"an",
"idle",
"callback",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L182-L194 | [
"def",
"add_idle",
"(",
"self",
",",
"callback",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"self",
".",
"idlers",
".",
"append",
"(",
"(",
"callback",
",",
"args",
",",
"kwds",
")",
")"
] | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | EventLoop.run_idle | Run one of the idle callbacks.
Returns:
True if one was called, False if no idle callback was called. | ndb/eventloop.py | def run_idle(self):
"""Run one of the idle callbacks.
Returns:
True if one was called, False if no idle callback was called.
"""
if not self.idlers or self.inactive >= len(self.idlers):
return False
idler = self.idlers.popleft()
callback, args, kwds = idler
_logging_debug('idler... | def run_idle(self):
"""Run one of the idle callbacks.
Returns:
True if one was called, False if no idle callback was called.
"""
if not self.idlers or self.inactive >= len(self.idlers):
return False
idler = self.idlers.popleft()
callback, args, kwds = idler
_logging_debug('idler... | [
"Run",
"one",
"of",
"the",
"idle",
"callbacks",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L196-L217 | [
"def",
"run_idle",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"idlers",
"or",
"self",
".",
"inactive",
">=",
"len",
"(",
"self",
".",
"idlers",
")",
":",
"return",
"False",
"idler",
"=",
"self",
".",
"idlers",
".",
"popleft",
"(",
")",
"callb... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | EventLoop.run0 | Run one item (a callback or an RPC wait_any).
Returns:
A time to sleep if something happened (may be 0);
None if all queues are empty. | ndb/eventloop.py | def run0(self):
"""Run one item (a callback or an RPC wait_any).
Returns:
A time to sleep if something happened (may be 0);
None if all queues are empty.
"""
if self.current:
self.inactive = 0
callback, args, kwds = self.current.popleft()
_logging_debug('nowevent: %s', cal... | def run0(self):
"""Run one item (a callback or an RPC wait_any).
Returns:
A time to sleep if something happened (may be 0);
None if all queues are empty.
"""
if self.current:
self.inactive = 0
callback, args, kwds = self.current.popleft()
_logging_debug('nowevent: %s', cal... | [
"Run",
"one",
"item",
"(",
"a",
"callback",
"or",
"an",
"RPC",
"wait_any",
")",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L219-L260 | [
"def",
"run0",
"(",
"self",
")",
":",
"if",
"self",
".",
"current",
":",
"self",
".",
"inactive",
"=",
"0",
"callback",
",",
"args",
",",
"kwds",
"=",
"self",
".",
"current",
".",
"popleft",
"(",
")",
"_logging_debug",
"(",
"'nowevent: %s'",
",",
"ca... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | EventLoop.run1 | Run one item (a callback or an RPC wait_any) or sleep.
Returns:
True if something happened; False if all queues are empty. | ndb/eventloop.py | def run1(self):
"""Run one item (a callback or an RPC wait_any) or sleep.
Returns:
True if something happened; False if all queues are empty.
"""
delay = self.run0()
if delay is None:
return False
if delay > 0:
self.clock.sleep(delay)
return True | def run1(self):
"""Run one item (a callback or an RPC wait_any) or sleep.
Returns:
True if something happened; False if all queues are empty.
"""
delay = self.run0()
if delay is None:
return False
if delay > 0:
self.clock.sleep(delay)
return True | [
"Run",
"one",
"item",
"(",
"a",
"callback",
"or",
"an",
"RPC",
"wait_any",
")",
"or",
"sleep",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/eventloop.py#L262-L273 | [
"def",
"run1",
"(",
"self",
")",
":",
"delay",
"=",
"self",
".",
"run0",
"(",
")",
"if",
"delay",
"is",
"None",
":",
"return",
"False",
"if",
"delay",
">",
"0",
":",
"self",
".",
"clock",
".",
"sleep",
"(",
"delay",
")",
"return",
"True"
] | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | _args_to_val | Helper for GQL parsing to extract values from GQL expressions.
This can extract the value from a GQL literal, return a Parameter
for a GQL bound parameter (:1 or :foo), and interprets casts like
KEY(...) and plain lists of values like (1, 2, 3).
Args:
func: A string indicating what kind of thing this is.
... | ndb/query.py | def _args_to_val(func, args):
"""Helper for GQL parsing to extract values from GQL expressions.
This can extract the value from a GQL literal, return a Parameter
for a GQL bound parameter (:1 or :foo), and interprets casts like
KEY(...) and plain lists of values like (1, 2, 3).
Args:
func: A string indi... | def _args_to_val(func, args):
"""Helper for GQL parsing to extract values from GQL expressions.
This can extract the value from a GQL literal, return a Parameter
for a GQL bound parameter (:1 or :foo), and interprets casts like
KEY(...) and plain lists of values like (1, 2, 3).
Args:
func: A string indi... | [
"Helper",
"for",
"GQL",
"parsing",
"to",
"extract",
"values",
"from",
"GQL",
"expressions",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L700-L729 | [
"def",
"_args_to_val",
"(",
"func",
",",
"args",
")",
":",
"from",
".",
"google_imports",
"import",
"gql",
"# Late import, to avoid name conflict.",
"vals",
"=",
"[",
"]",
"for",
"arg",
"in",
"args",
":",
"if",
"isinstance",
"(",
"arg",
",",
"(",
"int",
",... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | _get_prop_from_modelclass | Helper for FQL parsing to turn a property name into a property object.
Args:
modelclass: The model class specified in the query.
name: The property name. This may contain dots which indicate
sub-properties of structured properties.
Returns:
A Property object.
Raises:
KeyError if the prop... | ndb/query.py | def _get_prop_from_modelclass(modelclass, name):
"""Helper for FQL parsing to turn a property name into a property object.
Args:
modelclass: The model class specified in the query.
name: The property name. This may contain dots which indicate
sub-properties of structured properties.
Returns:
... | def _get_prop_from_modelclass(modelclass, name):
"""Helper for FQL parsing to turn a property name into a property object.
Args:
modelclass: The model class specified in the query.
name: The property name. This may contain dots which indicate
sub-properties of structured properties.
Returns:
... | [
"Helper",
"for",
"FQL",
"parsing",
"to",
"turn",
"a",
"property",
"name",
"into",
"a",
"property",
"object",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L732-L782 | [
"def",
"_get_prop_from_modelclass",
"(",
"modelclass",
",",
"name",
")",
":",
"if",
"name",
"==",
"'__key__'",
":",
"return",
"modelclass",
".",
"_key",
"parts",
"=",
"name",
".",
"split",
"(",
"'.'",
")",
"part",
",",
"more",
"=",
"parts",
"[",
"0",
"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | gql | Parse a GQL query string.
Args:
query_string: Full GQL query, e.g. 'SELECT * FROM Kind WHERE prop = 1'.
*args, **kwds: If present, used to call bind().
Returns:
An instance of query_class. | ndb/query.py | def gql(query_string, *args, **kwds):
"""Parse a GQL query string.
Args:
query_string: Full GQL query, e.g. 'SELECT * FROM Kind WHERE prop = 1'.
*args, **kwds: If present, used to call bind().
Returns:
An instance of query_class.
"""
qry = _gql(query_string)
if args or kwds:
qry = qry._bin... | def gql(query_string, *args, **kwds):
"""Parse a GQL query string.
Args:
query_string: Full GQL query, e.g. 'SELECT * FROM Kind WHERE prop = 1'.
*args, **kwds: If present, used to call bind().
Returns:
An instance of query_class.
"""
qry = _gql(query_string)
if args or kwds:
qry = qry._bin... | [
"Parse",
"a",
"GQL",
"query",
"string",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1501-L1514 | [
"def",
"gql",
"(",
"query_string",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"qry",
"=",
"_gql",
"(",
"query_string",
")",
"if",
"args",
"or",
"kwds",
":",
"qry",
"=",
"qry",
".",
"_bind",
"(",
"args",
",",
"kwds",
")",
"return",
"qry"
] | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | _gql | Parse a GQL query string (internal version).
Args:
query_string: Full GQL query, e.g. 'SELECT * FROM Kind WHERE prop = 1'.
query_class: Optional class to use, default Query.
Returns:
An instance of query_class. | ndb/query.py | def _gql(query_string, query_class=Query):
"""Parse a GQL query string (internal version).
Args:
query_string: Full GQL query, e.g. 'SELECT * FROM Kind WHERE prop = 1'.
query_class: Optional class to use, default Query.
Returns:
An instance of query_class.
"""
from .google_imports import gql # ... | def _gql(query_string, query_class=Query):
"""Parse a GQL query string (internal version).
Args:
query_string: Full GQL query, e.g. 'SELECT * FROM Kind WHERE prop = 1'.
query_class: Optional class to use, default Query.
Returns:
An instance of query_class.
"""
from .google_imports import gql # ... | [
"Parse",
"a",
"GQL",
"query",
"string",
"(",
"internal",
"version",
")",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1518-L1596 | [
"def",
"_gql",
"(",
"query_string",
",",
"query_class",
"=",
"Query",
")",
":",
"from",
".",
"google_imports",
"import",
"gql",
"# Late import, to avoid name conflict.",
"gql_qry",
"=",
"gql",
".",
"GQL",
"(",
"query_string",
")",
"kind",
"=",
"gql_qry",
".",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | RepeatedStructuredPropertyPredicate._apply | Apply the filter to values extracted from an entity.
Think of self.match_keys and self.match_values as representing a
table with one row. For example:
match_keys = ('name', 'age', 'rank')
match_values = ('Joe', 24, 5)
(Except that in reality, the values are represented by tuples
produced... | ndb/query.py | def _apply(self, key_value_map):
"""Apply the filter to values extracted from an entity.
Think of self.match_keys and self.match_values as representing a
table with one row. For example:
match_keys = ('name', 'age', 'rank')
match_values = ('Joe', 24, 5)
(Except that in reality, the value... | def _apply(self, key_value_map):
"""Apply the filter to values extracted from an entity.
Think of self.match_keys and self.match_values as representing a
table with one row. For example:
match_keys = ('name', 'age', 'rank')
match_values = ('Joe', 24, 5)
(Except that in reality, the value... | [
"Apply",
"the",
"filter",
"to",
"values",
"extracted",
"from",
"an",
"entity",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L208-L257 | [
"def",
"_apply",
"(",
"self",
",",
"key_value_map",
")",
":",
"columns",
"=",
"[",
"]",
"for",
"key",
"in",
"self",
".",
"match_keys",
":",
"column",
"=",
"key_value_map",
".",
"get",
"(",
"key",
")",
"if",
"not",
"column",
":",
"# None, or an empty list... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query._fix_namespace | Internal helper to fix the namespace.
This is called to ensure that for queries without an explicit
namespace, the namespace used by async calls is the one in effect
at the time the async call is made, not the one in effect when the
the request is actually generated. | ndb/query.py | def _fix_namespace(self):
"""Internal helper to fix the namespace.
This is called to ensure that for queries without an explicit
namespace, the namespace used by async calls is the one in effect
at the time the async call is made, not the one in effect when the
the request is actually generated.
... | def _fix_namespace(self):
"""Internal helper to fix the namespace.
This is called to ensure that for queries without an explicit
namespace, the namespace used by async calls is the one in effect
at the time the async call is made, not the one in effect when the
the request is actually generated.
... | [
"Internal",
"helper",
"to",
"fix",
"the",
"namespace",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L912-L927 | [
"def",
"_fix_namespace",
"(",
"self",
")",
":",
"if",
"self",
".",
"namespace",
"is",
"not",
"None",
":",
"return",
"self",
"namespace",
"=",
"namespace_manager",
".",
"get_namespace",
"(",
")",
"return",
"self",
".",
"__class__",
"(",
"kind",
"=",
"self",... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query.run_to_queue | Run this query, putting entities into the given queue. | ndb/query.py | def run_to_queue(self, queue, conn, options=None, dsquery=None):
"""Run this query, putting entities into the given queue."""
try:
multiquery = self._maybe_multi_query()
if multiquery is not None:
yield multiquery.run_to_queue(queue, conn, options=options)
return
if dsquery is... | def run_to_queue(self, queue, conn, options=None, dsquery=None):
"""Run this query, putting entities into the given queue."""
try:
multiquery = self._maybe_multi_query()
if multiquery is not None:
yield multiquery.run_to_queue(queue, conn, options=options)
return
if dsquery is... | [
"Run",
"this",
"query",
"putting",
"entities",
"into",
"the",
"given",
"queue",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L957-L985 | [
"def",
"run_to_queue",
"(",
"self",
",",
"queue",
",",
"conn",
",",
"options",
"=",
"None",
",",
"dsquery",
"=",
"None",
")",
":",
"try",
":",
"multiquery",
"=",
"self",
".",
"_maybe_multi_query",
"(",
")",
"if",
"multiquery",
"is",
"not",
"None",
":",... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query.is_distinct | True if results are guaranteed to contain a unique set of property
values.
This happens when every property in the group_by is also in the projection. | ndb/query.py | def is_distinct(self):
"""True if results are guaranteed to contain a unique set of property
values.
This happens when every property in the group_by is also in the projection.
"""
return bool(self.__group_by and
set(self._to_property_names(self.__group_by)) <=
set(s... | def is_distinct(self):
"""True if results are guaranteed to contain a unique set of property
values.
This happens when every property in the group_by is also in the projection.
"""
return bool(self.__group_by and
set(self._to_property_names(self.__group_by)) <=
set(s... | [
"True",
"if",
"results",
"are",
"guaranteed",
"to",
"contain",
"a",
"unique",
"set",
"of",
"property",
"values",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1074-L1082 | [
"def",
"is_distinct",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"__group_by",
"and",
"set",
"(",
"self",
".",
"_to_property_names",
"(",
"self",
".",
"__group_by",
")",
")",
"<=",
"set",
"(",
"self",
".",
"_to_property_names",
"(",
"self... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query.filter | Return a new Query with additional filter(s) applied. | ndb/query.py | def filter(self, *args):
"""Return a new Query with additional filter(s) applied."""
if not args:
return self
preds = []
f = self.filters
if f:
preds.append(f)
for arg in args:
if not isinstance(arg, Node):
raise TypeError('Cannot filter a non-Node argument; received %r... | def filter(self, *args):
"""Return a new Query with additional filter(s) applied."""
if not args:
return self
preds = []
f = self.filters
if f:
preds.append(f)
for arg in args:
if not isinstance(arg, Node):
raise TypeError('Cannot filter a non-Node argument; received %r... | [
"Return",
"a",
"new",
"Query",
"with",
"additional",
"filter",
"(",
"s",
")",
"applied",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1084-L1106 | [
"def",
"filter",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"not",
"args",
":",
"return",
"self",
"preds",
"=",
"[",
"]",
"f",
"=",
"self",
".",
"filters",
"if",
"f",
":",
"preds",
".",
"append",
"(",
"f",
")",
"for",
"arg",
"in",
"args",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query.order | Return a new Query with additional sort order(s) applied. | ndb/query.py | def order(self, *args):
"""Return a new Query with additional sort order(s) applied."""
# q.order(Employee.name, -Employee.age)
if not args:
return self
orders = []
o = self.orders
if o:
orders.append(o)
for arg in args:
if isinstance(arg, model.Property):
orders.ap... | def order(self, *args):
"""Return a new Query with additional sort order(s) applied."""
# q.order(Employee.name, -Employee.age)
if not args:
return self
orders = []
o = self.orders
if o:
orders.append(o)
for arg in args:
if isinstance(arg, model.Property):
orders.ap... | [
"Return",
"a",
"new",
"Query",
"with",
"additional",
"sort",
"order",
"(",
"s",
")",
"applied",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1108-L1135 | [
"def",
"order",
"(",
"self",
",",
"*",
"args",
")",
":",
"# q.order(Employee.name, -Employee.age)",
"if",
"not",
"args",
":",
"return",
"self",
"orders",
"=",
"[",
"]",
"o",
"=",
"self",
".",
"orders",
"if",
"o",
":",
"orders",
".",
"append",
"(",
"o",... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query.map | Map a callback function or tasklet over the query results.
Args:
callback: A function or tasklet to be applied to each result; see below.
merge_future: Optional Future subclass; see below.
**q_options: All query options keyword arguments are supported.
Callback signature: The callback is nor... | ndb/query.py | def map(self, callback, pass_batch_into_callback=None,
merge_future=None, **q_options):
"""Map a callback function or tasklet over the query results.
Args:
callback: A function or tasklet to be applied to each result; see below.
merge_future: Optional Future subclass; see below.
**q... | def map(self, callback, pass_batch_into_callback=None,
merge_future=None, **q_options):
"""Map a callback function or tasklet over the query results.
Args:
callback: A function or tasklet to be applied to each result; see below.
merge_future: Optional Future subclass; see below.
**q... | [
"Map",
"a",
"callback",
"function",
"or",
"tasklet",
"over",
"the",
"query",
"results",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1154-L1190 | [
"def",
"map",
"(",
"self",
",",
"callback",
",",
"pass_batch_into_callback",
"=",
"None",
",",
"merge_future",
"=",
"None",
",",
"*",
"*",
"q_options",
")",
":",
"return",
"self",
".",
"map_async",
"(",
"callback",
",",
"pass_batch_into_callback",
"=",
"pass... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query.map_async | Map a callback function or tasklet over the query results.
This is the asynchronous version of Query.map(). | ndb/query.py | def map_async(self, callback, pass_batch_into_callback=None,
merge_future=None, **q_options):
"""Map a callback function or tasklet over the query results.
This is the asynchronous version of Query.map().
"""
qry = self._fix_namespace()
return tasklets.get_context().map_query(
... | def map_async(self, callback, pass_batch_into_callback=None,
merge_future=None, **q_options):
"""Map a callback function or tasklet over the query results.
This is the asynchronous version of Query.map().
"""
qry = self._fix_namespace()
return tasklets.get_context().map_query(
... | [
"Map",
"a",
"callback",
"function",
"or",
"tasklet",
"over",
"the",
"query",
"results",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1193-L1205 | [
"def",
"map_async",
"(",
"self",
",",
"callback",
",",
"pass_batch_into_callback",
"=",
"None",
",",
"merge_future",
"=",
"None",
",",
"*",
"*",
"q_options",
")",
":",
"qry",
"=",
"self",
".",
"_fix_namespace",
"(",
")",
"return",
"tasklets",
".",
"get_con... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query.fetch_async | Fetch a list of query results, up to a limit.
This is the asynchronous version of Query.fetch(). | ndb/query.py | def fetch_async(self, limit=None, **q_options):
"""Fetch a list of query results, up to a limit.
This is the asynchronous version of Query.fetch().
"""
if limit is None:
default_options = self._make_options(q_options)
if default_options is not None and default_options.limit is not None:
... | def fetch_async(self, limit=None, **q_options):
"""Fetch a list of query results, up to a limit.
This is the asynchronous version of Query.fetch().
"""
if limit is None:
default_options = self._make_options(q_options)
if default_options is not None and default_options.limit is not None:
... | [
"Fetch",
"a",
"list",
"of",
"query",
"results",
"up",
"to",
"a",
"limit",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1221-L1239 | [
"def",
"fetch_async",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"*",
"*",
"q_options",
")",
":",
"if",
"limit",
"is",
"None",
":",
"default_options",
"=",
"self",
".",
"_make_options",
"(",
"q_options",
")",
"if",
"default_options",
"is",
"not",
"None... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query._get_async | Internal version of get_async(). | ndb/query.py | def _get_async(self, **q_options):
"""Internal version of get_async()."""
res = yield self.fetch_async(1, **q_options)
if not res:
raise tasklets.Return(None)
raise tasklets.Return(res[0]) | def _get_async(self, **q_options):
"""Internal version of get_async()."""
res = yield self.fetch_async(1, **q_options)
if not res:
raise tasklets.Return(None)
raise tasklets.Return(res[0]) | [
"Internal",
"version",
"of",
"get_async",
"()",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1264-L1269 | [
"def",
"_get_async",
"(",
"self",
",",
"*",
"*",
"q_options",
")",
":",
"res",
"=",
"yield",
"self",
".",
"fetch_async",
"(",
"1",
",",
"*",
"*",
"q_options",
")",
"if",
"not",
"res",
":",
"raise",
"tasklets",
".",
"Return",
"(",
"None",
")",
"rais... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query.count_async | Count the number of query results, up to a limit.
This is the asynchronous version of Query.count(). | ndb/query.py | def count_async(self, limit=None, **q_options):
"""Count the number of query results, up to a limit.
This is the asynchronous version of Query.count().
"""
qry = self._fix_namespace()
return qry._count_async(limit=limit, **q_options) | def count_async(self, limit=None, **q_options):
"""Count the number of query results, up to a limit.
This is the asynchronous version of Query.count().
"""
qry = self._fix_namespace()
return qry._count_async(limit=limit, **q_options) | [
"Count",
"the",
"number",
"of",
"query",
"results",
"up",
"to",
"a",
"limit",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1290-L1296 | [
"def",
"count_async",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"*",
"*",
"q_options",
")",
":",
"qry",
"=",
"self",
".",
"_fix_namespace",
"(",
")",
"return",
"qry",
".",
"_count_async",
"(",
"limit",
"=",
"limit",
",",
"*",
"*",
"q_options",
")"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query._count_async | Internal version of count_async(). | ndb/query.py | def _count_async(self, limit=None, **q_options):
"""Internal version of count_async()."""
# TODO: Support offset by incorporating it to the limit.
if 'offset' in q_options:
raise NotImplementedError('.count() and .count_async() do not support '
'offsets at present.')
... | def _count_async(self, limit=None, **q_options):
"""Internal version of count_async()."""
# TODO: Support offset by incorporating it to the limit.
if 'offset' in q_options:
raise NotImplementedError('.count() and .count_async() do not support '
'offsets at present.')
... | [
"Internal",
"version",
"of",
"count_async",
"()",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1299-L1335 | [
"def",
"_count_async",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"*",
"*",
"q_options",
")",
":",
"# TODO: Support offset by incorporating it to the limit.",
"if",
"'offset'",
"in",
"q_options",
":",
"raise",
"NotImplementedError",
"(",
"'.count() and .count_async() ... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query.fetch_page_async | Fetch a page of results.
This is the asynchronous version of Query.fetch_page(). | ndb/query.py | def fetch_page_async(self, page_size, **q_options):
"""Fetch a page of results.
This is the asynchronous version of Query.fetch_page().
"""
qry = self._fix_namespace()
return qry._fetch_page_async(page_size, **q_options) | def fetch_page_async(self, page_size, **q_options):
"""Fetch a page of results.
This is the asynchronous version of Query.fetch_page().
"""
qry = self._fix_namespace()
return qry._fetch_page_async(page_size, **q_options) | [
"Fetch",
"a",
"page",
"of",
"results",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1365-L1371 | [
"def",
"fetch_page_async",
"(",
"self",
",",
"page_size",
",",
"*",
"*",
"q_options",
")",
":",
"qry",
"=",
"self",
".",
"_fix_namespace",
"(",
")",
"return",
"qry",
".",
"_fetch_page_async",
"(",
"page_size",
",",
"*",
"*",
"q_options",
")"
] | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query._fetch_page_async | Internal version of fetch_page_async(). | ndb/query.py | def _fetch_page_async(self, page_size, **q_options):
"""Internal version of fetch_page_async()."""
q_options.setdefault('batch_size', page_size)
q_options.setdefault('produce_cursors', True)
it = self.iter(limit=page_size + 1, **q_options)
results = []
while (yield it.has_next_async()):
re... | def _fetch_page_async(self, page_size, **q_options):
"""Internal version of fetch_page_async()."""
q_options.setdefault('batch_size', page_size)
q_options.setdefault('produce_cursors', True)
it = self.iter(limit=page_size + 1, **q_options)
results = []
while (yield it.has_next_async()):
re... | [
"Internal",
"version",
"of",
"fetch_page_async",
"()",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1374-L1388 | [
"def",
"_fetch_page_async",
"(",
"self",
",",
"page_size",
",",
"*",
"*",
"q_options",
")",
":",
"q_options",
".",
"setdefault",
"(",
"'batch_size'",
",",
"page_size",
")",
"q_options",
".",
"setdefault",
"(",
"'produce_cursors'",
",",
"True",
")",
"it",
"="... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query._make_options | Helper to construct a QueryOptions object from keyword arguments.
Args:
q_options: a dict of keyword arguments.
Note that either 'options' or 'config' can be used to pass another
QueryOptions object, but not both. If another QueryOptions object is
given it provides default values.
If self.... | ndb/query.py | def _make_options(self, q_options):
"""Helper to construct a QueryOptions object from keyword arguments.
Args:
q_options: a dict of keyword arguments.
Note that either 'options' or 'config' can be used to pass another
QueryOptions object, but not both. If another QueryOptions object is
give... | def _make_options(self, q_options):
"""Helper to construct a QueryOptions object from keyword arguments.
Args:
q_options: a dict of keyword arguments.
Note that either 'options' or 'config' can be used to pass another
QueryOptions object, but not both. If another QueryOptions object is
give... | [
"Helper",
"to",
"construct",
"a",
"QueryOptions",
"object",
"from",
"keyword",
"arguments",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1390-L1432 | [
"def",
"_make_options",
"(",
"self",
",",
"q_options",
")",
":",
"if",
"not",
"(",
"q_options",
"or",
"self",
".",
"__projection",
")",
":",
"return",
"self",
".",
"default_options",
"if",
"'options'",
"in",
"q_options",
":",
"# Move 'options' to 'config' since ... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query.analyze | Return a list giving the parameters required by a query. | ndb/query.py | def analyze(self):
"""Return a list giving the parameters required by a query."""
class MockBindings(dict):
def __contains__(self, key):
self[key] = None
return True
bindings = MockBindings()
used = {}
ancestor = self.ancestor
if isinstance(ancestor, ParameterizedThing):
... | def analyze(self):
"""Return a list giving the parameters required by a query."""
class MockBindings(dict):
def __contains__(self, key):
self[key] = None
return True
bindings = MockBindings()
used = {}
ancestor = self.ancestor
if isinstance(ancestor, ParameterizedThing):
... | [
"Return",
"a",
"list",
"giving",
"the",
"parameters",
"required",
"by",
"a",
"query",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1453-L1468 | [
"def",
"analyze",
"(",
"self",
")",
":",
"class",
"MockBindings",
"(",
"dict",
")",
":",
"def",
"__contains__",
"(",
"self",
",",
"key",
")",
":",
"self",
"[",
"key",
"]",
"=",
"None",
"return",
"True",
"bindings",
"=",
"MockBindings",
"(",
")",
"use... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Query._bind | Bind parameter values. Returns a new Query object. | ndb/query.py | def _bind(self, args, kwds):
"""Bind parameter values. Returns a new Query object."""
bindings = dict(kwds)
for i, arg in enumerate(args):
bindings[i + 1] = arg
used = {}
ancestor = self.ancestor
if isinstance(ancestor, ParameterizedThing):
ancestor = ancestor.resolve(bindings, used... | def _bind(self, args, kwds):
"""Bind parameter values. Returns a new Query object."""
bindings = dict(kwds)
for i, arg in enumerate(args):
bindings[i + 1] = arg
used = {}
ancestor = self.ancestor
if isinstance(ancestor, ParameterizedThing):
ancestor = ancestor.resolve(bindings, used... | [
"Bind",
"parameter",
"values",
".",
"Returns",
"a",
"new",
"Query",
"object",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1474-L1498 | [
"def",
"_bind",
"(",
"self",
",",
"args",
",",
"kwds",
")",
":",
"bindings",
"=",
"dict",
"(",
"kwds",
")",
"for",
"i",
",",
"arg",
"in",
"enumerate",
"(",
"args",
")",
":",
"bindings",
"[",
"i",
"+",
"1",
"]",
"=",
"arg",
"used",
"=",
"{",
"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | QueryIterator.cursor_before | Return the cursor before the current item.
You must pass a QueryOptions object with produce_cursors=True
for this to work.
If there is no cursor or no current item, raise BadArgumentError.
Before next() has returned there is no cursor. Once the loop is
exhausted, this returns the cursor after the... | ndb/query.py | def cursor_before(self):
"""Return the cursor before the current item.
You must pass a QueryOptions object with produce_cursors=True
for this to work.
If there is no cursor or no current item, raise BadArgumentError.
Before next() has returned there is no cursor. Once the loop is
exhausted, t... | def cursor_before(self):
"""Return the cursor before the current item.
You must pass a QueryOptions object with produce_cursors=True
for this to work.
If there is no cursor or no current item, raise BadArgumentError.
Before next() has returned there is no cursor. Once the loop is
exhausted, t... | [
"Return",
"the",
"cursor",
"before",
"the",
"current",
"item",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1693-L1707 | [
"def",
"cursor_before",
"(",
"self",
")",
":",
"if",
"self",
".",
"_exhausted",
":",
"return",
"self",
".",
"cursor_after",
"(",
")",
"if",
"isinstance",
"(",
"self",
".",
"_cursor_before",
",",
"BaseException",
")",
":",
"raise",
"self",
".",
"_cursor_bef... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | QueryIterator.cursor_after | Return the cursor after the current item.
You must pass a QueryOptions object with produce_cursors=True
for this to work.
If there is no cursor or no current item, raise BadArgumentError.
Before next() has returned there is no cursor. Once the loop is
exhausted, this returns the cursor after th... | ndb/query.py | def cursor_after(self):
"""Return the cursor after the current item.
You must pass a QueryOptions object with produce_cursors=True
for this to work.
If there is no cursor or no current item, raise BadArgumentError.
Before next() has returned there is no cursor. Once the loop is
exhausted, t... | def cursor_after(self):
"""Return the cursor after the current item.
You must pass a QueryOptions object with produce_cursors=True
for this to work.
If there is no cursor or no current item, raise BadArgumentError.
Before next() has returned there is no cursor. Once the loop is
exhausted, t... | [
"Return",
"the",
"cursor",
"after",
"the",
"current",
"item",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1709-L1721 | [
"def",
"cursor_after",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_cursor_after",
",",
"BaseException",
")",
":",
"raise",
"self",
".",
"_cursor_after",
"return",
"self",
".",
"_cursor_after"
] | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | QueryIterator.has_next_async | Return a Future whose result will say whether a next item is available.
See the module docstring for the usage pattern. | ndb/query.py | def has_next_async(self):
"""Return a Future whose result will say whether a next item is available.
See the module docstring for the usage pattern.
"""
if self._fut is None:
self._fut = self._iter.getq()
flag = True
try:
yield self._fut
except EOFError:
flag = False
r... | def has_next_async(self):
"""Return a Future whose result will say whether a next item is available.
See the module docstring for the usage pattern.
"""
if self._fut is None:
self._fut = self._iter.getq()
flag = True
try:
yield self._fut
except EOFError:
flag = False
r... | [
"Return",
"a",
"Future",
"whose",
"result",
"will",
"say",
"whether",
"a",
"next",
"item",
"is",
"available",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1784-L1796 | [
"def",
"has_next_async",
"(",
"self",
")",
":",
"if",
"self",
".",
"_fut",
"is",
"None",
":",
"self",
".",
"_fut",
"=",
"self",
".",
"_iter",
".",
"getq",
"(",
")",
"flag",
"=",
"True",
"try",
":",
"yield",
"self",
".",
"_fut",
"except",
"EOFError"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | QueryIterator.next | Iterator protocol: get next item or raise StopIteration. | ndb/query.py | def next(self):
"""Iterator protocol: get next item or raise StopIteration."""
if self._fut is None:
self._fut = self._iter.getq()
try:
try:
# The future result is set by this class's _extended_callback
# method.
# pylint: disable=unpacking-non-sequence
(ent,
... | def next(self):
"""Iterator protocol: get next item or raise StopIteration."""
if self._fut is None:
self._fut = self._iter.getq()
try:
try:
# The future result is set by this class's _extended_callback
# method.
# pylint: disable=unpacking-non-sequence
(ent,
... | [
"Iterator",
"protocol",
":",
"get",
"next",
"item",
"or",
"raise",
"StopIteration",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1798-L1816 | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"_fut",
"is",
"None",
":",
"self",
".",
"_fut",
"=",
"self",
".",
"_iter",
".",
"getq",
"(",
")",
"try",
":",
"try",
":",
"# The future result is set by this class's _extended_callback",
"# method.",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | _MultiQuery.run_to_queue | Run this query, putting entities into the given queue. | ndb/query.py | def run_to_queue(self, queue, conn, options=None):
"""Run this query, putting entities into the given queue."""
if options is None:
# Default options.
offset = None
limit = None
keys_only = None
else:
# Capture options we need to simulate.
offset = options.offset
li... | def run_to_queue(self, queue, conn, options=None):
"""Run this query, putting entities into the given queue."""
if options is None:
# Default options.
offset = None
limit = None
keys_only = None
else:
# Capture options we need to simulate.
offset = options.offset
li... | [
"Run",
"this",
"query",
"putting",
"entities",
"into",
"the",
"given",
"queue",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1910-L2047 | [
"def",
"run_to_queue",
"(",
"self",
",",
"queue",
",",
"conn",
",",
"options",
"=",
"None",
")",
":",
"if",
"options",
"is",
"None",
":",
"# Default options.",
"offset",
"=",
"None",
"limit",
"=",
"None",
"keys_only",
"=",
"None",
"else",
":",
"# Capture... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | MemcacheClient.memcache_get | An auto-batching wrapper for memcache.get() or .get_multi().
Args:
key: Key to set. This must be a string; no prefix is applied.
for_cas: If True, request and store CAS ids on the Context.
namespace: Optional namespace.
deadline: Optional deadline for the RPC.
Returns:
A Future ... | ndb/memcache_client.py | def memcache_get(self, key, for_cas=False, namespace=None, use_cache=False,
deadline=None):
"""An auto-batching wrapper for memcache.get() or .get_multi().
Args:
key: Key to set. This must be a string; no prefix is applied.
for_cas: If True, request and store CAS ids on the Cont... | def memcache_get(self, key, for_cas=False, namespace=None, use_cache=False,
deadline=None):
"""An auto-batching wrapper for memcache.get() or .get_multi().
Args:
key: Key to set. This must be a string; no prefix is applied.
for_cas: If True, request and store CAS ids on the Cont... | [
"An",
"auto",
"-",
"batching",
"wrapper",
"for",
"memcache",
".",
"get",
"()",
"or",
".",
"get_multi",
"()",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/memcache_client.py#L103-L128 | [
"def",
"memcache_get",
"(",
"self",
",",
"key",
",",
"for_cas",
"=",
"False",
",",
"namespace",
"=",
"None",
",",
"use_cache",
"=",
"False",
",",
"deadline",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"key",
",",
"basestring",
")",
":",
"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | positional | A decorator to declare that only the first N arguments may be positional.
Note that for methods, n includes 'self'. | ndb/utils.py | def positional(max_pos_args):
"""A decorator to declare that only the first N arguments may be positional.
Note that for methods, n includes 'self'.
"""
__ndb_debug__ = 'SKIP'
def positional_decorator(wrapped):
if not DEBUG:
return wrapped
__ndb_debug__ = 'SKIP'
@wrapping(wrapped)
def... | def positional(max_pos_args):
"""A decorator to declare that only the first N arguments may be positional.
Note that for methods, n includes 'self'.
"""
__ndb_debug__ = 'SKIP'
def positional_decorator(wrapped):
if not DEBUG:
return wrapped
__ndb_debug__ = 'SKIP'
@wrapping(wrapped)
def... | [
"A",
"decorator",
"to",
"declare",
"that",
"only",
"the",
"first",
"N",
"arguments",
"may",
"be",
"positional",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/utils.py#L138-L162 | [
"def",
"positional",
"(",
"max_pos_args",
")",
":",
"__ndb_debug__",
"=",
"'SKIP'",
"def",
"positional_decorator",
"(",
"wrapped",
")",
":",
"if",
"not",
"DEBUG",
":",
"return",
"wrapped",
"__ndb_debug__",
"=",
"'SKIP'",
"@",
"wrapping",
"(",
"wrapped",
")",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | decorator | Converts a function into a decorator that optionally accepts keyword
arguments in its declaration.
Example usage:
@utils.decorator
def decorator(func, args, kwds, op1=None):
... apply op1 ...
return func(*args, **kwds)
# Form (1), vanilla
@decorator
foo(...)
...
# Form (... | ndb/utils.py | def decorator(wrapped_decorator):
"""Converts a function into a decorator that optionally accepts keyword
arguments in its declaration.
Example usage:
@utils.decorator
def decorator(func, args, kwds, op1=None):
... apply op1 ...
return func(*args, **kwds)
# Form (1), vanilla
@decorat... | def decorator(wrapped_decorator):
"""Converts a function into a decorator that optionally accepts keyword
arguments in its declaration.
Example usage:
@utils.decorator
def decorator(func, args, kwds, op1=None):
... apply op1 ...
return func(*args, **kwds)
# Form (1), vanilla
@decorat... | [
"Converts",
"a",
"function",
"into",
"a",
"decorator",
"that",
"optionally",
"accepts",
"keyword",
"arguments",
"in",
"its",
"declaration",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/utils.py#L165-L210 | [
"def",
"decorator",
"(",
"wrapped_decorator",
")",
":",
"def",
"helper",
"(",
"_func",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"def",
"outer_wrapper",
"(",
"func",
")",
":",
"@",
"wrapping",
"(",
"func",
")",
"def",
"inner_wrapper",
"(",
"*",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | fibonacci | A recursive Fibonacci to exercise task switching. | demo/app/fibo.py | def fibonacci(n):
"""A recursive Fibonacci to exercise task switching."""
if n <= 1:
raise ndb.Return(n)
a, b = yield fibonacci(n - 1), fibonacci(n - 2)
raise ndb.Return(a + b) | def fibonacci(n):
"""A recursive Fibonacci to exercise task switching."""
if n <= 1:
raise ndb.Return(n)
a, b = yield fibonacci(n - 1), fibonacci(n - 2)
raise ndb.Return(a + b) | [
"A",
"recursive",
"Fibonacci",
"to",
"exercise",
"task",
"switching",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/demo/app/fibo.py#L32-L37 | [
"def",
"fibonacci",
"(",
"n",
")",
":",
"if",
"n",
"<=",
"1",
":",
"raise",
"ndb",
".",
"Return",
"(",
"n",
")",
"a",
",",
"b",
"=",
"yield",
"fibonacci",
"(",
"n",
"-",
"1",
")",
",",
"fibonacci",
"(",
"n",
"-",
"2",
")",
"raise",
"ndb",
"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | memoizing_fibonacci | A memoizing recursive Fibonacci to exercise RPCs. | demo/app/fibo.py | def memoizing_fibonacci(n):
"""A memoizing recursive Fibonacci to exercise RPCs."""
if n <= 1:
raise ndb.Return(n)
key = ndb.Key(FibonacciMemo, str(n))
memo = yield key.get_async(ndb_should_cache=False)
if memo is not None:
assert memo.arg == n
logging.info('memo hit: %d -> %d', n, memo.value)
... | def memoizing_fibonacci(n):
"""A memoizing recursive Fibonacci to exercise RPCs."""
if n <= 1:
raise ndb.Return(n)
key = ndb.Key(FibonacciMemo, str(n))
memo = yield key.get_async(ndb_should_cache=False)
if memo is not None:
assert memo.arg == n
logging.info('memo hit: %d -> %d', n, memo.value)
... | [
"A",
"memoizing",
"recursive",
"Fibonacci",
"to",
"exercise",
"RPCs",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/demo/app/fibo.py#L46-L63 | [
"def",
"memoizing_fibonacci",
"(",
"n",
")",
":",
"if",
"n",
"<=",
"1",
":",
"raise",
"ndb",
".",
"Return",
"(",
"n",
")",
"key",
"=",
"ndb",
".",
"Key",
"(",
"FibonacciMemo",
",",
"str",
"(",
"n",
")",
")",
"memo",
"=",
"yield",
"key",
".",
"g... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | AutoBatcher.run_queue | Actually run the _todo_tasklet. | ndb/autobatcher.py | def run_queue(self, options, todo):
"""Actually run the _todo_tasklet."""
utils.logging_debug('AutoBatcher(%s): %d items',
self._todo_tasklet.__name__, len(todo))
batch_fut = self._todo_tasklet(todo, options)
self._running.append(batch_fut)
# Add a callback when we're done.
... | def run_queue(self, options, todo):
"""Actually run the _todo_tasklet."""
utils.logging_debug('AutoBatcher(%s): %d items',
self._todo_tasklet.__name__, len(todo))
batch_fut = self._todo_tasklet(todo, options)
self._running.append(batch_fut)
# Add a callback when we're done.
... | [
"Actually",
"run",
"the",
"_todo_tasklet",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/autobatcher.py#L71-L78 | [
"def",
"run_queue",
"(",
"self",
",",
"options",
",",
"todo",
")",
":",
"utils",
".",
"logging_debug",
"(",
"'AutoBatcher(%s): %d items'",
",",
"self",
".",
"_todo_tasklet",
".",
"__name__",
",",
"len",
"(",
"todo",
")",
")",
"batch_fut",
"=",
"self",
".",... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | AutoBatcher.add | Adds an arg and gets back a future.
Args:
arg: one argument for _todo_tasklet.
options: rpc options.
Return:
An instance of future, representing the result of running
_todo_tasklet without batching. | ndb/autobatcher.py | def add(self, arg, options=None):
"""Adds an arg and gets back a future.
Args:
arg: one argument for _todo_tasklet.
options: rpc options.
Return:
An instance of future, representing the result of running
_todo_tasklet without batching.
"""
fut = tasklets.Future('%s.add(%s... | def add(self, arg, options=None):
"""Adds an arg and gets back a future.
Args:
arg: one argument for _todo_tasklet.
options: rpc options.
Return:
An instance of future, representing the result of running
_todo_tasklet without batching.
"""
fut = tasklets.Future('%s.add(%s... | [
"Adds",
"an",
"arg",
"and",
"gets",
"back",
"a",
"future",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/autobatcher.py#L90-L113 | [
"def",
"add",
"(",
"self",
",",
"arg",
",",
"options",
"=",
"None",
")",
":",
"fut",
"=",
"tasklets",
".",
"Future",
"(",
"'%s.add(%s, %s)'",
"%",
"(",
"self",
",",
"arg",
",",
"options",
")",
")",
"todo",
"=",
"self",
".",
"_queues",
".",
"get",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | AutoBatcher._finished_callback | Passes exception along.
Args:
batch_fut: the batch future returned by running todo_tasklet.
todo: (fut, option) pair. fut is the future return by each add() call.
If the batch fut was successful, it has already called fut.set_result()
on other individual futs. This method only handles when the... | ndb/autobatcher.py | def _finished_callback(self, batch_fut, todo):
"""Passes exception along.
Args:
batch_fut: the batch future returned by running todo_tasklet.
todo: (fut, option) pair. fut is the future return by each add() call.
If the batch fut was successful, it has already called fut.set_result()
on ot... | def _finished_callback(self, batch_fut, todo):
"""Passes exception along.
Args:
batch_fut: the batch future returned by running todo_tasklet.
todo: (fut, option) pair. fut is the future return by each add() call.
If the batch fut was successful, it has already called fut.set_result()
on ot... | [
"Passes",
"exception",
"along",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/autobatcher.py#L132-L149 | [
"def",
"_finished_callback",
"(",
"self",
",",
"batch_fut",
",",
"todo",
")",
":",
"self",
".",
"_running",
".",
"remove",
"(",
"batch_fut",
")",
"err",
"=",
"batch_fut",
".",
"get_exception",
"(",
")",
"if",
"err",
"is",
"not",
"None",
":",
"tb",
"=",... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | get_namespaces | Return all namespaces in the specified range.
Args:
start: only return namespaces >= start if start is not None.
end: only return namespaces < end if end is not None.
Returns:
A list of namespace names between the (optional) start and end values. | ndb/metadata.py | def get_namespaces(start=None, end=None):
"""Return all namespaces in the specified range.
Args:
start: only return namespaces >= start if start is not None.
end: only return namespaces < end if end is not None.
Returns:
A list of namespace names between the (optional) start and end values.
"""
... | def get_namespaces(start=None, end=None):
"""Return all namespaces in the specified range.
Args:
start: only return namespaces >= start if start is not None.
end: only return namespaces < end if end is not None.
Returns:
A list of namespace names between the (optional) start and end values.
"""
... | [
"Return",
"all",
"namespaces",
"in",
"the",
"specified",
"range",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L239-L254 | [
"def",
"get_namespaces",
"(",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"q",
"=",
"Namespace",
".",
"query",
"(",
")",
"if",
"start",
"is",
"not",
"None",
":",
"q",
"=",
"q",
".",
"filter",
"(",
"Namespace",
".",
"key",
">=",
"Name... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | get_kinds | Return all kinds in the specified range, for the current namespace.
Args:
start: only return kinds >= start if start is not None.
end: only return kinds < end if end is not None.
Returns:
A list of kind names between the (optional) start and end values. | ndb/metadata.py | def get_kinds(start=None, end=None):
"""Return all kinds in the specified range, for the current namespace.
Args:
start: only return kinds >= start if start is not None.
end: only return kinds < end if end is not None.
Returns:
A list of kind names between the (optional) start and end values.
"""
... | def get_kinds(start=None, end=None):
"""Return all kinds in the specified range, for the current namespace.
Args:
start: only return kinds >= start if start is not None.
end: only return kinds < end if end is not None.
Returns:
A list of kind names between the (optional) start and end values.
"""
... | [
"Return",
"all",
"kinds",
"in",
"the",
"specified",
"range",
"for",
"the",
"current",
"namespace",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L257-L275 | [
"def",
"get_kinds",
"(",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"q",
"=",
"Kind",
".",
"query",
"(",
")",
"if",
"start",
"is",
"not",
"None",
"and",
"start",
"!=",
"''",
":",
"q",
"=",
"q",
".",
"filter",
"(",
"Kind",
".",
"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | get_properties_of_kind | Return all properties of kind in the specified range.
NOTE: This function does not return unindexed properties.
Args:
kind: name of kind whose properties you want.
start: only return properties >= start if start is not None.
end: only return properties < end if end is not None.
Returns:
A list ... | ndb/metadata.py | def get_properties_of_kind(kind, start=None, end=None):
"""Return all properties of kind in the specified range.
NOTE: This function does not return unindexed properties.
Args:
kind: name of kind whose properties you want.
start: only return properties >= start if start is not None.
end: only return... | def get_properties_of_kind(kind, start=None, end=None):
"""Return all properties of kind in the specified range.
NOTE: This function does not return unindexed properties.
Args:
kind: name of kind whose properties you want.
start: only return properties >= start if start is not None.
end: only return... | [
"Return",
"all",
"properties",
"of",
"kind",
"in",
"the",
"specified",
"range",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L278-L300 | [
"def",
"get_properties_of_kind",
"(",
"kind",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"q",
"=",
"Property",
".",
"query",
"(",
"ancestor",
"=",
"Property",
".",
"key_for_kind",
"(",
"kind",
")",
")",
"if",
"start",
"is",
"not",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | get_representations_of_kind | Return all representations of properties of kind in the specified range.
NOTE: This function does not return unindexed properties.
Args:
kind: name of kind whose properties you want.
start: only return properties >= start if start is not None.
end: only return properties < end if end is not None.
R... | ndb/metadata.py | def get_representations_of_kind(kind, start=None, end=None):
"""Return all representations of properties of kind in the specified range.
NOTE: This function does not return unindexed properties.
Args:
kind: name of kind whose properties you want.
start: only return properties >= start if start is not No... | def get_representations_of_kind(kind, start=None, end=None):
"""Return all representations of properties of kind in the specified range.
NOTE: This function does not return unindexed properties.
Args:
kind: name of kind whose properties you want.
start: only return properties >= start if start is not No... | [
"Return",
"all",
"representations",
"of",
"properties",
"of",
"kind",
"in",
"the",
"specified",
"range",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L303-L328 | [
"def",
"get_representations_of_kind",
"(",
"kind",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"q",
"=",
"Property",
".",
"query",
"(",
"ancestor",
"=",
"Property",
".",
"key_for_kind",
"(",
"kind",
")",
")",
"if",
"start",
"is",
"not... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | get_entity_group_version | Return the version of the entity group containing key.
Args:
key: a key for an entity group whose __entity_group__ key you want.
Returns:
The version of the entity group containing key. This version is
guaranteed to increase on every change to the entity group. The version
may increase even in the... | ndb/metadata.py | def get_entity_group_version(key):
"""Return the version of the entity group containing key.
Args:
key: a key for an entity group whose __entity_group__ key you want.
Returns:
The version of the entity group containing key. This version is
guaranteed to increase on every change to the entity group. ... | def get_entity_group_version(key):
"""Return the version of the entity group containing key.
Args:
key: a key for an entity group whose __entity_group__ key you want.
Returns:
The version of the entity group containing key. This version is
guaranteed to increase on every change to the entity group. ... | [
"Return",
"the",
"version",
"of",
"the",
"entity",
"group",
"containing",
"key",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L331-L350 | [
"def",
"get_entity_group_version",
"(",
"key",
")",
":",
"eg",
"=",
"EntityGroup",
".",
"key_for_entity_group",
"(",
"key",
")",
".",
"get",
"(",
")",
"if",
"eg",
":",
"return",
"eg",
".",
"version",
"else",
":",
"return",
"None"
] | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Namespace.key_for_namespace | Return the Key for a namespace.
Args:
namespace: A string giving the namespace whose key is requested.
Returns:
The Key for the namespace. | ndb/metadata.py | def key_for_namespace(cls, namespace):
"""Return the Key for a namespace.
Args:
namespace: A string giving the namespace whose key is requested.
Returns:
The Key for the namespace.
"""
if namespace:
return model.Key(cls.KIND_NAME, namespace)
else:
return model.Key(cls.K... | def key_for_namespace(cls, namespace):
"""Return the Key for a namespace.
Args:
namespace: A string giving the namespace whose key is requested.
Returns:
The Key for the namespace.
"""
if namespace:
return model.Key(cls.KIND_NAME, namespace)
else:
return model.Key(cls.K... | [
"Return",
"the",
"Key",
"for",
"a",
"namespace",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L76-L88 | [
"def",
"key_for_namespace",
"(",
"cls",
",",
"namespace",
")",
":",
"if",
"namespace",
":",
"return",
"model",
".",
"Key",
"(",
"cls",
".",
"KIND_NAME",
",",
"namespace",
")",
"else",
":",
"return",
"model",
".",
"Key",
"(",
"cls",
".",
"KIND_NAME",
",... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Property.key_for_property | Return the __property__ key for property of kind.
Args:
kind: kind whose key is requested.
property: property whose key is requested.
Returns:
The key for property of kind. | ndb/metadata.py | def key_for_property(cls, kind, property):
"""Return the __property__ key for property of kind.
Args:
kind: kind whose key is requested.
property: property whose key is requested.
Returns:
The key for property of kind.
"""
return model.Key(Kind.KIND_NAME, kind, Property.KIND_NAME... | def key_for_property(cls, kind, property):
"""Return the __property__ key for property of kind.
Args:
kind: kind whose key is requested.
property: property whose key is requested.
Returns:
The key for property of kind.
"""
return model.Key(Kind.KIND_NAME, kind, Property.KIND_NAME... | [
"Return",
"the",
"__property__",
"key",
"for",
"property",
"of",
"kind",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L168-L178 | [
"def",
"key_for_property",
"(",
"cls",
",",
"kind",
",",
"property",
")",
":",
"return",
"model",
".",
"Key",
"(",
"Kind",
".",
"KIND_NAME",
",",
"kind",
",",
"Property",
".",
"KIND_NAME",
",",
"property",
")"
] | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Property.key_to_kind | Return the kind specified by a given __property__ key.
Args:
key: key whose kind name is requested.
Returns:
The kind specified by key. | ndb/metadata.py | def key_to_kind(cls, key):
"""Return the kind specified by a given __property__ key.
Args:
key: key whose kind name is requested.
Returns:
The kind specified by key.
"""
if key.kind() == Kind.KIND_NAME:
return key.id()
else:
return key.parent().id() | def key_to_kind(cls, key):
"""Return the kind specified by a given __property__ key.
Args:
key: key whose kind name is requested.
Returns:
The kind specified by key.
"""
if key.kind() == Kind.KIND_NAME:
return key.id()
else:
return key.parent().id() | [
"Return",
"the",
"kind",
"specified",
"by",
"a",
"given",
"__property__",
"key",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L181-L193 | [
"def",
"key_to_kind",
"(",
"cls",
",",
"key",
")",
":",
"if",
"key",
".",
"kind",
"(",
")",
"==",
"Kind",
".",
"KIND_NAME",
":",
"return",
"key",
".",
"id",
"(",
")",
"else",
":",
"return",
"key",
".",
"parent",
"(",
")",
".",
"id",
"(",
")"
] | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | EntityGroup.key_for_entity_group | Return the key for the entity group containing key.
Args:
key: a key for an entity group whose __entity_group__ key you want.
Returns:
The __entity_group__ key for the entity group containing key. | ndb/metadata.py | def key_for_entity_group(cls, key):
"""Return the key for the entity group containing key.
Args:
key: a key for an entity group whose __entity_group__ key you want.
Returns:
The __entity_group__ key for the entity group containing key.
"""
return model.Key(cls.KIND_NAME, cls.ID, parent... | def key_for_entity_group(cls, key):
"""Return the key for the entity group containing key.
Args:
key: a key for an entity group whose __entity_group__ key you want.
Returns:
The __entity_group__ key for the entity group containing key.
"""
return model.Key(cls.KIND_NAME, cls.ID, parent... | [
"Return",
"the",
"key",
"for",
"the",
"entity",
"group",
"containing",
"key",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/metadata.py#L227-L236 | [
"def",
"key_for_entity_group",
"(",
"cls",
",",
"key",
")",
":",
"return",
"model",
".",
"Key",
"(",
"cls",
".",
"KIND_NAME",
",",
"cls",
".",
"ID",
",",
"parent",
"=",
"key",
".",
"root",
"(",
")",
")"
] | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | NdbDjangoMiddleware.process_request | Called by Django before deciding which view to execute. | ndb/django_middleware.py | def process_request(self, unused_request):
"""Called by Django before deciding which view to execute."""
# Compare to the first half of toplevel() in context.py.
tasklets._state.clear_all_pending()
# Create and install a new context.
ctx = tasklets.make_default_context()
tasklets.set_context(ctx... | def process_request(self, unused_request):
"""Called by Django before deciding which view to execute."""
# Compare to the first half of toplevel() in context.py.
tasklets._state.clear_all_pending()
# Create and install a new context.
ctx = tasklets.make_default_context()
tasklets.set_context(ctx... | [
"Called",
"by",
"Django",
"before",
"deciding",
"which",
"view",
"to",
"execute",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/django_middleware.py#L42-L48 | [
"def",
"process_request",
"(",
"self",
",",
"unused_request",
")",
":",
"# Compare to the first half of toplevel() in context.py.",
"tasklets",
".",
"_state",
".",
"clear_all_pending",
"(",
")",
"# Create and install a new context.",
"ctx",
"=",
"tasklets",
".",
"make_defau... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | _make_ctx_options | Helper to construct a ContextOptions object from keyword arguments.
Args:
ctx_options: A dict of keyword arguments.
config_cls: Optional Configuration class to use, default ContextOptions.
Note that either 'options' or 'config' can be used to pass another
Configuration object, but not both. If another ... | ndb/context.py | def _make_ctx_options(ctx_options, config_cls=ContextOptions):
"""Helper to construct a ContextOptions object from keyword arguments.
Args:
ctx_options: A dict of keyword arguments.
config_cls: Optional Configuration class to use, default ContextOptions.
Note that either 'options' or 'config' can be use... | def _make_ctx_options(ctx_options, config_cls=ContextOptions):
"""Helper to construct a ContextOptions object from keyword arguments.
Args:
ctx_options: A dict of keyword arguments.
config_cls: Optional Configuration class to use, default ContextOptions.
Note that either 'options' or 'config' can be use... | [
"Helper",
"to",
"construct",
"a",
"ContextOptions",
"object",
"from",
"keyword",
"arguments",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/context.py#L103-L126 | [
"def",
"_make_ctx_options",
"(",
"ctx_options",
",",
"config_cls",
"=",
"ContextOptions",
")",
":",
"if",
"not",
"ctx_options",
":",
"return",
"None",
"for",
"key",
"in",
"list",
"(",
"ctx_options",
")",
":",
"translation",
"=",
"_OPTION_TRANSLATIONS",
".",
"g... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Context.set_cache_policy | Set the context cache policy function.
Args:
func: A function that accepts a Key instance as argument and returns
a bool indicating if it should be cached. May be None. | ndb/context.py | def set_cache_policy(self, func):
"""Set the context cache policy function.
Args:
func: A function that accepts a Key instance as argument and returns
a bool indicating if it should be cached. May be None.
"""
if func is None:
func = self.default_cache_policy
elif isinstance(fu... | def set_cache_policy(self, func):
"""Set the context cache policy function.
Args:
func: A function that accepts a Key instance as argument and returns
a bool indicating if it should be cached. May be None.
"""
if func is None:
func = self.default_cache_policy
elif isinstance(fu... | [
"Set",
"the",
"context",
"cache",
"policy",
"function",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/context.py#L281-L292 | [
"def",
"set_cache_policy",
"(",
"self",
",",
"func",
")",
":",
"if",
"func",
"is",
"None",
":",
"func",
"=",
"self",
".",
"default_cache_policy",
"elif",
"isinstance",
"(",
"func",
",",
"bool",
")",
":",
"func",
"=",
"lambda",
"unused_key",
",",
"flag",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Context._use_cache | Return whether to use the context cache for this key.
Args:
key: Key instance.
options: ContextOptions instance, or None.
Returns:
True if the key should be cached, False otherwise. | ndb/context.py | def _use_cache(self, key, options=None):
"""Return whether to use the context cache for this key.
Args:
key: Key instance.
options: ContextOptions instance, or None.
Returns:
True if the key should be cached, False otherwise.
"""
flag = ContextOptions.use_cache(options)
if fl... | def _use_cache(self, key, options=None):
"""Return whether to use the context cache for this key.
Args:
key: Key instance.
options: ContextOptions instance, or None.
Returns:
True if the key should be cached, False otherwise.
"""
flag = ContextOptions.use_cache(options)
if fl... | [
"Return",
"whether",
"to",
"use",
"the",
"context",
"cache",
"for",
"this",
"key",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/context.py#L294-L311 | [
"def",
"_use_cache",
"(",
"self",
",",
"key",
",",
"options",
"=",
"None",
")",
":",
"flag",
"=",
"ContextOptions",
".",
"use_cache",
"(",
"options",
")",
"if",
"flag",
"is",
"None",
":",
"flag",
"=",
"self",
".",
"_cache_policy",
"(",
"key",
")",
"i... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Context.set_memcache_policy | Set the memcache policy function.
Args:
func: A function that accepts a Key instance as argument and returns
a bool indicating if it should be cached. May be None. | ndb/context.py | def set_memcache_policy(self, func):
"""Set the memcache policy function.
Args:
func: A function that accepts a Key instance as argument and returns
a bool indicating if it should be cached. May be None.
"""
if func is None:
func = self.default_memcache_policy
elif isinstance(f... | def set_memcache_policy(self, func):
"""Set the memcache policy function.
Args:
func: A function that accepts a Key instance as argument and returns
a bool indicating if it should be cached. May be None.
"""
if func is None:
func = self.default_memcache_policy
elif isinstance(f... | [
"Set",
"the",
"memcache",
"policy",
"function",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/context.py#L348-L359 | [
"def",
"set_memcache_policy",
"(",
"self",
",",
"func",
")",
":",
"if",
"func",
"is",
"None",
":",
"func",
"=",
"self",
".",
"default_memcache_policy",
"elif",
"isinstance",
"(",
"func",
",",
"bool",
")",
":",
"func",
"=",
"lambda",
"unused_key",
",",
"f... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Context._use_memcache | Return whether to use memcache for this key.
Args:
key: Key instance.
options: ContextOptions instance, or None.
Returns:
True if the key should be cached in memcache, False otherwise. | ndb/context.py | def _use_memcache(self, key, options=None):
"""Return whether to use memcache for this key.
Args:
key: Key instance.
options: ContextOptions instance, or None.
Returns:
True if the key should be cached in memcache, False otherwise.
"""
flag = ContextOptions.use_memcache(options)
... | def _use_memcache(self, key, options=None):
"""Return whether to use memcache for this key.
Args:
key: Key instance.
options: ContextOptions instance, or None.
Returns:
True if the key should be cached in memcache, False otherwise.
"""
flag = ContextOptions.use_memcache(options)
... | [
"Return",
"whether",
"to",
"use",
"memcache",
"for",
"this",
"key",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/context.py#L361-L378 | [
"def",
"_use_memcache",
"(",
"self",
",",
"key",
",",
"options",
"=",
"None",
")",
":",
"flag",
"=",
"ContextOptions",
".",
"use_memcache",
"(",
"options",
")",
"if",
"flag",
"is",
"None",
":",
"flag",
"=",
"self",
".",
"_memcache_policy",
"(",
"key",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Context.default_datastore_policy | Default datastore policy.
This defers to _use_datastore on the Model class.
Args:
key: Key instance.
Returns:
A bool or None. | ndb/context.py | def default_datastore_policy(key):
"""Default datastore policy.
This defers to _use_datastore on the Model class.
Args:
key: Key instance.
Returns:
A bool or None.
"""
flag = None
if key is not None:
modelclass = model.Model._kind_map.get(key.kind())
if modelclass ... | def default_datastore_policy(key):
"""Default datastore policy.
This defers to _use_datastore on the Model class.
Args:
key: Key instance.
Returns:
A bool or None.
"""
flag = None
if key is not None:
modelclass = model.Model._kind_map.get(key.kind())
if modelclass ... | [
"Default",
"datastore",
"policy",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/context.py#L381-L402 | [
"def",
"default_datastore_policy",
"(",
"key",
")",
":",
"flag",
"=",
"None",
"if",
"key",
"is",
"not",
"None",
":",
"modelclass",
"=",
"model",
".",
"Model",
".",
"_kind_map",
".",
"get",
"(",
"key",
".",
"kind",
"(",
")",
")",
"if",
"modelclass",
"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Context.set_datastore_policy | Set the context datastore policy function.
Args:
func: A function that accepts a Key instance as argument and returns
a bool indicating if it should use the datastore. May be None. | ndb/context.py | def set_datastore_policy(self, func):
"""Set the context datastore policy function.
Args:
func: A function that accepts a Key instance as argument and returns
a bool indicating if it should use the datastore. May be None.
"""
if func is None:
func = self.default_datastore_policy
... | def set_datastore_policy(self, func):
"""Set the context datastore policy function.
Args:
func: A function that accepts a Key instance as argument and returns
a bool indicating if it should use the datastore. May be None.
"""
if func is None:
func = self.default_datastore_policy
... | [
"Set",
"the",
"context",
"datastore",
"policy",
"function",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/context.py#L415-L426 | [
"def",
"set_datastore_policy",
"(",
"self",
",",
"func",
")",
":",
"if",
"func",
"is",
"None",
":",
"func",
"=",
"self",
".",
"default_datastore_policy",
"elif",
"isinstance",
"(",
"func",
",",
"bool",
")",
":",
"func",
"=",
"lambda",
"unused_key",
",",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Context._use_datastore | Return whether to use the datastore for this key.
Args:
key: Key instance.
options: ContextOptions instance, or None.
Returns:
True if the datastore should be used, False otherwise. | ndb/context.py | def _use_datastore(self, key, options=None):
"""Return whether to use the datastore for this key.
Args:
key: Key instance.
options: ContextOptions instance, or None.
Returns:
True if the datastore should be used, False otherwise.
"""
flag = ContextOptions.use_datastore(options)
... | def _use_datastore(self, key, options=None):
"""Return whether to use the datastore for this key.
Args:
key: Key instance.
options: ContextOptions instance, or None.
Returns:
True if the datastore should be used, False otherwise.
"""
flag = ContextOptions.use_datastore(options)
... | [
"Return",
"whether",
"to",
"use",
"the",
"datastore",
"for",
"this",
"key",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/context.py#L428-L445 | [
"def",
"_use_datastore",
"(",
"self",
",",
"key",
",",
"options",
"=",
"None",
")",
":",
"flag",
"=",
"ContextOptions",
".",
"use_datastore",
"(",
"options",
")",
"if",
"flag",
"is",
"None",
":",
"flag",
"=",
"self",
".",
"_datastore_policy",
"(",
"key",... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Context.default_memcache_timeout_policy | Default memcache timeout policy.
This defers to _memcache_timeout on the Model class.
Args:
key: Key instance.
Returns:
Memcache timeout to use (integer), or None. | ndb/context.py | def default_memcache_timeout_policy(key):
"""Default memcache timeout policy.
This defers to _memcache_timeout on the Model class.
Args:
key: Key instance.
Returns:
Memcache timeout to use (integer), or None.
"""
timeout = None
if key is not None and isinstance(key, model.Key)... | def default_memcache_timeout_policy(key):
"""Default memcache timeout policy.
This defers to _memcache_timeout on the Model class.
Args:
key: Key instance.
Returns:
Memcache timeout to use (integer), or None.
"""
timeout = None
if key is not None and isinstance(key, model.Key)... | [
"Default",
"memcache",
"timeout",
"policy",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/context.py#L448-L469 | [
"def",
"default_memcache_timeout_policy",
"(",
"key",
")",
":",
"timeout",
"=",
"None",
"if",
"key",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"key",
",",
"model",
".",
"Key",
")",
":",
"modelclass",
"=",
"model",
".",
"Model",
".",
"_kind_map",
"."... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Context.set_memcache_timeout_policy | Set the policy function for memcache timeout (expiration).
Args:
func: A function that accepts a key instance as argument and returns
an integer indicating the desired memcache timeout. May be None.
If the function returns 0 it implies the default timeout. | ndb/context.py | def set_memcache_timeout_policy(self, func):
"""Set the policy function for memcache timeout (expiration).
Args:
func: A function that accepts a key instance as argument and returns
an integer indicating the desired memcache timeout. May be None.
If the function returns 0 it implies the def... | def set_memcache_timeout_policy(self, func):
"""Set the policy function for memcache timeout (expiration).
Args:
func: A function that accepts a key instance as argument and returns
an integer indicating the desired memcache timeout. May be None.
If the function returns 0 it implies the def... | [
"Set",
"the",
"policy",
"function",
"for",
"memcache",
"timeout",
"(",
"expiration",
")",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/context.py#L473-L486 | [
"def",
"set_memcache_timeout_policy",
"(",
"self",
",",
"func",
")",
":",
"if",
"func",
"is",
"None",
":",
"func",
"=",
"self",
".",
"default_memcache_timeout_policy",
"elif",
"isinstance",
"(",
"func",
",",
"(",
"int",
",",
"long",
")",
")",
":",
"func",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Context._get_memcache_timeout | Return the memcache timeout (expiration) for this key. | ndb/context.py | def _get_memcache_timeout(self, key, options=None):
"""Return the memcache timeout (expiration) for this key."""
timeout = ContextOptions.memcache_timeout(options)
if timeout is None:
timeout = self._memcache_timeout_policy(key)
if timeout is None:
timeout = ContextOptions.memcache_timeout(s... | def _get_memcache_timeout(self, key, options=None):
"""Return the memcache timeout (expiration) for this key."""
timeout = ContextOptions.memcache_timeout(options)
if timeout is None:
timeout = self._memcache_timeout_policy(key)
if timeout is None:
timeout = ContextOptions.memcache_timeout(s... | [
"Return",
"the",
"memcache",
"timeout",
"(",
"expiration",
")",
"for",
"this",
"key",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/context.py#L492-L501 | [
"def",
"_get_memcache_timeout",
"(",
"self",
",",
"key",
",",
"options",
"=",
"None",
")",
":",
"timeout",
"=",
"ContextOptions",
".",
"memcache_timeout",
"(",
"options",
")",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"self",
".",
"_memcache_timeou... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Context._load_from_cache_if_available | Returns a cached Model instance given the entity key if available.
Args:
key: Key instance.
Returns:
A Model instance if the key exists in the cache. | ndb/context.py | def _load_from_cache_if_available(self, key):
"""Returns a cached Model instance given the entity key if available.
Args:
key: Key instance.
Returns:
A Model instance if the key exists in the cache.
"""
if key in self._cache:
entity = self._cache[key] # May be None, meaning "doe... | def _load_from_cache_if_available(self, key):
"""Returns a cached Model instance given the entity key if available.
Args:
key: Key instance.
Returns:
A Model instance if the key exists in the cache.
"""
if key in self._cache:
entity = self._cache[key] # May be None, meaning "doe... | [
"Returns",
"a",
"cached",
"Model",
"instance",
"given",
"the",
"entity",
"key",
"if",
"available",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/context.py#L518-L532 | [
"def",
"_load_from_cache_if_available",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"_cache",
":",
"entity",
"=",
"self",
".",
"_cache",
"[",
"key",
"]",
"# May be None, meaning \"doesn't exist\".",
"if",
"entity",
"is",
"None",
"or",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Context.get | Return a Model instance given the entity key.
It will use the context cache if the cache policy for the given
key is enabled.
Args:
key: Key instance.
**ctx_options: Context options.
Returns:
A Model instance if the key exists in the datastore; None otherwise. | ndb/context.py | def get(self, key, **ctx_options):
"""Return a Model instance given the entity key.
It will use the context cache if the cache policy for the given
key is enabled.
Args:
key: Key instance.
**ctx_options: Context options.
Returns:
A Model instance if the key exists in the datasto... | def get(self, key, **ctx_options):
"""Return a Model instance given the entity key.
It will use the context cache if the cache policy for the given
key is enabled.
Args:
key: Key instance.
**ctx_options: Context options.
Returns:
A Model instance if the key exists in the datasto... | [
"Return",
"a",
"Model",
"instance",
"given",
"the",
"entity",
"key",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/context.py#L542-L637 | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"*",
"*",
"ctx_options",
")",
":",
"options",
"=",
"_make_ctx_options",
"(",
"ctx_options",
")",
"use_cache",
"=",
"self",
".",
"_use_cache",
"(",
"key",
",",
"options",
")",
"if",
"use_cache",
":",
"self",
"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Context.call_on_commit | Call a callback upon successful commit of a transaction.
If not in a transaction, the callback is called immediately.
In a transaction, multiple callbacks may be registered and will be
called once the transaction commits, in the order in which they
were registered. If the transaction fails, the callb... | ndb/context.py | def call_on_commit(self, callback):
"""Call a callback upon successful commit of a transaction.
If not in a transaction, the callback is called immediately.
In a transaction, multiple callbacks may be registered and will be
called once the transaction commits, in the order in which they
were regis... | def call_on_commit(self, callback):
"""Call a callback upon successful commit of a transaction.
If not in a transaction, the callback is called immediately.
In a transaction, multiple callbacks may be registered and will be
called once the transaction commits, in the order in which they
were regis... | [
"Call",
"a",
"callback",
"upon",
"successful",
"commit",
"of",
"a",
"transaction",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/context.py#L908-L928 | [
"def",
"call_on_commit",
"(",
"self",
",",
"callback",
")",
":",
"if",
"not",
"self",
".",
"in_transaction",
"(",
")",
":",
"callback",
"(",
")",
"else",
":",
"self",
".",
"_on_commit_queue",
".",
"append",
"(",
"callback",
")"
] | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | get_nickname | Return a Future for a nickname from an account. | demo/app/main.py | def get_nickname(userid):
"""Return a Future for a nickname from an account."""
account = yield get_account(userid)
if not account:
nickname = 'Unregistered'
else:
nickname = account.nickname or account.email
raise ndb.Return(nickname) | def get_nickname(userid):
"""Return a Future for a nickname from an account."""
account = yield get_account(userid)
if not account:
nickname = 'Unregistered'
else:
nickname = account.nickname or account.email
raise ndb.Return(nickname) | [
"Return",
"a",
"Future",
"for",
"a",
"nickname",
"from",
"an",
"account",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/demo/app/main.py#L111-L118 | [
"def",
"get_nickname",
"(",
"userid",
")",
":",
"account",
"=",
"yield",
"get_account",
"(",
"userid",
")",
"if",
"not",
"account",
":",
"nickname",
"=",
"'Unregistered'",
"else",
":",
"nickname",
"=",
"account",
".",
"nickname",
"or",
"account",
".",
"ema... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | mark_done | Marks a task as done.
Args:
task_id: The integer id of the task to update.
Raises:
ValueError: if the requested task doesn't exist. | demo/task_list.py | def mark_done(task_id):
"""Marks a task as done.
Args:
task_id: The integer id of the task to update.
Raises:
ValueError: if the requested task doesn't exist.
"""
task = Task.get_by_id(task_id)
if task is None:
raise ValueError('Task with id %d does not exist' % task_id)
task.done = True
t... | def mark_done(task_id):
"""Marks a task as done.
Args:
task_id: The integer id of the task to update.
Raises:
ValueError: if the requested task doesn't exist.
"""
task = Task.get_by_id(task_id)
if task is None:
raise ValueError('Task with id %d does not exist' % task_id)
task.done = True
t... | [
"Marks",
"a",
"task",
"as",
"done",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/demo/task_list.py#L61-L74 | [
"def",
"mark_done",
"(",
"task_id",
")",
":",
"task",
"=",
"Task",
".",
"get_by_id",
"(",
"task_id",
")",
"if",
"task",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Task with id %d does not exist'",
"%",
"task_id",
")",
"task",
".",
"done",
"=",
"True"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | format_tasks | Converts a list of tasks to a list of string representations.
Args:
tasks: A list of the tasks to convert.
Returns:
A list of string formatted tasks. | demo/task_list.py | def format_tasks(tasks):
"""Converts a list of tasks to a list of string representations.
Args:
tasks: A list of the tasks to convert.
Returns:
A list of string formatted tasks.
"""
return ['%d : %s (%s)' % (task.key.id(),
task.description,
('do... | def format_tasks(tasks):
"""Converts a list of tasks to a list of string representations.
Args:
tasks: A list of the tasks to convert.
Returns:
A list of string formatted tasks.
"""
return ['%d : %s (%s)' % (task.key.id(),
task.description,
('do... | [
"Converts",
"a",
"list",
"of",
"tasks",
"to",
"a",
"list",
"of",
"string",
"representations",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/demo/task_list.py#L102-L114 | [
"def",
"format_tasks",
"(",
"tasks",
")",
":",
"return",
"[",
"'%d : %s (%s)'",
"%",
"(",
"task",
".",
"key",
".",
"id",
"(",
")",
",",
"task",
".",
"description",
",",
"(",
"'done'",
"if",
"task",
".",
"done",
"else",
"'created %s'",
"%",
"task",
".... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | handle_command | Accepts a string command and performs an action.
Args:
command: the command to run as a string. | demo/task_list.py | def handle_command(command):
"""Accepts a string command and performs an action.
Args:
command: the command to run as a string.
"""
try:
cmds = command.split(None, 1)
cmd = cmds[0]
if cmd == 'new':
add_task(get_arg(cmds))
elif cmd == 'done':
mark_done(int(get_arg(cmds)))
eli... | def handle_command(command):
"""Accepts a string command and performs an action.
Args:
command: the command to run as a string.
"""
try:
cmds = command.split(None, 1)
cmd = cmds[0]
if cmd == 'new':
add_task(get_arg(cmds))
elif cmd == 'done':
mark_done(int(get_arg(cmds)))
eli... | [
"Accepts",
"a",
"string",
"command",
"and",
"performs",
"an",
"action",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/demo/task_list.py#L135-L157 | [
"def",
"handle_command",
"(",
"command",
")",
":",
"try",
":",
"cmds",
"=",
"command",
".",
"split",
"(",
"None",
",",
"1",
")",
"cmd",
"=",
"cmds",
"[",
"0",
"]",
"if",
"cmd",
"==",
"'new'",
":",
"add_task",
"(",
"get_arg",
"(",
"cmds",
")",
")"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | delete_async | Async version of delete(). | ndb/blobstore.py | def delete_async(blob_key, **options):
"""Async version of delete()."""
if not isinstance(blob_key, (basestring, BlobKey)):
raise TypeError('Expected blob key, got %r' % (blob_key,))
rpc = blobstore.create_rpc(**options)
yield blobstore.delete_async(blob_key, rpc=rpc) | def delete_async(blob_key, **options):
"""Async version of delete()."""
if not isinstance(blob_key, (basestring, BlobKey)):
raise TypeError('Expected blob key, got %r' % (blob_key,))
rpc = blobstore.create_rpc(**options)
yield blobstore.delete_async(blob_key, rpc=rpc) | [
"Async",
"version",
"of",
"delete",
"()",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/blobstore.py#L273-L278 | [
"def",
"delete_async",
"(",
"blob_key",
",",
"*",
"*",
"options",
")",
":",
"if",
"not",
"isinstance",
"(",
"blob_key",
",",
"(",
"basestring",
",",
"BlobKey",
")",
")",
":",
"raise",
"TypeError",
"(",
"'Expected blob key, got %r'",
"%",
"(",
"blob_key",
"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | delete_multi_async | Async version of delete_multi(). | ndb/blobstore.py | def delete_multi_async(blob_keys, **options):
"""Async version of delete_multi()."""
if isinstance(blob_keys, (basestring, BlobKey)):
raise TypeError('Expected a list, got %r' % (blob_key,))
rpc = blobstore.create_rpc(**options)
yield blobstore.delete_async(blob_keys, rpc=rpc) | def delete_multi_async(blob_keys, **options):
"""Async version of delete_multi()."""
if isinstance(blob_keys, (basestring, BlobKey)):
raise TypeError('Expected a list, got %r' % (blob_key,))
rpc = blobstore.create_rpc(**options)
yield blobstore.delete_async(blob_keys, rpc=rpc) | [
"Async",
"version",
"of",
"delete_multi",
"()",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/blobstore.py#L293-L298 | [
"def",
"delete_multi_async",
"(",
"blob_keys",
",",
"*",
"*",
"options",
")",
":",
"if",
"isinstance",
"(",
"blob_keys",
",",
"(",
"basestring",
",",
"BlobKey",
")",
")",
":",
"raise",
"TypeError",
"(",
"'Expected a list, got %r'",
"%",
"(",
"blob_key",
",",... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | create_upload_url | Create upload URL for POST form.
Args:
success_path: Path within application to call when POST is successful
and upload is complete.
max_bytes_per_blob: The maximum size in bytes that any one blob in the
upload can be or None for no maximum size.
max_bytes_total: The maximum size in bytes tha... | ndb/blobstore.py | def create_upload_url(success_path,
max_bytes_per_blob=None,
max_bytes_total=None,
**options):
"""Create upload URL for POST form.
Args:
success_path: Path within application to call when POST is successful
and upload is complete.
max_... | def create_upload_url(success_path,
max_bytes_per_blob=None,
max_bytes_total=None,
**options):
"""Create upload URL for POST form.
Args:
success_path: Path within application to call when POST is successful
and upload is complete.
max_... | [
"Create",
"upload",
"URL",
"for",
"POST",
"form",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/blobstore.py#L301-L328 | [
"def",
"create_upload_url",
"(",
"success_path",
",",
"max_bytes_per_blob",
"=",
"None",
",",
"max_bytes_total",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"fut",
"=",
"create_upload_url_async",
"(",
"success_path",
",",
"max_bytes_per_blob",
"=",
"max_bytes... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | create_upload_url_async | Async version of create_upload_url(). | ndb/blobstore.py | def create_upload_url_async(success_path,
max_bytes_per_blob=None,
max_bytes_total=None,
**options):
"""Async version of create_upload_url()."""
rpc = blobstore.create_rpc(**options)
rpc = blobstore.create_upload_url_async(success... | def create_upload_url_async(success_path,
max_bytes_per_blob=None,
max_bytes_total=None,
**options):
"""Async version of create_upload_url()."""
rpc = blobstore.create_rpc(**options)
rpc = blobstore.create_upload_url_async(success... | [
"Async",
"version",
"of",
"create_upload_url",
"()",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/blobstore.py#L332-L343 | [
"def",
"create_upload_url_async",
"(",
"success_path",
",",
"max_bytes_per_blob",
"=",
"None",
",",
"max_bytes_total",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"rpc",
"=",
"blobstore",
".",
"create_rpc",
"(",
"*",
"*",
"options",
")",
"rpc",
"=",
"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | parse_blob_info | Parse a BlobInfo record from file upload field_storage.
Args:
field_storage: cgi.FieldStorage that represents uploaded blob.
Returns:
BlobInfo record as parsed from the field-storage instance.
None if there was no field_storage.
Raises:
BlobInfoParseError when provided field_storage does not co... | ndb/blobstore.py | def parse_blob_info(field_storage):
"""Parse a BlobInfo record from file upload field_storage.
Args:
field_storage: cgi.FieldStorage that represents uploaded blob.
Returns:
BlobInfo record as parsed from the field-storage instance.
None if there was no field_storage.
Raises:
BlobInfoParseErro... | def parse_blob_info(field_storage):
"""Parse a BlobInfo record from file upload field_storage.
Args:
field_storage: cgi.FieldStorage that represents uploaded blob.
Returns:
BlobInfo record as parsed from the field-storage instance.
None if there was no field_storage.
Raises:
BlobInfoParseErro... | [
"Parse",
"a",
"BlobInfo",
"record",
"from",
"file",
"upload",
"field_storage",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/blobstore.py#L346-L400 | [
"def",
"parse_blob_info",
"(",
"field_storage",
")",
":",
"if",
"field_storage",
"is",
"None",
":",
"return",
"None",
"field_name",
"=",
"field_storage",
".",
"name",
"def",
"get_value",
"(",
"dct",
",",
"name",
")",
":",
"value",
"=",
"dct",
".",
"get",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | fetch_data | Fetch data for blob.
Fetches a fragment of a blob up to MAX_BLOB_FETCH_SIZE in length. Attempting
to fetch a fragment that extends beyond the boundaries of the blob will return
the amount of data from start_index until the end of the blob, which will be
a smaller size than requested. Requesting a fragment wh... | ndb/blobstore.py | def fetch_data(blob, start_index, end_index, **options):
"""Fetch data for blob.
Fetches a fragment of a blob up to MAX_BLOB_FETCH_SIZE in length. Attempting
to fetch a fragment that extends beyond the boundaries of the blob will return
the amount of data from start_index until the end of the blob, which will... | def fetch_data(blob, start_index, end_index, **options):
"""Fetch data for blob.
Fetches a fragment of a blob up to MAX_BLOB_FETCH_SIZE in length. Attempting
to fetch a fragment that extends beyond the boundaries of the blob will return
the amount of data from start_index until the end of the blob, which will... | [
"Fetch",
"data",
"for",
"blob",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/blobstore.py#L403-L434 | [
"def",
"fetch_data",
"(",
"blob",
",",
"start_index",
",",
"end_index",
",",
"*",
"*",
"options",
")",
":",
"fut",
"=",
"fetch_data_async",
"(",
"blob",
",",
"start_index",
",",
"end_index",
",",
"*",
"*",
"options",
")",
"return",
"fut",
".",
"get_resul... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | fetch_data_async | Async version of fetch_data(). | ndb/blobstore.py | def fetch_data_async(blob, start_index, end_index, **options):
"""Async version of fetch_data()."""
if isinstance(blob, BlobInfo):
blob = blob.key()
rpc = blobstore.create_rpc(**options)
rpc = blobstore.fetch_data_async(blob, start_index, end_index, rpc=rpc)
result = yield rpc
raise tasklets.Return(resu... | def fetch_data_async(blob, start_index, end_index, **options):
"""Async version of fetch_data()."""
if isinstance(blob, BlobInfo):
blob = blob.key()
rpc = blobstore.create_rpc(**options)
rpc = blobstore.fetch_data_async(blob, start_index, end_index, rpc=rpc)
result = yield rpc
raise tasklets.Return(resu... | [
"Async",
"version",
"of",
"fetch_data",
"()",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/blobstore.py#L438-L445 | [
"def",
"fetch_data_async",
"(",
"blob",
",",
"start_index",
",",
"end_index",
",",
"*",
"*",
"options",
")",
":",
"if",
"isinstance",
"(",
"blob",
",",
"BlobInfo",
")",
":",
"blob",
"=",
"blob",
".",
"key",
"(",
")",
"rpc",
"=",
"blobstore",
".",
"cr... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | BlobInfo.get | Retrieve a BlobInfo by key.
Args:
blob_key: A blob key. This may be a str, unicode or BlobKey instance.
**ctx_options: Context options for Model().get_by_id().
Returns:
A BlobInfo entity associated with the provided key, If there was
no such entity, returns None. | ndb/blobstore.py | def get(cls, blob_key, **ctx_options):
"""Retrieve a BlobInfo by key.
Args:
blob_key: A blob key. This may be a str, unicode or BlobKey instance.
**ctx_options: Context options for Model().get_by_id().
Returns:
A BlobInfo entity associated with the provided key, If there was
no s... | def get(cls, blob_key, **ctx_options):
"""Retrieve a BlobInfo by key.
Args:
blob_key: A blob key. This may be a str, unicode or BlobKey instance.
**ctx_options: Context options for Model().get_by_id().
Returns:
A BlobInfo entity associated with the provided key, If there was
no s... | [
"Retrieve",
"a",
"BlobInfo",
"by",
"key",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/blobstore.py#L167-L179 | [
"def",
"get",
"(",
"cls",
",",
"blob_key",
",",
"*",
"*",
"ctx_options",
")",
":",
"fut",
"=",
"cls",
".",
"get_async",
"(",
"blob_key",
",",
"*",
"*",
"ctx_options",
")",
"return",
"fut",
".",
"get_result",
"(",
")"
] | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | BlobInfo.get_async | Async version of get(). | ndb/blobstore.py | def get_async(cls, blob_key, **ctx_options):
"""Async version of get()."""
if not isinstance(blob_key, (BlobKey, basestring)):
raise TypeError('Expected blob key, got %r' % (blob_key,))
if 'parent' in ctx_options:
raise TypeError('Parent is not supported')
return cls.get_by_id_async(str(blob... | def get_async(cls, blob_key, **ctx_options):
"""Async version of get()."""
if not isinstance(blob_key, (BlobKey, basestring)):
raise TypeError('Expected blob key, got %r' % (blob_key,))
if 'parent' in ctx_options:
raise TypeError('Parent is not supported')
return cls.get_by_id_async(str(blob... | [
"Async",
"version",
"of",
"get",
"()",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/blobstore.py#L182-L188 | [
"def",
"get_async",
"(",
"cls",
",",
"blob_key",
",",
"*",
"*",
"ctx_options",
")",
":",
"if",
"not",
"isinstance",
"(",
"blob_key",
",",
"(",
"BlobKey",
",",
"basestring",
")",
")",
":",
"raise",
"TypeError",
"(",
"'Expected blob key, got %r'",
"%",
"(",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | BlobInfo.get_multi | Multi-key version of get().
Args:
blob_keys: A list of blob keys.
**ctx_options: Context options for Model().get_by_id().
Returns:
A list whose items are each either a BlobInfo entity or None. | ndb/blobstore.py | def get_multi(cls, blob_keys, **ctx_options):
"""Multi-key version of get().
Args:
blob_keys: A list of blob keys.
**ctx_options: Context options for Model().get_by_id().
Returns:
A list whose items are each either a BlobInfo entity or None.
"""
futs = cls.get_multi_async(blob_ke... | def get_multi(cls, blob_keys, **ctx_options):
"""Multi-key version of get().
Args:
blob_keys: A list of blob keys.
**ctx_options: Context options for Model().get_by_id().
Returns:
A list whose items are each either a BlobInfo entity or None.
"""
futs = cls.get_multi_async(blob_ke... | [
"Multi",
"-",
"key",
"version",
"of",
"get",
"()",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/blobstore.py#L191-L202 | [
"def",
"get_multi",
"(",
"cls",
",",
"blob_keys",
",",
"*",
"*",
"ctx_options",
")",
":",
"futs",
"=",
"cls",
".",
"get_multi_async",
"(",
"blob_keys",
",",
"*",
"*",
"ctx_options",
")",
"return",
"[",
"fut",
".",
"get_result",
"(",
")",
"for",
"fut",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | BlobInfo.get_multi_async | Async version of get_multi(). | ndb/blobstore.py | def get_multi_async(cls, blob_keys, **ctx_options):
"""Async version of get_multi()."""
for blob_key in blob_keys:
if not isinstance(blob_key, (BlobKey, basestring)):
raise TypeError('Expected blob key, got %r' % (blob_key,))
if 'parent' in ctx_options:
raise TypeError('Parent is not sup... | def get_multi_async(cls, blob_keys, **ctx_options):
"""Async version of get_multi()."""
for blob_key in blob_keys:
if not isinstance(blob_key, (BlobKey, basestring)):
raise TypeError('Expected blob key, got %r' % (blob_key,))
if 'parent' in ctx_options:
raise TypeError('Parent is not sup... | [
"Async",
"version",
"of",
"get_multi",
"()",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/blobstore.py#L205-L214 | [
"def",
"get_multi_async",
"(",
"cls",
",",
"blob_keys",
",",
"*",
"*",
"ctx_options",
")",
":",
"for",
"blob_key",
"in",
"blob_keys",
":",
"if",
"not",
"isinstance",
"(",
"blob_key",
",",
"(",
"BlobKey",
",",
"basestring",
")",
")",
":",
"raise",
"TypeEr... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | BlobInfo.delete | Permanently delete this blob from Blobstore.
Args:
**options: Options for create_rpc(). | ndb/blobstore.py | def delete(self, **options):
"""Permanently delete this blob from Blobstore.
Args:
**options: Options for create_rpc().
"""
fut = delete_async(self.key(), **options)
fut.get_result() | def delete(self, **options):
"""Permanently delete this blob from Blobstore.
Args:
**options: Options for create_rpc().
"""
fut = delete_async(self.key(), **options)
fut.get_result() | [
"Permanently",
"delete",
"this",
"blob",
"from",
"Blobstore",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/blobstore.py#L230-L237 | [
"def",
"delete",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"fut",
"=",
"delete_async",
"(",
"self",
".",
"key",
"(",
")",
",",
"*",
"*",
"options",
")",
"fut",
".",
"get_result",
"(",
")"
] | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | BlobReader.__fill_buffer | Fills the internal buffer.
Args:
size: Number of bytes to read. Will be clamped to
[self.__buffer_size, MAX_BLOB_FETCH_SIZE]. | ndb/blobstore.py | def __fill_buffer(self, size=0):
"""Fills the internal buffer.
Args:
size: Number of bytes to read. Will be clamped to
[self.__buffer_size, MAX_BLOB_FETCH_SIZE].
"""
read_size = min(max(size, self.__buffer_size), MAX_BLOB_FETCH_SIZE)
self.__buffer = fetch_data(self.__blob_key, self._... | def __fill_buffer(self, size=0):
"""Fills the internal buffer.
Args:
size: Number of bytes to read. Will be clamped to
[self.__buffer_size, MAX_BLOB_FETCH_SIZE].
"""
read_size = min(max(size, self.__buffer_size), MAX_BLOB_FETCH_SIZE)
self.__buffer = fetch_data(self.__blob_key, self._... | [
"Fills",
"the",
"internal",
"buffer",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/blobstore.py#L455-L467 | [
"def",
"__fill_buffer",
"(",
"self",
",",
"size",
"=",
"0",
")",
":",
"read_size",
"=",
"min",
"(",
"max",
"(",
"size",
",",
"self",
".",
"__buffer_size",
")",
",",
"MAX_BLOB_FETCH_SIZE",
")",
"self",
".",
"__buffer",
"=",
"fetch_data",
"(",
"self",
".... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | BlobReader.blob_info | Returns the BlobInfo for this file. | ndb/blobstore.py | def blob_info(self):
"""Returns the BlobInfo for this file."""
if not self.__blob_info:
self.__blob_info = BlobInfo.get(self.__blob_key)
return self.__blob_info | def blob_info(self):
"""Returns the BlobInfo for this file."""
if not self.__blob_info:
self.__blob_info = BlobInfo.get(self.__blob_key)
return self.__blob_info | [
"Returns",
"the",
"BlobInfo",
"for",
"this",
"file",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/blobstore.py#L470-L474 | [
"def",
"blob_info",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"__blob_info",
":",
"self",
".",
"__blob_info",
"=",
"BlobInfo",
".",
"get",
"(",
"self",
".",
"__blob_key",
")",
"return",
"self",
".",
"__blob_info"
] | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | make_connection | Create a new Connection object with the right adapter.
Optionally you can pass in a datastore_rpc.Configuration object. | ndb/model.py | def make_connection(config=None, default_model=None,
_api_version=datastore_rpc._DATASTORE_V3,
_id_resolver=None):
"""Create a new Connection object with the right adapter.
Optionally you can pass in a datastore_rpc.Configuration object.
"""
return datastore_rpc.Connecti... | def make_connection(config=None, default_model=None,
_api_version=datastore_rpc._DATASTORE_V3,
_id_resolver=None):
"""Create a new Connection object with the right adapter.
Optionally you can pass in a datastore_rpc.Configuration object.
"""
return datastore_rpc.Connecti... | [
"Create",
"a",
"new",
"Connection",
"object",
"with",
"the",
"right",
"adapter",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L716-L726 | [
"def",
"make_connection",
"(",
"config",
"=",
"None",
",",
"default_model",
"=",
"None",
",",
"_api_version",
"=",
"datastore_rpc",
".",
"_DATASTORE_V3",
",",
"_id_resolver",
"=",
"None",
")",
":",
"return",
"datastore_rpc",
".",
"Connection",
"(",
"adapter",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | _unpack_user | Internal helper to unpack a User value from a protocol buffer. | ndb/model.py | def _unpack_user(v):
"""Internal helper to unpack a User value from a protocol buffer."""
uv = v.uservalue()
email = unicode(uv.email().decode('utf-8'))
auth_domain = unicode(uv.auth_domain().decode('utf-8'))
obfuscated_gaiaid = uv.obfuscated_gaiaid().decode('utf-8')
obfuscated_gaiaid = unicode(obfuscated_g... | def _unpack_user(v):
"""Internal helper to unpack a User value from a protocol buffer."""
uv = v.uservalue()
email = unicode(uv.email().decode('utf-8'))
auth_domain = unicode(uv.auth_domain().decode('utf-8'))
obfuscated_gaiaid = uv.obfuscated_gaiaid().decode('utf-8')
obfuscated_gaiaid = unicode(obfuscated_g... | [
"Internal",
"helper",
"to",
"unpack",
"a",
"User",
"value",
"from",
"a",
"protocol",
"buffer",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L1838-L1855 | [
"def",
"_unpack_user",
"(",
"v",
")",
":",
"uv",
"=",
"v",
".",
"uservalue",
"(",
")",
"email",
"=",
"unicode",
"(",
"uv",
".",
"email",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")",
")",
"auth_domain",
"=",
"unicode",
"(",
"uv",
".",
"auth_domain"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | _date_to_datetime | Convert a date to a datetime for Cloud Datastore storage.
Args:
value: A datetime.date object.
Returns:
A datetime object with time set to 0:00. | ndb/model.py | def _date_to_datetime(value):
"""Convert a date to a datetime for Cloud Datastore storage.
Args:
value: A datetime.date object.
Returns:
A datetime object with time set to 0:00.
"""
if not isinstance(value, datetime.date):
raise TypeError('Cannot convert to datetime expected date value; '
... | def _date_to_datetime(value):
"""Convert a date to a datetime for Cloud Datastore storage.
Args:
value: A datetime.date object.
Returns:
A datetime object with time set to 0:00.
"""
if not isinstance(value, datetime.date):
raise TypeError('Cannot convert to datetime expected date value; '
... | [
"Convert",
"a",
"date",
"to",
"a",
"datetime",
"for",
"Cloud",
"Datastore",
"storage",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L2142-L2154 | [
"def",
"_date_to_datetime",
"(",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"date",
")",
":",
"raise",
"TypeError",
"(",
"'Cannot convert to datetime expected date value; '",
"'received %s'",
"%",
"value",
")",
"return",
"dat... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | _time_to_datetime | Convert a time to a datetime for Cloud Datastore storage.
Args:
value: A datetime.time object.
Returns:
A datetime object with date set to 1970-01-01. | ndb/model.py | def _time_to_datetime(value):
"""Convert a time to a datetime for Cloud Datastore storage.
Args:
value: A datetime.time object.
Returns:
A datetime object with date set to 1970-01-01.
"""
if not isinstance(value, datetime.time):
raise TypeError('Cannot convert to datetime expected time value; '
... | def _time_to_datetime(value):
"""Convert a time to a datetime for Cloud Datastore storage.
Args:
value: A datetime.time object.
Returns:
A datetime object with date set to 1970-01-01.
"""
if not isinstance(value, datetime.time):
raise TypeError('Cannot convert to datetime expected time value; '
... | [
"Convert",
"a",
"time",
"to",
"a",
"datetime",
"for",
"Cloud",
"Datastore",
"storage",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L2157-L2171 | [
"def",
"_time_to_datetime",
"(",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"time",
")",
":",
"raise",
"TypeError",
"(",
"'Cannot convert to datetime expected time value; '",
"'received %s'",
"%",
"value",
")",
"return",
"dat... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | transactional | Decorator to make a function automatically run in a transaction.
Args:
**ctx_options: Transaction options (see transaction(), but propagation
default to TransactionOptions.ALLOWED).
This supports two forms:
(1) Vanilla:
@transactional
def callback(arg):
...
(2) With options:
... | ndb/model.py | def transactional(func, args, kwds, **options):
"""Decorator to make a function automatically run in a transaction.
Args:
**ctx_options: Transaction options (see transaction(), but propagation
default to TransactionOptions.ALLOWED).
This supports two forms:
(1) Vanilla:
@transactional
d... | def transactional(func, args, kwds, **options):
"""Decorator to make a function automatically run in a transaction.
Args:
**ctx_options: Transaction options (see transaction(), but propagation
default to TransactionOptions.ALLOWED).
This supports two forms:
(1) Vanilla:
@transactional
d... | [
"Decorator",
"to",
"make",
"a",
"function",
"automatically",
"run",
"in",
"a",
"transaction",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L3821-L3841 | [
"def",
"transactional",
"(",
"func",
",",
"args",
",",
"kwds",
",",
"*",
"*",
"options",
")",
":",
"return",
"transactional_async",
".",
"wrapped_decorator",
"(",
"func",
",",
"args",
",",
"kwds",
",",
"*",
"*",
"options",
")",
".",
"get_result",
"(",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | transactional_async | The async version of @ndb.transaction. | ndb/model.py | def transactional_async(func, args, kwds, **options):
"""The async version of @ndb.transaction."""
options.setdefault('propagation', datastore_rpc.TransactionOptions.ALLOWED)
if args or kwds:
return transaction_async(lambda: func(*args, **kwds), **options)
return transaction_async(func, **options) | def transactional_async(func, args, kwds, **options):
"""The async version of @ndb.transaction."""
options.setdefault('propagation', datastore_rpc.TransactionOptions.ALLOWED)
if args or kwds:
return transaction_async(lambda: func(*args, **kwds), **options)
return transaction_async(func, **options) | [
"The",
"async",
"version",
"of"
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L3845-L3850 | [
"def",
"transactional_async",
"(",
"func",
",",
"args",
",",
"kwds",
",",
"*",
"*",
"options",
")",
":",
"options",
".",
"setdefault",
"(",
"'propagation'",
",",
"datastore_rpc",
".",
"TransactionOptions",
".",
"ALLOWED",
")",
"if",
"args",
"or",
"kwds",
"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | transactional_tasklet | The async version of @ndb.transaction.
Will return the result of the wrapped function as a Future. | ndb/model.py | def transactional_tasklet(func, args, kwds, **options):
"""The async version of @ndb.transaction.
Will return the result of the wrapped function as a Future.
"""
from . import tasklets
func = tasklets.tasklet(func)
return transactional_async.wrapped_decorator(func, args, kwds, **options) | def transactional_tasklet(func, args, kwds, **options):
"""The async version of @ndb.transaction.
Will return the result of the wrapped function as a Future.
"""
from . import tasklets
func = tasklets.tasklet(func)
return transactional_async.wrapped_decorator(func, args, kwds, **options) | [
"The",
"async",
"version",
"of",
"@ndb",
".",
"transaction",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L3854-L3861 | [
"def",
"transactional_tasklet",
"(",
"func",
",",
"args",
",",
"kwds",
",",
"*",
"*",
"options",
")",
":",
"from",
".",
"import",
"tasklets",
"func",
"=",
"tasklets",
".",
"tasklet",
"(",
"func",
")",
"return",
"transactional_async",
".",
"wrapped_decorator"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | non_transactional | A decorator that ensures a function is run outside a transaction.
If there is an existing transaction (and allow_existing=True), the
existing transaction is paused while the function is executed.
Args:
allow_existing: If false, throw an exception if called from within
a transaction. If true, temporar... | ndb/model.py | def non_transactional(func, args, kwds, allow_existing=True):
"""A decorator that ensures a function is run outside a transaction.
If there is an existing transaction (and allow_existing=True), the
existing transaction is paused while the function is executed.
Args:
allow_existing: If false, throw an exce... | def non_transactional(func, args, kwds, allow_existing=True):
"""A decorator that ensures a function is run outside a transaction.
If there is an existing transaction (and allow_existing=True), the
existing transaction is paused while the function is executed.
Args:
allow_existing: If false, throw an exce... | [
"A",
"decorator",
"that",
"ensures",
"a",
"function",
"is",
"run",
"outside",
"a",
"transaction",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L3865-L3903 | [
"def",
"non_transactional",
"(",
"func",
",",
"args",
",",
"kwds",
",",
"allow_existing",
"=",
"True",
")",
":",
"from",
".",
"import",
"tasklets",
"ctx",
"=",
"tasklets",
".",
"get_context",
"(",
")",
"if",
"not",
"ctx",
".",
"in_transaction",
"(",
")",... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | _NestedCounter._set | Updates all descendants to a specified value. | ndb/model.py | def _set(self, value):
"""Updates all descendants to a specified value."""
if self.__is_parent_node():
for child in self.__sub_counters.itervalues():
child._set(value)
else:
self.__counter = value | def _set(self, value):
"""Updates all descendants to a specified value."""
if self.__is_parent_node():
for child in self.__sub_counters.itervalues():
child._set(value)
else:
self.__counter = value | [
"Updates",
"all",
"descendants",
"to",
"a",
"specified",
"value",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L487-L493 | [
"def",
"_set",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"__is_parent_node",
"(",
")",
":",
"for",
"child",
"in",
"self",
".",
"__sub_counters",
".",
"itervalues",
"(",
")",
":",
"child",
".",
"_set",
"(",
"value",
")",
"else",
":",
"... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Property._comparison | Internal helper for comparison operators.
Args:
op: The operator ('=', '<' etc.).
Returns:
A FilterNode instance representing the requested comparison. | ndb/model.py | def _comparison(self, op, value):
"""Internal helper for comparison operators.
Args:
op: The operator ('=', '<' etc.).
Returns:
A FilterNode instance representing the requested comparison.
"""
# NOTE: This is also used by query.gql().
if not self._indexed:
raise datastore_err... | def _comparison(self, op, value):
"""Internal helper for comparison operators.
Args:
op: The operator ('=', '<' etc.).
Returns:
A FilterNode instance representing the requested comparison.
"""
# NOTE: This is also used by query.gql().
if not self._indexed:
raise datastore_err... | [
"Internal",
"helper",
"for",
"comparison",
"operators",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L972-L990 | [
"def",
"_comparison",
"(",
"self",
",",
"op",
",",
"value",
")",
":",
"# NOTE: This is also used by query.gql().",
"if",
"not",
"self",
".",
"_indexed",
":",
"raise",
"datastore_errors",
".",
"BadFilterError",
"(",
"'Cannot query for unindexed property %s'",
"%",
"sel... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Property._IN | Comparison operator for the 'in' comparison operator.
The Python 'in' operator cannot be overloaded in the way we want
to, so we define a method. For example::
Employee.query(Employee.rank.IN([4, 5, 6]))
Note that the method is called ._IN() but may normally be invoked
as .IN(); ._IN() is prov... | ndb/model.py | def _IN(self, value):
"""Comparison operator for the 'in' comparison operator.
The Python 'in' operator cannot be overloaded in the way we want
to, so we define a method. For example::
Employee.query(Employee.rank.IN([4, 5, 6]))
Note that the method is called ._IN() but may normally be invoked... | def _IN(self, value):
"""Comparison operator for the 'in' comparison operator.
The Python 'in' operator cannot be overloaded in the way we want
to, so we define a method. For example::
Employee.query(Employee.rank.IN([4, 5, 6]))
Note that the method is called ._IN() but may normally be invoked... | [
"Comparison",
"operator",
"for",
"the",
"in",
"comparison",
"operator",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L1022-L1048 | [
"def",
"_IN",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"_indexed",
":",
"raise",
"datastore_errors",
".",
"BadFilterError",
"(",
"'Cannot query for unindexed property %s'",
"%",
"self",
".",
"_name",
")",
"from",
".",
"query",
"import",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Property._do_validate | Call all validations on the value.
This calls the most derived _validate() method(s), then the custom
validator function, and then checks the choices. It returns the
value, possibly modified in an idempotent way, or raises an
exception.
Note that this does not call all composable _validate() meth... | ndb/model.py | def _do_validate(self, value):
"""Call all validations on the value.
This calls the most derived _validate() method(s), then the custom
validator function, and then checks the choices. It returns the
value, possibly modified in an idempotent way, or raises an
exception.
Note that this does no... | def _do_validate(self, value):
"""Call all validations on the value.
This calls the most derived _validate() method(s), then the custom
validator function, and then checks the choices. It returns the
value, possibly modified in an idempotent way, or raises an
exception.
Note that this does no... | [
"Call",
"all",
"validations",
"on",
"the",
"value",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L1072-L1102 | [
"def",
"_do_validate",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"_BaseValue",
")",
":",
"return",
"value",
"value",
"=",
"self",
".",
"_call_shallow_validation",
"(",
"value",
")",
"if",
"self",
".",
"_validator",
"is",
... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Property._fix_up | Internal helper called to tell the property its name.
This is called by _fix_up_properties() which is called by
MetaModel when finishing the construction of a Model subclass.
The name passed in is the name of the class attribute to which the
Property is assigned (a.k.a. the code name). Note that this ... | ndb/model.py | def _fix_up(self, cls, code_name):
"""Internal helper called to tell the property its name.
This is called by _fix_up_properties() which is called by
MetaModel when finishing the construction of a Model subclass.
The name passed in is the name of the class attribute to which the
Property is assigne... | def _fix_up(self, cls, code_name):
"""Internal helper called to tell the property its name.
This is called by _fix_up_properties() which is called by
MetaModel when finishing the construction of a Model subclass.
The name passed in is the name of the class attribute to which the
Property is assigne... | [
"Internal",
"helper",
"called",
"to",
"tell",
"the",
"property",
"its",
"name",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L1104-L1119 | [
"def",
"_fix_up",
"(",
"self",
",",
"cls",
",",
"code_name",
")",
":",
"self",
".",
"_code_name",
"=",
"code_name",
"if",
"self",
".",
"_name",
"is",
"None",
":",
"self",
".",
"_name",
"=",
"code_name"
] | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
train | Property._set_value | Internal helper to set a value in an entity for a Property.
This performs validation first. For a repeated Property the value
should be a list. | ndb/model.py | def _set_value(self, entity, value):
"""Internal helper to set a value in an entity for a Property.
This performs validation first. For a repeated Property the value
should be a list.
"""
if entity._projection:
raise ReadonlyPropertyError(
'You cannot set property values of a proje... | def _set_value(self, entity, value):
"""Internal helper to set a value in an entity for a Property.
This performs validation first. For a repeated Property the value
should be a list.
"""
if entity._projection:
raise ReadonlyPropertyError(
'You cannot set property values of a proje... | [
"Internal",
"helper",
"to",
"set",
"a",
"value",
"in",
"an",
"entity",
"for",
"a",
"Property",
"."
] | GoogleCloudPlatform/datastore-ndb-python | python | https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/model.py#L1129-L1146 | [
"def",
"_set_value",
"(",
"self",
",",
"entity",
",",
"value",
")",
":",
"if",
"entity",
".",
"_projection",
":",
"raise",
"ReadonlyPropertyError",
"(",
"'You cannot set property values of a projection entity'",
")",
"if",
"self",
".",
"_repeated",
":",
"if",
"not... | cf4cab3f1f69cd04e1a9229871be466b53729f3f |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.