repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
couchbase/couchbase-python-client | couchbase/admin.py | Admin.wait_ready | def wait_ready(self, name, timeout=5.0, sleep_interval=0.2):
"""
Wait for a newly created bucket to be ready.
:param string name: the name to wait for
:param seconds timeout: the maximum amount of time to wait
:param seconds sleep_interval: the number of time to sleep
... | python | def wait_ready(self, name, timeout=5.0, sleep_interval=0.2):
"""
Wait for a newly created bucket to be ready.
:param string name: the name to wait for
:param seconds timeout: the maximum amount of time to wait
:param seconds sleep_interval: the number of time to sleep
... | [
"def",
"wait_ready",
"(",
"self",
",",
"name",
",",
"timeout",
"=",
"5.0",
",",
"sleep_interval",
"=",
"0.2",
")",
":",
"end",
"=",
"time",
"(",
")",
"+",
"timeout",
"while",
"True",
":",
"try",
":",
"info",
"=",
"self",
".",
"bucket_info",
"(",
"n... | Wait for a newly created bucket to be ready.
:param string name: the name to wait for
:param seconds timeout: the maximum amount of time to wait
:param seconds sleep_interval: the number of time to sleep
between each probe
:raise: :exc:`.CouchbaseError` on internal HTTP erro... | [
"Wait",
"for",
"a",
"newly",
"created",
"bucket",
"to",
"be",
"ready",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/admin.py#L241-L264 | train |
couchbase/couchbase-python-client | couchbase/admin.py | Admin.bucket_update | def bucket_update(self, name, current, bucket_password=None, replicas=None,
ram_quota=None, flush_enabled=None):
"""
Update an existing bucket's settings.
:param string name: The name of the bucket to update
:param dict current: Current state of the bucket.
... | python | def bucket_update(self, name, current, bucket_password=None, replicas=None,
ram_quota=None, flush_enabled=None):
"""
Update an existing bucket's settings.
:param string name: The name of the bucket to update
:param dict current: Current state of the bucket.
... | [
"def",
"bucket_update",
"(",
"self",
",",
"name",
",",
"current",
",",
"bucket_password",
"=",
"None",
",",
"replicas",
"=",
"None",
",",
"ram_quota",
"=",
"None",
",",
"flush_enabled",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"current",
"=",
"c... | Update an existing bucket's settings.
:param string name: The name of the bucket to update
:param dict current: Current state of the bucket.
This can be retrieve from :meth:`bucket_info`
:param str bucket_password: Change the bucket's password
:param int replicas: The number... | [
"Update",
"an",
"existing",
"bucket",
"s",
"settings",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/admin.py#L266-L329 | train |
couchbase/couchbase-python-client | couchbase/admin.py | Admin.users_get | def users_get(self, domain):
"""
Retrieve a list of users from the server.
:param AuthDomain domain: The authentication domain to retrieve users from.
:return: :class:`~.HttpResult`. The list of users can be obtained from
the returned object's `value` property.
"""
... | python | def users_get(self, domain):
"""
Retrieve a list of users from the server.
:param AuthDomain domain: The authentication domain to retrieve users from.
:return: :class:`~.HttpResult`. The list of users can be obtained from
the returned object's `value` property.
"""
... | [
"def",
"users_get",
"(",
"self",
",",
"domain",
")",
":",
"path",
"=",
"self",
".",
"_get_management_path",
"(",
"domain",
")",
"return",
"self",
".",
"http_request",
"(",
"path",
"=",
"path",
",",
"method",
"=",
"'GET'",
")"
] | Retrieve a list of users from the server.
:param AuthDomain domain: The authentication domain to retrieve users from.
:return: :class:`~.HttpResult`. The list of users can be obtained from
the returned object's `value` property. | [
"Retrieve",
"a",
"list",
"of",
"users",
"from",
"the",
"server",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/admin.py#L347-L357 | train |
couchbase/couchbase-python-client | couchbase/admin.py | Admin.user_get | def user_get(self, domain, userid):
"""
Retrieve a user from the server
:param AuthDomain domain: The authentication domain for the user.
:param userid: The user ID.
:raise: :exc:`couchbase.exceptions.HTTPError` if the user does not exist.
:return: :class:`~.HttpResult`.... | python | def user_get(self, domain, userid):
"""
Retrieve a user from the server
:param AuthDomain domain: The authentication domain for the user.
:param userid: The user ID.
:raise: :exc:`couchbase.exceptions.HTTPError` if the user does not exist.
:return: :class:`~.HttpResult`.... | [
"def",
"user_get",
"(",
"self",
",",
"domain",
",",
"userid",
")",
":",
"path",
"=",
"self",
".",
"_get_management_path",
"(",
"domain",
",",
"userid",
")",
"return",
"self",
".",
"http_request",
"(",
"path",
"=",
"path",
",",
"method",
"=",
"'GET'",
"... | Retrieve a user from the server
:param AuthDomain domain: The authentication domain for the user.
:param userid: The user ID.
:raise: :exc:`couchbase.exceptions.HTTPError` if the user does not exist.
:return: :class:`~.HttpResult`. The user can be obtained from the
returned ... | [
"Retrieve",
"a",
"user",
"from",
"the",
"server"
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/admin.py#L359-L371 | train |
couchbase/couchbase-python-client | couchbase/admin.py | Admin.user_upsert | def user_upsert(self, domain, userid, password=None, roles=None, name=None):
"""
Upsert a user in the cluster
:param AuthDomain domain: The authentication domain for the user.
:param userid: The user ID
:param password: The user password
:param roles: A list of roles. A ... | python | def user_upsert(self, domain, userid, password=None, roles=None, name=None):
"""
Upsert a user in the cluster
:param AuthDomain domain: The authentication domain for the user.
:param userid: The user ID
:param password: The user password
:param roles: A list of roles. A ... | [
"def",
"user_upsert",
"(",
"self",
",",
"domain",
",",
"userid",
",",
"password",
"=",
"None",
",",
"roles",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"if",
"not",
"roles",
"or",
"not",
"isinstance",
"(",
"roles",
",",
"list",
")",
":",
"rai... | Upsert a user in the cluster
:param AuthDomain domain: The authentication domain for the user.
:param userid: The user ID
:param password: The user password
:param roles: A list of roles. A role can either be a simple string,
or a list of `(role, bucket)` pairs.
:par... | [
"Upsert",
"a",
"user",
"in",
"the",
"cluster"
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/admin.py#L373-L429 | train |
couchbase/couchbase-python-client | couchbase/connstr.py | convert_1x_args | def convert_1x_args(bucket, **kwargs):
"""
Converts arguments for 1.x constructors to their 2.x forms
"""
host = kwargs.pop('host', 'localhost')
port = kwargs.pop('port', None)
if not 'connstr' in kwargs and 'connection_string' not in kwargs:
kwargs['connection_string'] = _build_connstr(... | python | def convert_1x_args(bucket, **kwargs):
"""
Converts arguments for 1.x constructors to their 2.x forms
"""
host = kwargs.pop('host', 'localhost')
port = kwargs.pop('port', None)
if not 'connstr' in kwargs and 'connection_string' not in kwargs:
kwargs['connection_string'] = _build_connstr(... | [
"def",
"convert_1x_args",
"(",
"bucket",
",",
"**",
"kwargs",
")",
":",
"host",
"=",
"kwargs",
".",
"pop",
"(",
"'host'",
",",
"'localhost'",
")",
"port",
"=",
"kwargs",
".",
"pop",
"(",
"'port'",
",",
"None",
")",
"if",
"not",
"'connstr'",
"in",
"kw... | Converts arguments for 1.x constructors to their 2.x forms | [
"Converts",
"arguments",
"for",
"1",
".",
"x",
"constructors",
"to",
"their",
"2",
".",
"x",
"forms"
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/connstr.py#L173-L181 | train |
couchbase/couchbase-python-client | couchbase/connstr.py | ConnectionString.parse | def parse(cls, ss):
"""
Parses an existing connection string
This method will return a :class:`~.ConnectionString` object
which will allow further inspection on the input parameters.
:param string ss: The existing connection string
:return: A new :class:`~.ConnectionStr... | python | def parse(cls, ss):
"""
Parses an existing connection string
This method will return a :class:`~.ConnectionString` object
which will allow further inspection on the input parameters.
:param string ss: The existing connection string
:return: A new :class:`~.ConnectionStr... | [
"def",
"parse",
"(",
"cls",
",",
"ss",
")",
":",
"up",
"=",
"urlparse",
"(",
"ss",
")",
"path",
"=",
"up",
".",
"path",
"query",
"=",
"up",
".",
"query",
"if",
"'?'",
"in",
"path",
":",
"path",
",",
"_",
"=",
"up",
".",
"path",
".",
"split",
... | Parses an existing connection string
This method will return a :class:`~.ConnectionString` object
which will allow further inspection on the input parameters.
:param string ss: The existing connection string
:return: A new :class:`~.ConnectionString` object | [
"Parses",
"an",
"existing",
"connection",
"string"
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/connstr.py#L76-L101 | train |
couchbase/couchbase-python-client | couchbase/connstr.py | ConnectionString.encode | def encode(self):
"""
Encodes the current state of the object into a string.
:return: The encoded string
"""
opt_dict = {}
for k, v in self.options.items():
opt_dict[k] = v[0]
ss = '{0}://{1}'.format(self.scheme, ','.join(self.hosts))
if self... | python | def encode(self):
"""
Encodes the current state of the object into a string.
:return: The encoded string
"""
opt_dict = {}
for k, v in self.options.items():
opt_dict[k] = v[0]
ss = '{0}://{1}'.format(self.scheme, ','.join(self.hosts))
if self... | [
"def",
"encode",
"(",
"self",
")",
":",
"opt_dict",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"self",
".",
"options",
".",
"items",
"(",
")",
":",
"opt_dict",
"[",
"k",
"]",
"=",
"v",
"[",
"0",
"]",
"ss",
"=",
"'{0}://{1}'",
".",
"format",
"... | Encodes the current state of the object into a string.
:return: The encoded string | [
"Encodes",
"the",
"current",
"state",
"of",
"the",
"object",
"into",
"a",
"string",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/connstr.py#L126-L143 | train |
couchbase/couchbase-python-client | couchbase/exceptions.py | CouchbaseError.rc_to_exctype | def rc_to_exctype(cls, rc):
"""
Map an error code to an exception
:param int rc: The error code received for an operation
:return: a subclass of :class:`CouchbaseError`
"""
try:
return _LCB_ERRNO_MAP[rc]
except KeyError:
newcls = _mk_lcbe... | python | def rc_to_exctype(cls, rc):
"""
Map an error code to an exception
:param int rc: The error code received for an operation
:return: a subclass of :class:`CouchbaseError`
"""
try:
return _LCB_ERRNO_MAP[rc]
except KeyError:
newcls = _mk_lcbe... | [
"def",
"rc_to_exctype",
"(",
"cls",
",",
"rc",
")",
":",
"try",
":",
"return",
"_LCB_ERRNO_MAP",
"[",
"rc",
"]",
"except",
"KeyError",
":",
"newcls",
"=",
"_mk_lcberr",
"(",
"rc",
")",
"_LCB_ERRNO_MAP",
"[",
"rc",
"]",
"=",
"newcls",
"return",
"newcls"
] | Map an error code to an exception
:param int rc: The error code received for an operation
:return: a subclass of :class:`CouchbaseError` | [
"Map",
"an",
"error",
"code",
"to",
"an",
"exception"
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/exceptions.py#L91-L104 | train |
couchbase/couchbase-python-client | couchbase/exceptions.py | CouchbaseError.split_results | def split_results(self):
"""
Convenience method to separate failed and successful results.
.. versionadded:: 2.0.0
This function will split the results of the failed operation
(see :attr:`.all_results`) into "good" and "bad" dictionaries.
The intent is for the applicat... | python | def split_results(self):
"""
Convenience method to separate failed and successful results.
.. versionadded:: 2.0.0
This function will split the results of the failed operation
(see :attr:`.all_results`) into "good" and "bad" dictionaries.
The intent is for the applicat... | [
"def",
"split_results",
"(",
"self",
")",
":",
"ret_ok",
",",
"ret_fail",
"=",
"{",
"}",
",",
"{",
"}",
"count",
"=",
"0",
"nokey_prefix",
"=",
"(",
"[",
"\"\"",
"]",
"+",
"sorted",
"(",
"filter",
"(",
"bool",
",",
"self",
".",
"all_results",
".",
... | Convenience method to separate failed and successful results.
.. versionadded:: 2.0.0
This function will split the results of the failed operation
(see :attr:`.all_results`) into "good" and "bad" dictionaries.
The intent is for the application to handle any successful
results ... | [
"Convenience",
"method",
"to",
"separate",
"failed",
"and",
"successful",
"results",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/exceptions.py#L162-L209 | train |
couchbase/couchbase-python-client | couchbase/items.py | ItemOptionDict.add | def add(self, itm, **options):
"""
Convenience method to add an item together with a series of options.
:param itm: The item to add
:param options: keyword arguments which will be placed in the item's
option entry.
If the item already exists, it (and its options) wi... | python | def add(self, itm, **options):
"""
Convenience method to add an item together with a series of options.
:param itm: The item to add
:param options: keyword arguments which will be placed in the item's
option entry.
If the item already exists, it (and its options) wi... | [
"def",
"add",
"(",
"self",
",",
"itm",
",",
"**",
"options",
")",
":",
"if",
"not",
"options",
":",
"options",
"=",
"None",
"self",
".",
"_d",
"[",
"itm",
"]",
"=",
"options"
] | Convenience method to add an item together with a series of options.
:param itm: The item to add
:param options: keyword arguments which will be placed in the item's
option entry.
If the item already exists, it (and its options) will be overidden. Use
:attr:`dict` instead t... | [
"Convenience",
"method",
"to",
"add",
"an",
"item",
"together",
"with",
"a",
"series",
"of",
"options",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/items.py#L144-L158 | train |
couchbase/couchbase-python-client | couchbase/deprecation.py | deprecate_module_attribute | def deprecate_module_attribute(mod, deprecated):
"""Return a wrapped object that warns about deprecated accesses"""
deprecated = set(deprecated)
class Wrapper(object):
def __getattr__(self, attr):
if attr in deprecated:
warnings.warn("Property %s is deprecated" % attr)
... | python | def deprecate_module_attribute(mod, deprecated):
"""Return a wrapped object that warns about deprecated accesses"""
deprecated = set(deprecated)
class Wrapper(object):
def __getattr__(self, attr):
if attr in deprecated:
warnings.warn("Property %s is deprecated" % attr)
... | [
"def",
"deprecate_module_attribute",
"(",
"mod",
",",
"deprecated",
")",
":",
"deprecated",
"=",
"set",
"(",
"deprecated",
")",
"class",
"Wrapper",
"(",
"object",
")",
":",
"def",
"__getattr__",
"(",
"self",
",",
"attr",
")",
":",
"if",
"attr",
"in",
"de... | Return a wrapped object that warns about deprecated accesses | [
"Return",
"a",
"wrapped",
"object",
"that",
"warns",
"about",
"deprecated",
"accesses"
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/deprecation.py#L4-L19 | train |
couchbase/couchbase-python-client | couchbase/result.py | SubdocResult.get | def get(self, path_or_index, default=None):
"""
Get details about a given result
:param path_or_index: The path (or index) of the result to fetch.
:param default: If the given result does not exist, return this value
instead
:return: A tuple of `(error, value)`. If t... | python | def get(self, path_or_index, default=None):
"""
Get details about a given result
:param path_or_index: The path (or index) of the result to fetch.
:param default: If the given result does not exist, return this value
instead
:return: A tuple of `(error, value)`. If t... | [
"def",
"get",
"(",
"self",
",",
"path_or_index",
",",
"default",
"=",
"None",
")",
":",
"err",
",",
"value",
"=",
"self",
".",
"_resolve",
"(",
"path_or_index",
")",
"value",
"=",
"default",
"if",
"err",
"else",
"value",
"return",
"err",
",",
"value"
] | Get details about a given result
:param path_or_index: The path (or index) of the result to fetch.
:param default: If the given result does not exist, return this value
instead
:return: A tuple of `(error, value)`. If the entry does not exist
then `(err, default)` is ret... | [
"Get",
"details",
"about",
"a",
"given",
"result"
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/result.py#L115-L133 | train |
couchbase/couchbase-python-client | couchbase/asynchronous/bucket.py | AsyncBucket.query | def query(self, *args, **kwargs):
"""
Reimplemented from base class.
This method does not add additional functionality of the
base class' :meth:`~couchbase.bucket.Bucket.query` method (all the
functionality is encapsulated in the view class anyway). However it
does requi... | python | def query(self, *args, **kwargs):
"""
Reimplemented from base class.
This method does not add additional functionality of the
base class' :meth:`~couchbase.bucket.Bucket.query` method (all the
functionality is encapsulated in the view class anyway). However it
does requi... | [
"def",
"query",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"issubclass",
"(",
"kwargs",
".",
"get",
"(",
"'itercls'",
",",
"None",
")",
",",
"AsyncViewBase",
")",
":",
"raise",
"ArgumentError",
".",
"pyexc",
"(",
"\"it... | Reimplemented from base class.
This method does not add additional functionality of the
base class' :meth:`~couchbase.bucket.Bucket.query` method (all the
functionality is encapsulated in the view class anyway). However it
does require one additional keyword argument
:param cla... | [
"Reimplemented",
"from",
"base",
"class",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/asynchronous/bucket.py#L154-L171 | train |
couchbase/couchbase-python-client | couchbase/subdocument.py | _gen_3spec | def _gen_3spec(op, path, xattr=False):
"""
Returns a Spec tuple suitable for passing to the underlying C extension.
This variant is called for operations that lack an input value.
:param str path: The path to fetch
:param bool xattr: Whether this is an extended attribute
:return: a spec suitabl... | python | def _gen_3spec(op, path, xattr=False):
"""
Returns a Spec tuple suitable for passing to the underlying C extension.
This variant is called for operations that lack an input value.
:param str path: The path to fetch
:param bool xattr: Whether this is an extended attribute
:return: a spec suitabl... | [
"def",
"_gen_3spec",
"(",
"op",
",",
"path",
",",
"xattr",
"=",
"False",
")",
":",
"flags",
"=",
"0",
"if",
"xattr",
":",
"flags",
"|=",
"_P",
".",
"SDSPEC_F_XATTR",
"return",
"Spec",
"(",
"op",
",",
"path",
",",
"flags",
")"
] | Returns a Spec tuple suitable for passing to the underlying C extension.
This variant is called for operations that lack an input value.
:param str path: The path to fetch
:param bool xattr: Whether this is an extended attribute
:return: a spec suitable for passing to the underlying C extension | [
"Returns",
"a",
"Spec",
"tuple",
"suitable",
"for",
"passing",
"to",
"the",
"underlying",
"C",
"extension",
".",
"This",
"variant",
"is",
"called",
"for",
"operations",
"that",
"lack",
"an",
"input",
"value",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/subdocument.py#L34-L46 | train |
couchbase/couchbase-python-client | couchbase/subdocument.py | upsert | def upsert(path, value, create_parents=False, **kwargs):
"""
Create or replace a dictionary path.
:param path: The path to modify
:param value: The new value for the path. This should be a native Python
object which can be encoded into JSON (the SDK will do the encoding
for you).
:p... | python | def upsert(path, value, create_parents=False, **kwargs):
"""
Create or replace a dictionary path.
:param path: The path to modify
:param value: The new value for the path. This should be a native Python
object which can be encoded into JSON (the SDK will do the encoding
for you).
:p... | [
"def",
"upsert",
"(",
"path",
",",
"value",
",",
"create_parents",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"return",
"_gen_4spec",
"(",
"LCB_SDCMD_DICT_UPSERT",
",",
"path",
",",
"value",
",",
"create_path",
"=",
"create_parents",
",",
"**",
"kwargs",
... | Create or replace a dictionary path.
:param path: The path to modify
:param value: The new value for the path. This should be a native Python
object which can be encoded into JSON (the SDK will do the encoding
for you).
:param create_parents: Whether intermediate parents should be created.
... | [
"Create",
"or",
"replace",
"a",
"dictionary",
"path",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/subdocument.py#L100-L129 | train |
couchbase/couchbase-python-client | couchbase/subdocument.py | array_append | def array_append(path, *values, **kwargs):
"""
Add new values to the end of an array.
:param path: Path to the array. The path should contain the *array itself*
and not an element *within* the array
:param values: one or more values to append
:param create_parents: Create the array if it do... | python | def array_append(path, *values, **kwargs):
"""
Add new values to the end of an array.
:param path: Path to the array. The path should contain the *array itself*
and not an element *within* the array
:param values: one or more values to append
:param create_parents: Create the array if it do... | [
"def",
"array_append",
"(",
"path",
",",
"*",
"values",
",",
"**",
"kwargs",
")",
":",
"return",
"_gen_4spec",
"(",
"LCB_SDCMD_ARRAY_ADD_LAST",
",",
"path",
",",
"MultiValue",
"(",
"*",
"values",
")",
",",
"create_path",
"=",
"kwargs",
".",
"pop",
"(",
"... | Add new values to the end of an array.
:param path: Path to the array. The path should contain the *array itself*
and not an element *within* the array
:param values: one or more values to append
:param create_parents: Create the array if it does not exist
.. note::
Specifying multipl... | [
"Add",
"new",
"values",
"to",
"the",
"end",
"of",
"an",
"array",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/subdocument.py#L157-L181 | train |
couchbase/couchbase-python-client | couchbase/subdocument.py | array_prepend | def array_prepend(path, *values, **kwargs):
"""
Add new values to the beginning of an array.
:param path: Path to the array. The path should contain the *array itself*
and not an element *within* the array
:param values: one or more values to append
:param create_parents: Create the array i... | python | def array_prepend(path, *values, **kwargs):
"""
Add new values to the beginning of an array.
:param path: Path to the array. The path should contain the *array itself*
and not an element *within* the array
:param values: one or more values to append
:param create_parents: Create the array i... | [
"def",
"array_prepend",
"(",
"path",
",",
"*",
"values",
",",
"**",
"kwargs",
")",
":",
"return",
"_gen_4spec",
"(",
"LCB_SDCMD_ARRAY_ADD_FIRST",
",",
"path",
",",
"MultiValue",
"(",
"*",
"values",
")",
",",
"create_path",
"=",
"kwargs",
".",
"pop",
"(",
... | Add new values to the beginning of an array.
:param path: Path to the array. The path should contain the *array itself*
and not an element *within* the array
:param values: one or more values to append
:param create_parents: Create the array if it does not exist
This operation is only valid in... | [
"Add",
"new",
"values",
"to",
"the",
"beginning",
"of",
"an",
"array",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/subdocument.py#L184-L200 | train |
couchbase/couchbase-python-client | couchbase/subdocument.py | array_insert | def array_insert(path, *values, **kwargs):
"""
Insert items at a given position within an array.
:param path: The path indicating where the item should be placed. The path
_should_ contain the desired position
:param values: Values to insert
This operation is only valid in :cb_bmeth:`mutat... | python | def array_insert(path, *values, **kwargs):
"""
Insert items at a given position within an array.
:param path: The path indicating where the item should be placed. The path
_should_ contain the desired position
:param values: Values to insert
This operation is only valid in :cb_bmeth:`mutat... | [
"def",
"array_insert",
"(",
"path",
",",
"*",
"values",
",",
"**",
"kwargs",
")",
":",
"return",
"_gen_4spec",
"(",
"LCB_SDCMD_ARRAY_INSERT",
",",
"path",
",",
"MultiValue",
"(",
"*",
"values",
")",
",",
"**",
"kwargs",
")"
] | Insert items at a given position within an array.
:param path: The path indicating where the item should be placed. The path
_should_ contain the desired position
:param values: Values to insert
This operation is only valid in :cb_bmeth:`mutate_in`.
.. seealso:: :func:`array_prepend`, :func:`... | [
"Insert",
"items",
"at",
"a",
"given",
"position",
"within",
"an",
"array",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/subdocument.py#L203-L216 | train |
couchbase/couchbase-python-client | couchbase/subdocument.py | array_addunique | def array_addunique(path, value, create_parents=False, **kwargs):
"""
Add a new value to an array if the value does not exist.
:param path: The path to the array
:param value: Value to add to the array if it does not exist.
Currently the value is restricted to primitives: strings, numbers,
... | python | def array_addunique(path, value, create_parents=False, **kwargs):
"""
Add a new value to an array if the value does not exist.
:param path: The path to the array
:param value: Value to add to the array if it does not exist.
Currently the value is restricted to primitives: strings, numbers,
... | [
"def",
"array_addunique",
"(",
"path",
",",
"value",
",",
"create_parents",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"return",
"_gen_4spec",
"(",
"LCB_SDCMD_ARRAY_ADD_UNIQUE",
",",
"path",
",",
"value",
",",
"create_path",
"=",
"create_parents",
",",
"**",... | Add a new value to an array if the value does not exist.
:param path: The path to the array
:param value: Value to add to the array if it does not exist.
Currently the value is restricted to primitives: strings, numbers,
booleans, and `None` values.
:param create_parents: Create the array i... | [
"Add",
"a",
"new",
"value",
"to",
"an",
"array",
"if",
"the",
"value",
"does",
"not",
"exist",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/subdocument.py#L219-L240 | train |
couchbase/couchbase-python-client | couchbase/subdocument.py | counter | def counter(path, delta, create_parents=False, **kwargs):
"""
Increment or decrement a counter in a document.
:param path: Path to the counter
:param delta: Amount by which to modify the value. The delta
can be negative but not 0. It must be an integer (not a float)
as well.
:param ... | python | def counter(path, delta, create_parents=False, **kwargs):
"""
Increment or decrement a counter in a document.
:param path: Path to the counter
:param delta: Amount by which to modify the value. The delta
can be negative but not 0. It must be an integer (not a float)
as well.
:param ... | [
"def",
"counter",
"(",
"path",
",",
"delta",
",",
"create_parents",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"delta",
":",
"raise",
"ValueError",
"(",
"\"Delta must be positive or negative!\"",
")",
"return",
"_gen_4spec",
"(",
"LCB_SDCMD_COUNTE... | Increment or decrement a counter in a document.
:param path: Path to the counter
:param delta: Amount by which to modify the value. The delta
can be negative but not 0. It must be an integer (not a float)
as well.
:param create_parents: Create the counter (and apply the modification) if it
... | [
"Increment",
"or",
"decrement",
"a",
"counter",
"in",
"a",
"document",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/subdocument.py#L243-L268 | train |
couchbase/couchbase-python-client | couchbase/mutation_state.py | MutationState.add_results | def add_results(self, *rvs, **kwargs):
"""
Changes the state to reflect the mutation which yielded the given
result.
In order to use the result, the `fetch_mutation_tokens` option must
have been specified in the connection string, _and_ the result
must have been successf... | python | def add_results(self, *rvs, **kwargs):
"""
Changes the state to reflect the mutation which yielded the given
result.
In order to use the result, the `fetch_mutation_tokens` option must
have been specified in the connection string, _and_ the result
must have been successf... | [
"def",
"add_results",
"(",
"self",
",",
"*",
"rvs",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"rvs",
":",
"raise",
"MissingTokenError",
".",
"pyexc",
"(",
"message",
"=",
"'No results passed'",
")",
"for",
"rv",
"in",
"rvs",
":",
"mi",
"=",
"rv",
"... | Changes the state to reflect the mutation which yielded the given
result.
In order to use the result, the `fetch_mutation_tokens` option must
have been specified in the connection string, _and_ the result
must have been successful.
:param rvs: One or more :class:`~.OperationRes... | [
"Changes",
"the",
"state",
"to",
"reflect",
"the",
"mutation",
"which",
"yielded",
"the",
"given",
"result",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/mutation_state.py#L111-L139 | train |
couchbase/couchbase-python-client | couchbase/mutation_state.py | MutationState.add_all | def add_all(self, bucket, quiet=False):
"""
Ensures the query result is consistent with all prior
mutations performed by a given bucket.
Using this function is equivalent to keeping track of all
mutations performed by the given bucket, and passing them to
:meth:`~add_res... | python | def add_all(self, bucket, quiet=False):
"""
Ensures the query result is consistent with all prior
mutations performed by a given bucket.
Using this function is equivalent to keeping track of all
mutations performed by the given bucket, and passing them to
:meth:`~add_res... | [
"def",
"add_all",
"(",
"self",
",",
"bucket",
",",
"quiet",
"=",
"False",
")",
":",
"added",
"=",
"False",
"for",
"mt",
"in",
"bucket",
".",
"_mutinfo",
"(",
")",
":",
"added",
"=",
"True",
"self",
".",
"_add_scanvec",
"(",
"mt",
")",
"if",
"not",
... | Ensures the query result is consistent with all prior
mutations performed by a given bucket.
Using this function is equivalent to keeping track of all
mutations performed by the given bucket, and passing them to
:meth:`~add_result`
:param bucket: A :class:`~couchbase.bucket.Buc... | [
"Ensures",
"the",
"query",
"result",
"is",
"consistent",
"with",
"all",
"prior",
"mutations",
"performed",
"by",
"a",
"given",
"bucket",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/mutation_state.py#L141-L165 | train |
couchbase/couchbase-python-client | couchbase/fulltext.py | _assign_kwargs | def _assign_kwargs(self, kwargs):
"""
Assigns all keyword arguments to a given instance, raising an exception
if one of the keywords is not already the name of a property.
"""
for k in kwargs:
if not hasattr(self, k):
raise AttributeError(k, 'Not valid for', self.__class__.__name... | python | def _assign_kwargs(self, kwargs):
"""
Assigns all keyword arguments to a given instance, raising an exception
if one of the keywords is not already the name of a property.
"""
for k in kwargs:
if not hasattr(self, k):
raise AttributeError(k, 'Not valid for', self.__class__.__name... | [
"def",
"_assign_kwargs",
"(",
"self",
",",
"kwargs",
")",
":",
"for",
"k",
"in",
"kwargs",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"k",
")",
":",
"raise",
"AttributeError",
"(",
"k",
",",
"'Not valid for'",
",",
"self",
".",
"__class__",
".",
... | Assigns all keyword arguments to a given instance, raising an exception
if one of the keywords is not already the name of a property. | [
"Assigns",
"all",
"keyword",
"arguments",
"to",
"a",
"given",
"instance",
"raising",
"an",
"exception",
"if",
"one",
"of",
"the",
"keywords",
"is",
"not",
"already",
"the",
"name",
"of",
"a",
"property",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/fulltext.py#L86-L94 | train |
couchbase/couchbase-python-client | couchbase/fulltext.py | _mk_range_bucket | def _mk_range_bucket(name, n1, n2, r1, r2):
"""
Create a named range specification for encoding.
:param name: The name of the range as it should appear in the result
:param n1: The name of the lower bound of the range specifier
:param n2: The name of the upper bound of the range specified
:para... | python | def _mk_range_bucket(name, n1, n2, r1, r2):
"""
Create a named range specification for encoding.
:param name: The name of the range as it should appear in the result
:param n1: The name of the lower bound of the range specifier
:param n2: The name of the upper bound of the range specified
:para... | [
"def",
"_mk_range_bucket",
"(",
"name",
",",
"n1",
",",
"n2",
",",
"r1",
",",
"r2",
")",
":",
"d",
"=",
"{",
"}",
"if",
"r1",
"is",
"not",
"None",
":",
"d",
"[",
"n1",
"]",
"=",
"r1",
"if",
"r2",
"is",
"not",
"None",
":",
"d",
"[",
"n2",
... | Create a named range specification for encoding.
:param name: The name of the range as it should appear in the result
:param n1: The name of the lower bound of the range specifier
:param n2: The name of the upper bound of the range specified
:param r1: The value of the lower bound (user value)
:par... | [
"Create",
"a",
"named",
"range",
"specification",
"for",
"encoding",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/fulltext.py#L133-L157 | train |
couchbase/couchbase-python-client | couchbase/fulltext.py | DateFacet.add_range | def add_range(self, name, start=None, end=None):
"""
Adds a date range to the given facet.
:param str name:
The name by which the results within the range can be accessed
:param str start: Lower date range. Should be in RFC 3339 format
:param str end: Upper date rang... | python | def add_range(self, name, start=None, end=None):
"""
Adds a date range to the given facet.
:param str name:
The name by which the results within the range can be accessed
:param str start: Lower date range. Should be in RFC 3339 format
:param str end: Upper date rang... | [
"def",
"add_range",
"(",
"self",
",",
"name",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"self",
".",
"_ranges",
".",
"append",
"(",
"_mk_range_bucket",
"(",
"name",
",",
"'start'",
",",
"'end'",
",",
"start",
",",
"end",
")",
")... | Adds a date range to the given facet.
:param str name:
The name by which the results within the range can be accessed
:param str start: Lower date range. Should be in RFC 3339 format
:param str end: Upper date range.
:return: The `DateFacet` object, so calls to this method m... | [
"Adds",
"a",
"date",
"range",
"to",
"the",
"given",
"facet",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/fulltext.py#L170-L182 | train |
couchbase/couchbase-python-client | couchbase/fulltext.py | NumericFacet.add_range | def add_range(self, name, min=None, max=None):
"""
Add a numeric range.
:param str name:
the name by which the range is accessed in the results
:param int | float min: Lower range bound
:param int | float max: Upper range bound
:return: This object; suitable ... | python | def add_range(self, name, min=None, max=None):
"""
Add a numeric range.
:param str name:
the name by which the range is accessed in the results
:param int | float min: Lower range bound
:param int | float max: Upper range bound
:return: This object; suitable ... | [
"def",
"add_range",
"(",
"self",
",",
"name",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"self",
".",
"_ranges",
".",
"append",
"(",
"_mk_range_bucket",
"(",
"name",
",",
"'min'",
",",
"'max'",
",",
"min",
",",
"max",
")",
")",
"... | Add a numeric range.
:param str name:
the name by which the range is accessed in the results
:param int | float min: Lower range bound
:param int | float max: Upper range bound
:return: This object; suitable for method chaining | [
"Add",
"a",
"numeric",
"range",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/fulltext.py#L197-L208 | train |
couchbase/couchbase-python-client | couchbase/fulltext.py | SearchRequest.mk_kwargs | def mk_kwargs(cls, kwargs):
"""
Pop recognized arguments from a keyword list.
"""
ret = {}
kws = ['row_factory', 'body', 'parent']
for k in kws:
if k in kwargs:
ret[k] = kwargs.pop(k)
return ret | python | def mk_kwargs(cls, kwargs):
"""
Pop recognized arguments from a keyword list.
"""
ret = {}
kws = ['row_factory', 'body', 'parent']
for k in kws:
if k in kwargs:
ret[k] = kwargs.pop(k)
return ret | [
"def",
"mk_kwargs",
"(",
"cls",
",",
"kwargs",
")",
":",
"ret",
"=",
"{",
"}",
"kws",
"=",
"[",
"'row_factory'",
",",
"'body'",
",",
"'parent'",
"]",
"for",
"k",
"in",
"kws",
":",
"if",
"k",
"in",
"kwargs",
":",
"ret",
"[",
"k",
"]",
"=",
"kwar... | Pop recognized arguments from a keyword list. | [
"Pop",
"recognized",
"arguments",
"from",
"a",
"keyword",
"list",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/fulltext.py#L1115-L1125 | train |
couchbase/couchbase-python-client | couchbase/n1ql.py | N1QLQuery._set_named_args | def _set_named_args(self, **kv):
"""
Set a named parameter in the query. The named field must
exist in the query itself.
:param kv: Key-Value pairs representing values within the
query. These values should be stripped of their leading
`$` identifier.
"""... | python | def _set_named_args(self, **kv):
"""
Set a named parameter in the query. The named field must
exist in the query itself.
:param kv: Key-Value pairs representing values within the
query. These values should be stripped of their leading
`$` identifier.
"""... | [
"def",
"_set_named_args",
"(",
"self",
",",
"**",
"kv",
")",
":",
"for",
"k",
"in",
"kv",
":",
"self",
".",
"_body",
"[",
"'${0}'",
".",
"format",
"(",
"k",
")",
"]",
"=",
"kv",
"[",
"k",
"]",
"return",
"self"
] | Set a named parameter in the query. The named field must
exist in the query itself.
:param kv: Key-Value pairs representing values within the
query. These values should be stripped of their leading
`$` identifier. | [
"Set",
"a",
"named",
"parameter",
"in",
"the",
"query",
".",
"The",
"named",
"field",
"must",
"exist",
"in",
"the",
"query",
"itself",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/n1ql.py#L134-L146 | train |
couchbase/couchbase-python-client | couchbase/n1ql.py | N1QLQuery.consistent_with | def consistent_with(self, state):
"""
Indicate that the query should be consistent with one or more
mutations.
:param state: The state of the mutations it should be consistent
with.
:type state: :class:`~.couchbase.mutation_state.MutationState`
"""
if... | python | def consistent_with(self, state):
"""
Indicate that the query should be consistent with one or more
mutations.
:param state: The state of the mutations it should be consistent
with.
:type state: :class:`~.couchbase.mutation_state.MutationState`
"""
if... | [
"def",
"consistent_with",
"(",
"self",
",",
"state",
")",
":",
"if",
"self",
".",
"consistency",
"not",
"in",
"(",
"UNBOUNDED",
",",
"NOT_BOUNDED",
",",
"'at_plus'",
")",
":",
"raise",
"TypeError",
"(",
"'consistent_with not valid with other consistency options'",
... | Indicate that the query should be consistent with one or more
mutations.
:param state: The state of the mutations it should be consistent
with.
:type state: :class:`~.couchbase.mutation_state.MutationState` | [
"Indicate",
"that",
"the",
"query",
"should",
"be",
"consistent",
"with",
"one",
"or",
"more",
"mutations",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/n1ql.py#L194-L210 | train |
couchbase/couchbase-python-client | couchbase/n1ql.py | N1QLQuery.timeout | def timeout(self):
"""
Optional per-query timeout. If set, this will limit the amount
of time in which the query can be executed and waited for.
.. note::
The effective timeout for the query will be either this property
or the value of :attr:`couchbase.bucket.Bu... | python | def timeout(self):
"""
Optional per-query timeout. If set, this will limit the amount
of time in which the query can be executed and waited for.
.. note::
The effective timeout for the query will be either this property
or the value of :attr:`couchbase.bucket.Bu... | [
"def",
"timeout",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"_body",
".",
"get",
"(",
"'timeout'",
",",
"'0s'",
")",
"value",
"=",
"value",
"[",
":",
"-",
"1",
"]",
"return",
"float",
"(",
"value",
")"
] | Optional per-query timeout. If set, this will limit the amount
of time in which the query can be executed and waited for.
.. note::
The effective timeout for the query will be either this property
or the value of :attr:`couchbase.bucket.Bucket.n1ql_timeout`
property... | [
"Optional",
"per",
"-",
"query",
"timeout",
".",
"If",
"set",
"this",
"will",
"limit",
"the",
"amount",
"of",
"time",
"in",
"which",
"the",
"query",
"can",
"be",
"executed",
"and",
"waited",
"for",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/n1ql.py#L247-L262 | train |
couchbase/couchbase-python-client | couchbase/analytics.py | DeferredAnalyticsRequest._is_ready | def _is_ready(self):
"""
Return True if and only if final result has been received, optionally blocking
until this is the case, or the timeout is exceeded.
This is a synchronous implementation but an async one can
be added by subclassing this.
:return: True if ready, Fa... | python | def _is_ready(self):
"""
Return True if and only if final result has been received, optionally blocking
until this is the case, or the timeout is exceeded.
This is a synchronous implementation but an async one can
be added by subclassing this.
:return: True if ready, Fa... | [
"def",
"_is_ready",
"(",
"self",
")",
":",
"while",
"not",
"self",
".",
"finish_time",
"or",
"time",
".",
"time",
"(",
")",
"<",
"self",
".",
"finish_time",
":",
"result",
"=",
"self",
".",
"_poll_deferred",
"(",
")",
"if",
"result",
"==",
"'success'",... | Return True if and only if final result has been received, optionally blocking
until this is the case, or the timeout is exceeded.
This is a synchronous implementation but an async one can
be added by subclassing this.
:return: True if ready, False if not | [
"Return",
"True",
"if",
"and",
"only",
"if",
"final",
"result",
"has",
"been",
"received",
"optionally",
"blocking",
"until",
"this",
"is",
"the",
"case",
"or",
"the",
"timeout",
"is",
"exceeded",
"."
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/analytics.py#L199-L217 | train |
couchbase/couchbase-python-client | couchbase_version.py | VersionInfo.package_version | def package_version(self):
"""Returns the well formed PEP-440 version"""
vbase = self.base_version
if self.ncommits:
vbase += '.dev{0}+{1}'.format(self.ncommits, self.sha)
return vbase | python | def package_version(self):
"""Returns the well formed PEP-440 version"""
vbase = self.base_version
if self.ncommits:
vbase += '.dev{0}+{1}'.format(self.ncommits, self.sha)
return vbase | [
"def",
"package_version",
"(",
"self",
")",
":",
"vbase",
"=",
"self",
".",
"base_version",
"if",
"self",
".",
"ncommits",
":",
"vbase",
"+=",
"'.dev{0}+{1}'",
".",
"format",
"(",
"self",
".",
"ncommits",
",",
"self",
".",
"sha",
")",
"return",
"vbase"
] | Returns the well formed PEP-440 version | [
"Returns",
"the",
"well",
"formed",
"PEP",
"-",
"440",
"version"
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase_version.py#L76-L81 | train |
couchbase/couchbase-python-client | jenkins/pycbc-winbuild.py | download_and_bootstrap | def download_and_bootstrap(src, name, prereq=None):
"""
Download and install something if 'prerequisite' fails
"""
if prereq:
prereq_cmd = '{0} -c "{1}"'.format(PY_EXE, prereq)
rv = os.system(prereq_cmd)
if rv == 0:
return
ulp = urllib2.urlopen(src)
fp = open... | python | def download_and_bootstrap(src, name, prereq=None):
"""
Download and install something if 'prerequisite' fails
"""
if prereq:
prereq_cmd = '{0} -c "{1}"'.format(PY_EXE, prereq)
rv = os.system(prereq_cmd)
if rv == 0:
return
ulp = urllib2.urlopen(src)
fp = open... | [
"def",
"download_and_bootstrap",
"(",
"src",
",",
"name",
",",
"prereq",
"=",
"None",
")",
":",
"if",
"prereq",
":",
"prereq_cmd",
"=",
"'{0} -c \"{1}\"'",
".",
"format",
"(",
"PY_EXE",
",",
"prereq",
")",
"rv",
"=",
"os",
".",
"system",
"(",
"prereq_cmd... | Download and install something if 'prerequisite' fails | [
"Download",
"and",
"install",
"something",
"if",
"prerequisite",
"fails"
] | a7bada167785bf79a29c39f820d932a433a6a535 | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/jenkins/pycbc-winbuild.py#L165-L181 | train |
zheller/flake8-quotes | flake8_quotes/__init__.py | QuoteChecker._register_opt | def _register_opt(parser, *args, **kwargs):
"""
Handler to register an option for both Flake8 3.x and 2.x.
This is based on:
https://github.com/PyCQA/flake8/blob/3.0.0b2/docs/source/plugin-development/cross-compatibility.rst#option-handling-on-flake8-2-and-3
It only supports `p... | python | def _register_opt(parser, *args, **kwargs):
"""
Handler to register an option for both Flake8 3.x and 2.x.
This is based on:
https://github.com/PyCQA/flake8/blob/3.0.0b2/docs/source/plugin-development/cross-compatibility.rst#option-handling-on-flake8-2-and-3
It only supports `p... | [
"def",
"_register_opt",
"(",
"parser",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"parser",
".",
"add_option",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"except",
"(",
"optparse",
".",
"OptionError",
",",
"TypeError",
")",
":",
"p... | Handler to register an option for both Flake8 3.x and 2.x.
This is based on:
https://github.com/PyCQA/flake8/blob/3.0.0b2/docs/source/plugin-development/cross-compatibility.rst#option-handling-on-flake8-2-and-3
It only supports `parse_from_config` from the original function and it
uses... | [
"Handler",
"to",
"register",
"an",
"option",
"for",
"both",
"Flake8",
"3",
".",
"x",
"and",
"2",
".",
"x",
"."
] | 4afe69da02b89232cb71c57aafd384214a45a145 | https://github.com/zheller/flake8-quotes/blob/4afe69da02b89232cb71c57aafd384214a45a145/flake8_quotes/__init__.py#L78-L96 | train |
eventbrite/pysoa | pysoa/utils.py | dict_to_hashable | def dict_to_hashable(d):
"""
Takes a dict and returns an immutable, hashable version of that dict that can be used as a key in dicts or as a
set value. Any two dicts passed in with the same content are guaranteed to return the same value. Any two dicts
passed in with different content are guaranteed to ... | python | def dict_to_hashable(d):
"""
Takes a dict and returns an immutable, hashable version of that dict that can be used as a key in dicts or as a
set value. Any two dicts passed in with the same content are guaranteed to return the same value. Any two dicts
passed in with different content are guaranteed to ... | [
"def",
"dict_to_hashable",
"(",
"d",
")",
":",
"return",
"frozenset",
"(",
"(",
"k",
",",
"tuple",
"(",
"v",
")",
"if",
"isinstance",
"(",
"v",
",",
"list",
")",
"else",
"(",
"dict_to_hashable",
"(",
"v",
")",
"if",
"isinstance",
"(",
"v",
",",
"di... | Takes a dict and returns an immutable, hashable version of that dict that can be used as a key in dicts or as a
set value. Any two dicts passed in with the same content are guaranteed to return the same value. Any two dicts
passed in with different content are guaranteed to return different values. Performs com... | [
"Takes",
"a",
"dict",
"and",
"returns",
"an",
"immutable",
"hashable",
"version",
"of",
"that",
"dict",
"that",
"can",
"be",
"used",
"as",
"a",
"key",
"in",
"dicts",
"or",
"as",
"a",
"set",
"value",
".",
"Any",
"two",
"dicts",
"passed",
"in",
"with",
... | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/utils.py#L12-L32 | train |
eventbrite/pysoa | pysoa/server/action/introspection.py | IntrospectionAction.run | def run(self, request):
"""
Introspects all of the actions on the server and returns their documentation.
:param request: The request object
:type request: EnrichedActionRequest
:return: The response
"""
if request.body.get('action_name'):
return sel... | python | def run(self, request):
"""
Introspects all of the actions on the server and returns their documentation.
:param request: The request object
:type request: EnrichedActionRequest
:return: The response
"""
if request.body.get('action_name'):
return sel... | [
"def",
"run",
"(",
"self",
",",
"request",
")",
":",
"if",
"request",
".",
"body",
".",
"get",
"(",
"'action_name'",
")",
":",
"return",
"self",
".",
"_get_response_for_single_action",
"(",
"request",
".",
"body",
".",
"get",
"(",
"'action_name'",
")",
"... | Introspects all of the actions on the server and returns their documentation.
:param request: The request object
:type request: EnrichedActionRequest
:return: The response | [
"Introspects",
"all",
"of",
"the",
"actions",
"on",
"the",
"server",
"and",
"returns",
"their",
"documentation",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/server/action/introspection.py#L118-L130 | train |
eventbrite/pysoa | pysoa/client/client.py | ServiceHandler._make_middleware_stack | def _make_middleware_stack(middleware, base):
"""
Given a list of in-order middleware callables `middleware`
and a base function `base`, chains them together so each middleware is
fed the function below, and returns the top level ready to call.
"""
for ware in reversed(mi... | python | def _make_middleware_stack(middleware, base):
"""
Given a list of in-order middleware callables `middleware`
and a base function `base`, chains them together so each middleware is
fed the function below, and returns the top level ready to call.
"""
for ware in reversed(mi... | [
"def",
"_make_middleware_stack",
"(",
"middleware",
",",
"base",
")",
":",
"for",
"ware",
"in",
"reversed",
"(",
"middleware",
")",
":",
"base",
"=",
"ware",
"(",
"base",
")",
"return",
"base"
] | Given a list of in-order middleware callables `middleware`
and a base function `base`, chains them together so each middleware is
fed the function below, and returns the top level ready to call. | [
"Given",
"a",
"list",
"of",
"in",
"-",
"order",
"middleware",
"callables",
"middleware",
"and",
"a",
"base",
"function",
"base",
"chains",
"them",
"together",
"so",
"each",
"middleware",
"is",
"fed",
"the",
"function",
"below",
"and",
"returns",
"the",
"top"... | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/client.py#L71-L79 | train |
eventbrite/pysoa | pysoa/client/client.py | ServiceHandler.send_request | def send_request(self, job_request, message_expiry_in_seconds=None):
"""
Send a JobRequest, and return a request ID.
The context and control_extra arguments may be used to include extra values in the
context and control headers, respectively.
:param job_request: The job request... | python | def send_request(self, job_request, message_expiry_in_seconds=None):
"""
Send a JobRequest, and return a request ID.
The context and control_extra arguments may be used to include extra values in the
context and control headers, respectively.
:param job_request: The job request... | [
"def",
"send_request",
"(",
"self",
",",
"job_request",
",",
"message_expiry_in_seconds",
"=",
"None",
")",
":",
"request_id",
"=",
"self",
".",
"request_counter",
"self",
".",
"request_counter",
"+=",
"1",
"meta",
"=",
"{",
"}",
"wrapper",
"=",
"self",
".",... | Send a JobRequest, and return a request ID.
The context and control_extra arguments may be used to include extra values in the
context and control headers, respectively.
:param job_request: The job request object to send
:type job_request: JobRequest
:param message_expiry_in_se... | [
"Send",
"a",
"JobRequest",
"and",
"return",
"a",
"request",
"ID",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/client.py#L87-L117 | train |
eventbrite/pysoa | pysoa/client/client.py | ServiceHandler.get_all_responses | def get_all_responses(self, receive_timeout_in_seconds=None):
"""
Receive all available responses from the transport as a generator.
:param receive_timeout_in_seconds: How long to block without receiving a message before raising
`MessageReceiveTimeout`... | python | def get_all_responses(self, receive_timeout_in_seconds=None):
"""
Receive all available responses from the transport as a generator.
:param receive_timeout_in_seconds: How long to block without receiving a message before raising
`MessageReceiveTimeout`... | [
"def",
"get_all_responses",
"(",
"self",
",",
"receive_timeout_in_seconds",
"=",
"None",
")",
":",
"wrapper",
"=",
"self",
".",
"_make_middleware_stack",
"(",
"[",
"m",
".",
"response",
"for",
"m",
"in",
"self",
".",
"middleware",
"]",
",",
"self",
".",
"_... | Receive all available responses from the transport as a generator.
:param receive_timeout_in_seconds: How long to block without receiving a message before raising
`MessageReceiveTimeout` (defaults to five seconds unless the settings are
... | [
"Receive",
"all",
"available",
"responses",
"from",
"the",
"transport",
"as",
"a",
"generator",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/client.py#L127-L154 | train |
eventbrite/pysoa | pysoa/client/client.py | Client.call_action | def call_action(self, service_name, action, body=None, **kwargs):
"""
Build and send a single job request with one action.
Returns the action response or raises an exception if the action response is an error (unless
`raise_action_errors` is passed as `False`) or if the job response is ... | python | def call_action(self, service_name, action, body=None, **kwargs):
"""
Build and send a single job request with one action.
Returns the action response or raises an exception if the action response is an error (unless
`raise_action_errors` is passed as `False`) or if the job response is ... | [
"def",
"call_action",
"(",
"self",
",",
"service_name",
",",
"action",
",",
"body",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"call_action_future",
"(",
"service_name",
",",
"action",
",",
"body",
",",
"**",
"kwargs",
")",
".",
... | Build and send a single job request with one action.
Returns the action response or raises an exception if the action response is an error (unless
`raise_action_errors` is passed as `False`) or if the job response is an error (unless `raise_job_errors` is
passed as `False`).
:param ser... | [
"Build",
"and",
"send",
"a",
"single",
"job",
"request",
"with",
"one",
"action",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/client.py#L348-L390 | train |
eventbrite/pysoa | pysoa/client/client.py | Client.call_actions | def call_actions(
self,
service_name,
actions,
expansions=None,
raise_job_errors=True,
raise_action_errors=True,
timeout=None,
**kwargs
):
"""
Build and send a single job request with one or more actions.
Returns a list of acti... | python | def call_actions(
self,
service_name,
actions,
expansions=None,
raise_job_errors=True,
raise_action_errors=True,
timeout=None,
**kwargs
):
"""
Build and send a single job request with one or more actions.
Returns a list of acti... | [
"def",
"call_actions",
"(",
"self",
",",
"service_name",
",",
"actions",
",",
"expansions",
"=",
"None",
",",
"raise_job_errors",
"=",
"True",
",",
"raise_action_errors",
"=",
"True",
",",
"timeout",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"return",
"s... | Build and send a single job request with one or more actions.
Returns a list of action responses, one for each action in the same order as provided, or raises an exception
if any action response is an error (unless `raise_action_errors` is passed as `False`) or if the job response
is an error (... | [
"Build",
"and",
"send",
"a",
"single",
"job",
"request",
"with",
"one",
"or",
"more",
"actions",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/client.py#L392-L451 | train |
eventbrite/pysoa | pysoa/client/client.py | Client.call_actions_parallel | def call_actions_parallel(self, service_name, actions, **kwargs):
"""
Build and send multiple job requests to one service, each job with one action, to be executed in parallel, and
return once all responses have been received.
Returns a list of action responses, one for each action in t... | python | def call_actions_parallel(self, service_name, actions, **kwargs):
"""
Build and send multiple job requests to one service, each job with one action, to be executed in parallel, and
return once all responses have been received.
Returns a list of action responses, one for each action in t... | [
"def",
"call_actions_parallel",
"(",
"self",
",",
"service_name",
",",
"actions",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"call_actions_parallel_future",
"(",
"service_name",
",",
"actions",
",",
"**",
"kwargs",
")",
".",
"result",
"(",
")"
] | Build and send multiple job requests to one service, each job with one action, to be executed in parallel, and
return once all responses have been received.
Returns a list of action responses, one for each action in the same order as provided, or raises an exception
if any action response is an... | [
"Build",
"and",
"send",
"multiple",
"job",
"requests",
"to",
"one",
"service",
"each",
"job",
"with",
"one",
"action",
"to",
"be",
"executed",
"in",
"parallel",
"and",
"return",
"once",
"all",
"responses",
"have",
"been",
"received",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/client.py#L453-L494 | train |
eventbrite/pysoa | pysoa/client/client.py | Client.call_jobs_parallel | def call_jobs_parallel(
self,
jobs,
expansions=None,
raise_job_errors=True,
raise_action_errors=True,
catch_transport_errors=False,
timeout=None,
**kwargs
):
"""
Build and send multiple job requests to one or more services, each with on... | python | def call_jobs_parallel(
self,
jobs,
expansions=None,
raise_job_errors=True,
raise_action_errors=True,
catch_transport_errors=False,
timeout=None,
**kwargs
):
"""
Build and send multiple job requests to one or more services, each with on... | [
"def",
"call_jobs_parallel",
"(",
"self",
",",
"jobs",
",",
"expansions",
"=",
"None",
",",
"raise_job_errors",
"=",
"True",
",",
"raise_action_errors",
"=",
"True",
",",
"catch_transport_errors",
"=",
"False",
",",
"timeout",
"=",
"None",
",",
"**",
"kwargs",... | Build and send multiple job requests to one or more services, each with one or more actions, to be executed in
parallel, and return once all responses have been received.
Returns a list of job responses, one for each job in the same order as provided, or raises an exception if any
job response ... | [
"Build",
"and",
"send",
"multiple",
"job",
"requests",
"to",
"one",
"or",
"more",
"services",
"each",
"with",
"one",
"or",
"more",
"actions",
"to",
"be",
"executed",
"in",
"parallel",
"and",
"return",
"once",
"all",
"responses",
"have",
"been",
"received",
... | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/client.py#L496-L564 | train |
eventbrite/pysoa | pysoa/client/client.py | Client.send_request | def send_request(
self,
service_name,
actions,
switches=None,
correlation_id=None,
continue_on_error=False,
context=None,
control_extra=None,
message_expiry_in_seconds=None,
suppress_response=False,
):
"""
Build and send... | python | def send_request(
self,
service_name,
actions,
switches=None,
correlation_id=None,
continue_on_error=False,
context=None,
control_extra=None,
message_expiry_in_seconds=None,
suppress_response=False,
):
"""
Build and send... | [
"def",
"send_request",
"(",
"self",
",",
"service_name",
",",
"actions",
",",
"switches",
"=",
"None",
",",
"correlation_id",
"=",
"None",
",",
"continue_on_error",
"=",
"False",
",",
"context",
"=",
"None",
",",
"control_extra",
"=",
"None",
",",
"message_e... | Build and send a JobRequest, and return a request ID.
The context and control_extra arguments may be used to include extra values in the
context and control headers, respectively.
:param service_name: The name of the service from which to receive responses
:type service_name: union[str... | [
"Build",
"and",
"send",
"a",
"JobRequest",
"and",
"return",
"a",
"request",
"ID",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/client.py#L804-L866 | train |
eventbrite/pysoa | pysoa/client/client.py | Client.get_all_responses | def get_all_responses(self, service_name, receive_timeout_in_seconds=None):
"""
Receive all available responses from the service as a generator.
:param service_name: The name of the service from which to receive responses
:type service_name: union[str, unicode]
:param receive_ti... | python | def get_all_responses(self, service_name, receive_timeout_in_seconds=None):
"""
Receive all available responses from the service as a generator.
:param service_name: The name of the service from which to receive responses
:type service_name: union[str, unicode]
:param receive_ti... | [
"def",
"get_all_responses",
"(",
"self",
",",
"service_name",
",",
"receive_timeout_in_seconds",
"=",
"None",
")",
":",
"handler",
"=",
"self",
".",
"_get_handler",
"(",
"service_name",
")",
"return",
"handler",
".",
"get_all_responses",
"(",
"receive_timeout_in_sec... | Receive all available responses from the service as a generator.
:param service_name: The name of the service from which to receive responses
:type service_name: union[str, unicode]
:param receive_timeout_in_seconds: How long to block without receiving a message before raising
... | [
"Receive",
"all",
"available",
"responses",
"from",
"the",
"service",
"as",
"a",
"generator",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/client.py#L868-L886 | train |
eventbrite/pysoa | pysoa/server/autoreload.py | get_reloader | def get_reloader(main_module_name, watch_modules, signal_forks=False):
"""
Don't instantiate a reloader directly. Instead, call this method to get a reloader, and then call `main` on that
reloader.
See the documentation for `AbstractReloader.main` above to see how to call it.
:param main_module_na... | python | def get_reloader(main_module_name, watch_modules, signal_forks=False):
"""
Don't instantiate a reloader directly. Instead, call this method to get a reloader, and then call `main` on that
reloader.
See the documentation for `AbstractReloader.main` above to see how to call it.
:param main_module_na... | [
"def",
"get_reloader",
"(",
"main_module_name",
",",
"watch_modules",
",",
"signal_forks",
"=",
"False",
")",
":",
"if",
"USE_PY_INOTIFY",
":",
"return",
"_PyInotifyReloader",
"(",
"main_module_name",
",",
"watch_modules",
",",
"signal_forks",
")",
"return",
"_Polli... | Don't instantiate a reloader directly. Instead, call this method to get a reloader, and then call `main` on that
reloader.
See the documentation for `AbstractReloader.main` above to see how to call it.
:param main_module_name: The main module name (such as "example_service.standalone"). It should be the v... | [
"Don",
"t",
"instantiate",
"a",
"reloader",
"directly",
".",
"Instead",
"call",
"this",
"method",
"to",
"get",
"a",
"reloader",
"and",
"then",
"call",
"main",
"on",
"that",
"reloader",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/server/autoreload.py#L414-L438 | train |
eventbrite/pysoa | pysoa/common/serializer/msgpack_serializer.py | MsgpackSerializer.ext_hook | def ext_hook(self, code, data):
"""
Decodes our custom extension types
"""
if code == self.EXT_DATETIME:
# Unpack datetime object from a big-endian signed 64-bit integer.
microseconds = self.STRUCT_DATETIME.unpack(data)[0]
return datetime.datetime.utcf... | python | def ext_hook(self, code, data):
"""
Decodes our custom extension types
"""
if code == self.EXT_DATETIME:
# Unpack datetime object from a big-endian signed 64-bit integer.
microseconds = self.STRUCT_DATETIME.unpack(data)[0]
return datetime.datetime.utcf... | [
"def",
"ext_hook",
"(",
"self",
",",
"code",
",",
"data",
")",
":",
"if",
"code",
"==",
"self",
".",
"EXT_DATETIME",
":",
"microseconds",
"=",
"self",
".",
"STRUCT_DATETIME",
".",
"unpack",
"(",
"data",
")",
"[",
"0",
"]",
"return",
"datetime",
".",
... | Decodes our custom extension types | [
"Decodes",
"our",
"custom",
"extension",
"types"
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/common/serializer/msgpack_serializer.py#L139-L163 | train |
eventbrite/pysoa | pysoa/common/transport/local.py | LocalClientTransport.send_request_message | def send_request_message(self, request_id, meta, body, _=None):
"""
Receives a request from the client and handles and dispatches in in-thread. `message_expiry_in_seconds` is not
supported. Messages do not expire, as the server handles the request immediately in the same thread before
th... | python | def send_request_message(self, request_id, meta, body, _=None):
"""
Receives a request from the client and handles and dispatches in in-thread. `message_expiry_in_seconds` is not
supported. Messages do not expire, as the server handles the request immediately in the same thread before
th... | [
"def",
"send_request_message",
"(",
"self",
",",
"request_id",
",",
"meta",
",",
"body",
",",
"_",
"=",
"None",
")",
":",
"self",
".",
"_current_request",
"=",
"(",
"request_id",
",",
"meta",
",",
"body",
")",
"try",
":",
"self",
".",
"server",
".",
... | Receives a request from the client and handles and dispatches in in-thread. `message_expiry_in_seconds` is not
supported. Messages do not expire, as the server handles the request immediately in the same thread before
this method returns. This method blocks until the server has completed handling the re... | [
"Receives",
"a",
"request",
"from",
"the",
"client",
"and",
"handles",
"and",
"dispatches",
"in",
"in",
"-",
"thread",
".",
"message_expiry_in_seconds",
"is",
"not",
"supported",
".",
"Messages",
"do",
"not",
"expire",
"as",
"the",
"server",
"handles",
"the",
... | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/common/transport/local.py#L78-L88 | train |
eventbrite/pysoa | pysoa/common/transport/local.py | LocalClientTransport.send_response_message | def send_response_message(self, request_id, meta, body):
"""
Add the response to the deque.
"""
self.response_messages.append((request_id, meta, body)) | python | def send_response_message(self, request_id, meta, body):
"""
Add the response to the deque.
"""
self.response_messages.append((request_id, meta, body)) | [
"def",
"send_response_message",
"(",
"self",
",",
"request_id",
",",
"meta",
",",
"body",
")",
":",
"self",
".",
"response_messages",
".",
"append",
"(",
"(",
"request_id",
",",
"meta",
",",
"body",
")",
")"
] | Add the response to the deque. | [
"Add",
"the",
"response",
"to",
"the",
"deque",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/common/transport/local.py#L103-L107 | train |
eventbrite/pysoa | pysoa/server/action/status.py | StatusActionFactory | def StatusActionFactory(version, build=None, base_class=BaseStatusAction): # noqa
"""
A factory for creating a new status action class specific to a service.
:param version: The service version
:type version: union[str, unicode]
:param build: The optional service build identifier
:type build: ... | python | def StatusActionFactory(version, build=None, base_class=BaseStatusAction): # noqa
"""
A factory for creating a new status action class specific to a service.
:param version: The service version
:type version: union[str, unicode]
:param build: The optional service build identifier
:type build: ... | [
"def",
"StatusActionFactory",
"(",
"version",
",",
"build",
"=",
"None",
",",
"base_class",
"=",
"BaseStatusAction",
")",
":",
"return",
"type",
"(",
"str",
"(",
"'StatusAction'",
")",
",",
"(",
"base_class",
",",
")",
",",
"{",
"str",
"(",
"'_version'",
... | A factory for creating a new status action class specific to a service.
:param version: The service version
:type version: union[str, unicode]
:param build: The optional service build identifier
:type build: union[str, unicode]
:param base_class: The optional base class, to override `BaseStatusActi... | [
"A",
"factory",
"for",
"creating",
"a",
"new",
"status",
"action",
"class",
"specific",
"to",
"a",
"service",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/server/action/status.py#L235-L253 | train |
eventbrite/pysoa | pysoa/server/server.py | Server.make_middleware_stack | def make_middleware_stack(middleware, base):
"""
Given a list of in-order middleware callable objects `middleware` and a base function `base`, chains them
together so each middleware is fed the function below, and returns the top level ready to call.
:param middleware: The middleware st... | python | def make_middleware_stack(middleware, base):
"""
Given a list of in-order middleware callable objects `middleware` and a base function `base`, chains them
together so each middleware is fed the function below, and returns the top level ready to call.
:param middleware: The middleware st... | [
"def",
"make_middleware_stack",
"(",
"middleware",
",",
"base",
")",
":",
"for",
"ware",
"in",
"reversed",
"(",
"middleware",
")",
":",
"base",
"=",
"ware",
"(",
"base",
")",
"return",
"base"
] | Given a list of in-order middleware callable objects `middleware` and a base function `base`, chains them
together so each middleware is fed the function below, and returns the top level ready to call.
:param middleware: The middleware stack
:type middleware: iterable[callable]
:param b... | [
"Given",
"a",
"list",
"of",
"in",
"-",
"order",
"middleware",
"callable",
"objects",
"middleware",
"and",
"a",
"base",
"function",
"base",
"chains",
"them",
"together",
"so",
"each",
"middleware",
"is",
"fed",
"the",
"function",
"below",
"and",
"returns",
"t... | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/server/server.py#L266-L282 | train |
eventbrite/pysoa | pysoa/server/server.py | Server.process_job | def process_job(self, job_request):
"""
Validate, execute, and run the job request, wrapping it with any applicable job middleware.
:param job_request: The job request
:type job_request: dict
:return: A `JobResponse` object
:rtype: JobResponse
:raise: JobError
... | python | def process_job(self, job_request):
"""
Validate, execute, and run the job request, wrapping it with any applicable job middleware.
:param job_request: The job request
:type job_request: dict
:return: A `JobResponse` object
:rtype: JobResponse
:raise: JobError
... | [
"def",
"process_job",
"(",
"self",
",",
"job_request",
")",
":",
"try",
":",
"validation_errors",
"=",
"[",
"Error",
"(",
"code",
"=",
"error",
".",
"code",
",",
"message",
"=",
"error",
".",
"message",
",",
"field",
"=",
"error",
".",
"pointer",
",",
... | Validate, execute, and run the job request, wrapping it with any applicable job middleware.
:param job_request: The job request
:type job_request: dict
:return: A `JobResponse` object
:rtype: JobResponse
:raise: JobError | [
"Validate",
"execute",
"and",
"run",
"the",
"job",
"request",
"wrapping",
"it",
"with",
"any",
"applicable",
"job",
"middleware",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/server/server.py#L284-L339 | train |
eventbrite/pysoa | pysoa/server/server.py | Server.handle_job_exception | def handle_job_exception(self, exception, variables=None):
"""
Makes and returns a last-ditch error response.
:param exception: The exception that happened
:type exception: Exception
:param variables: A dictionary of context-relevant variables to include in the error response
... | python | def handle_job_exception(self, exception, variables=None):
"""
Makes and returns a last-ditch error response.
:param exception: The exception that happened
:type exception: Exception
:param variables: A dictionary of context-relevant variables to include in the error response
... | [
"def",
"handle_job_exception",
"(",
"self",
",",
"exception",
",",
"variables",
"=",
"None",
")",
":",
"try",
":",
"error_str",
",",
"traceback_str",
"=",
"six",
".",
"text_type",
"(",
"exception",
")",
",",
"traceback",
".",
"format_exc",
"(",
")",
"excep... | Makes and returns a last-ditch error response.
:param exception: The exception that happened
:type exception: Exception
:param variables: A dictionary of context-relevant variables to include in the error response
:type variables: dict
:return: A `JobResponse` object
:r... | [
"Makes",
"and",
"returns",
"a",
"last",
"-",
"ditch",
"error",
"response",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/server/server.py#L341-L383 | train |
eventbrite/pysoa | pysoa/server/server.py | Server.execute_job | def execute_job(self, job_request):
"""
Processes and runs the action requests contained in the job and returns a `JobResponse`.
:param job_request: The job request
:type job_request: dict
:return: A `JobResponse` object
:rtype: JobResponse
"""
# Run the... | python | def execute_job(self, job_request):
"""
Processes and runs the action requests contained in the job and returns a `JobResponse`.
:param job_request: The job request
:type job_request: dict
:return: A `JobResponse` object
:rtype: JobResponse
"""
# Run the... | [
"def",
"execute_job",
"(",
"self",
",",
"job_request",
")",
":",
"job_response",
"=",
"JobResponse",
"(",
")",
"job_switches",
"=",
"RequestSwitchSet",
"(",
"job_request",
"[",
"'context'",
"]",
"[",
"'switches'",
"]",
")",
"for",
"i",
",",
"raw_action_request... | Processes and runs the action requests contained in the job and returns a `JobResponse`.
:param job_request: The job request
:type job_request: dict
:return: A `JobResponse` object
:rtype: JobResponse | [
"Processes",
"and",
"runs",
"the",
"action",
"requests",
"contained",
"in",
"the",
"job",
"and",
"returns",
"a",
"JobResponse",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/server/server.py#L397-L467 | train |
eventbrite/pysoa | pysoa/server/server.py | Server.handle_shutdown_signal | def handle_shutdown_signal(self, *_):
"""
Handles the reception of a shutdown signal.
"""
if self.shutting_down:
self.logger.warning('Received double interrupt, forcing shutdown')
sys.exit(1)
else:
self.logger.warning('Received interrupt, initi... | python | def handle_shutdown_signal(self, *_):
"""
Handles the reception of a shutdown signal.
"""
if self.shutting_down:
self.logger.warning('Received double interrupt, forcing shutdown')
sys.exit(1)
else:
self.logger.warning('Received interrupt, initi... | [
"def",
"handle_shutdown_signal",
"(",
"self",
",",
"*",
"_",
")",
":",
"if",
"self",
".",
"shutting_down",
":",
"self",
".",
"logger",
".",
"warning",
"(",
"'Received double interrupt, forcing shutdown'",
")",
"sys",
".",
"exit",
"(",
"1",
")",
"else",
":",
... | Handles the reception of a shutdown signal. | [
"Handles",
"the",
"reception",
"of",
"a",
"shutdown",
"signal",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/server/server.py#L469-L478 | train |
eventbrite/pysoa | pysoa/server/server.py | Server.harakiri | def harakiri(self, *_):
"""
Handles the reception of a timeout signal indicating that a request has been processing for too long, as
defined by the Harakiri settings.
"""
if self.shutting_down:
self.logger.warning('Graceful shutdown failed after {}s. Exiting now!'.for... | python | def harakiri(self, *_):
"""
Handles the reception of a timeout signal indicating that a request has been processing for too long, as
defined by the Harakiri settings.
"""
if self.shutting_down:
self.logger.warning('Graceful shutdown failed after {}s. Exiting now!'.for... | [
"def",
"harakiri",
"(",
"self",
",",
"*",
"_",
")",
":",
"if",
"self",
".",
"shutting_down",
":",
"self",
".",
"logger",
".",
"warning",
"(",
"'Graceful shutdown failed after {}s. Exiting now!'",
".",
"format",
"(",
"self",
".",
"settings",
"[",
"'harakiri'",
... | Handles the reception of a timeout signal indicating that a request has been processing for too long, as
defined by the Harakiri settings. | [
"Handles",
"the",
"reception",
"of",
"a",
"timeout",
"signal",
"indicating",
"that",
"a",
"request",
"has",
"been",
"processing",
"for",
"too",
"long",
"as",
"defined",
"by",
"the",
"Harakiri",
"settings",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/server/server.py#L480-L496 | train |
eventbrite/pysoa | pysoa/server/server.py | Server.run | def run(self):
"""
Starts the server run loop and returns after the server shuts down due to a shutdown-request, Harakiri signal,
or unhandled exception. See the documentation for `Server.main` for full details on the chain of `Server`
method calls.
"""
self.logger.info(... | python | def run(self):
"""
Starts the server run loop and returns after the server shuts down due to a shutdown-request, Harakiri signal,
or unhandled exception. See the documentation for `Server.main` for full details on the chain of `Server`
method calls.
"""
self.logger.info(... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Service \"{service}\" server starting up, pysoa version {pysoa}, listening on transport {transport}.'",
".",
"format",
"(",
"service",
"=",
"self",
".",
"service_name",
",",
"pysoa",
"=",
... | Starts the server run loop and returns after the server shuts down due to a shutdown-request, Harakiri signal,
or unhandled exception. See the documentation for `Server.main` for full details on the chain of `Server`
method calls. | [
"Starts",
"the",
"server",
"run",
"loop",
"and",
"returns",
"after",
"the",
"server",
"shuts",
"down",
"due",
"to",
"a",
"shutdown",
"-",
"request",
"Harakiri",
"signal",
"or",
"unhandled",
"exception",
".",
"See",
"the",
"documentation",
"for",
"Server",
".... | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/server/server.py#L611-L658 | train |
eventbrite/pysoa | pysoa/common/logging.py | SyslogHandler.emit | def emit(self, record):
"""
Emits a record. The record is sent carefully, according to the following rules, to ensure that data is not
lost by exceeding the MTU of the connection.
- If the byte-encoded record length plus prefix length plus suffix length plus priority length is less than... | python | def emit(self, record):
"""
Emits a record. The record is sent carefully, according to the following rules, to ensure that data is not
lost by exceeding the MTU of the connection.
- If the byte-encoded record length plus prefix length plus suffix length plus priority length is less than... | [
"def",
"emit",
"(",
"self",
",",
"record",
")",
":",
"try",
":",
"formatted_message",
"=",
"self",
".",
"format",
"(",
"record",
")",
"encoded_message",
"=",
"formatted_message",
".",
"encode",
"(",
"'utf-8'",
")",
"prefix",
"=",
"suffix",
"=",
"b''",
"i... | Emits a record. The record is sent carefully, according to the following rules, to ensure that data is not
lost by exceeding the MTU of the connection.
- If the byte-encoded record length plus prefix length plus suffix length plus priority length is less than the
maximum allowed length, then ... | [
"Emits",
"a",
"record",
".",
"The",
"record",
"is",
"sent",
"carefully",
"according",
"to",
"the",
"following",
"rules",
"to",
"ensure",
"that",
"data",
"is",
"not",
"lost",
"by",
"exceeding",
"the",
"MTU",
"of",
"the",
"connection",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/common/logging.py#L270-L359 | train |
eventbrite/pysoa | pysoa/client/expander.py | TypeNode.add_expansion | def add_expansion(self, expansion_node):
"""
Add a child expansion node to the type node's expansions.
If an expansion node with the same name is already present in type node's expansions, the new and existing
expansion node's children are merged.
:param expansion_node: The exp... | python | def add_expansion(self, expansion_node):
"""
Add a child expansion node to the type node's expansions.
If an expansion node with the same name is already present in type node's expansions, the new and existing
expansion node's children are merged.
:param expansion_node: The exp... | [
"def",
"add_expansion",
"(",
"self",
",",
"expansion_node",
")",
":",
"existing_expansion_node",
"=",
"self",
".",
"get_expansion",
"(",
"expansion_node",
".",
"name",
")",
"if",
"existing_expansion_node",
":",
"for",
"child_expansion",
"in",
"expansion_node",
".",
... | Add a child expansion node to the type node's expansions.
If an expansion node with the same name is already present in type node's expansions, the new and existing
expansion node's children are merged.
:param expansion_node: The expansion node to add
:type expansion_node: ExpansionNod... | [
"Add",
"a",
"child",
"expansion",
"node",
"to",
"the",
"type",
"node",
"s",
"expansions",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/expander.py#L114-L132 | train |
eventbrite/pysoa | pysoa/client/expander.py | TypeNode.find_objects | def find_objects(self, obj):
"""
Find all objects in obj that match the type of the type node.
:param obj: A dictionary or list of dictionaries to search, recursively
:type obj: union[dict, list[dict]]
:return: a list of dictionary objects that have a "_type" key value that mat... | python | def find_objects(self, obj):
"""
Find all objects in obj that match the type of the type node.
:param obj: A dictionary or list of dictionaries to search, recursively
:type obj: union[dict, list[dict]]
:return: a list of dictionary objects that have a "_type" key value that mat... | [
"def",
"find_objects",
"(",
"self",
",",
"obj",
")",
":",
"objects",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"object_type",
"=",
"obj",
".",
"get",
"(",
"'_type'",
")",
"if",
"object_type",
"==",
"self",
".",
"type",
"... | Find all objects in obj that match the type of the type node.
:param obj: A dictionary or list of dictionaries to search, recursively
:type obj: union[dict, list[dict]]
:return: a list of dictionary objects that have a "_type" key value that matches the type of this node.
:rtype: list[... | [
"Find",
"all",
"objects",
"in",
"obj",
"that",
"match",
"the",
"type",
"of",
"the",
"type",
"node",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/expander.py#L147-L174 | train |
eventbrite/pysoa | pysoa/client/expander.py | TypeNode.to_dict | def to_dict(self):
"""
Convert the tree node to its dictionary representation.
:return: an expansion dictionary that represents the type and expansions of this tree node.
:rtype dict[list[union[str, unicode]]]
"""
expansion_strings = []
for expansion in self.exp... | python | def to_dict(self):
"""
Convert the tree node to its dictionary representation.
:return: an expansion dictionary that represents the type and expansions of this tree node.
:rtype dict[list[union[str, unicode]]]
"""
expansion_strings = []
for expansion in self.exp... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"expansion_strings",
"=",
"[",
"]",
"for",
"expansion",
"in",
"self",
".",
"expansions",
":",
"expansion_strings",
".",
"extend",
"(",
"expansion",
".",
"to_strings",
"(",
")",
")",
"return",
"{",
"self",
".",
"ty... | Convert the tree node to its dictionary representation.
:return: an expansion dictionary that represents the type and expansions of this tree node.
:rtype dict[list[union[str, unicode]]] | [
"Convert",
"the",
"tree",
"node",
"to",
"its",
"dictionary",
"representation",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/expander.py#L183-L197 | train |
eventbrite/pysoa | pysoa/client/expander.py | ExpansionNode.to_strings | def to_strings(self):
"""
Convert the expansion node to a list of expansion strings.
:return: a list of expansion strings that represent the leaf nodes of the expansion tree.
:rtype: list[union[str, unicode]]
"""
result = []
if not self.expansions:
r... | python | def to_strings(self):
"""
Convert the expansion node to a list of expansion strings.
:return: a list of expansion strings that represent the leaf nodes of the expansion tree.
:rtype: list[union[str, unicode]]
"""
result = []
if not self.expansions:
r... | [
"def",
"to_strings",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"expansions",
":",
"result",
".",
"append",
"(",
"self",
".",
"name",
")",
"else",
":",
"for",
"expansion",
"in",
"self",
".",
"expansions",
":",
"result",... | Convert the expansion node to a list of expansion strings.
:return: a list of expansion strings that represent the leaf nodes of the expansion tree.
:rtype: list[union[str, unicode]] | [
"Convert",
"the",
"expansion",
"node",
"to",
"a",
"list",
"of",
"expansion",
"strings",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/expander.py#L252-L267 | train |
eventbrite/pysoa | pysoa/client/expander.py | ExpansionConverter.dict_to_trees | def dict_to_trees(self, expansion_dict):
"""
Convert an expansion dictionary to a list of expansion trees.
:param expansion_dict: An expansion dictionary (see below)
:type expansion_dict: dict
:return: a list of expansion trees (`TreeNode` instances).
:rtype: list[TreeN... | python | def dict_to_trees(self, expansion_dict):
"""
Convert an expansion dictionary to a list of expansion trees.
:param expansion_dict: An expansion dictionary (see below)
:type expansion_dict: dict
:return: a list of expansion trees (`TreeNode` instances).
:rtype: list[TreeN... | [
"def",
"dict_to_trees",
"(",
"self",
",",
"expansion_dict",
")",
":",
"trees",
"=",
"[",
"]",
"for",
"node_type",
",",
"expansion_list",
"in",
"six",
".",
"iteritems",
"(",
"expansion_dict",
")",
":",
"type_node",
"=",
"TypeNode",
"(",
"node_type",
"=",
"n... | Convert an expansion dictionary to a list of expansion trees.
:param expansion_dict: An expansion dictionary (see below)
:type expansion_dict: dict
:return: a list of expansion trees (`TreeNode` instances).
:rtype: list[TreeNode]
Expansion Dictionary Format:
{
... | [
"Convert",
"an",
"expansion",
"dictionary",
"to",
"a",
"list",
"of",
"expansion",
"trees",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/expander.py#L344-L401 | train |
eventbrite/pysoa | pysoa/client/expander.py | ExpansionConverter.trees_to_dict | def trees_to_dict(trees_list):
"""
Convert a list of `TreeNode`s to an expansion dictionary.
:param trees_list: A list of `TreeNode` instances
:type trees_list: list[TreeNode]
:return: An expansion dictionary that represents the expansions detailed in the provided expansions tr... | python | def trees_to_dict(trees_list):
"""
Convert a list of `TreeNode`s to an expansion dictionary.
:param trees_list: A list of `TreeNode` instances
:type trees_list: list[TreeNode]
:return: An expansion dictionary that represents the expansions detailed in the provided expansions tr... | [
"def",
"trees_to_dict",
"(",
"trees_list",
")",
":",
"result",
"=",
"{",
"}",
"for",
"tree",
"in",
"trees_list",
":",
"result",
".",
"update",
"(",
"tree",
".",
"to_dict",
"(",
")",
")",
"return",
"result"
] | Convert a list of `TreeNode`s to an expansion dictionary.
:param trees_list: A list of `TreeNode` instances
:type trees_list: list[TreeNode]
:return: An expansion dictionary that represents the expansions detailed in the provided expansions tree nodes
:rtype: dict[union[str, unicode]] | [
"Convert",
"a",
"list",
"of",
"TreeNode",
"s",
"to",
"an",
"expansion",
"dictionary",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/client/expander.py#L404-L419 | train |
eventbrite/pysoa | pysoa/common/transport/redis_gateway/backend/sentinel.py | SentinelRedisClient._get_service_names | def _get_service_names(self):
"""
Get a list of service names from Sentinel. Tries Sentinel hosts until one succeeds; if none succeed,
raises a ConnectionError.
:return: the list of service names from Sentinel.
"""
master_info = None
connection_errors = []
... | python | def _get_service_names(self):
"""
Get a list of service names from Sentinel. Tries Sentinel hosts until one succeeds; if none succeed,
raises a ConnectionError.
:return: the list of service names from Sentinel.
"""
master_info = None
connection_errors = []
... | [
"def",
"_get_service_names",
"(",
"self",
")",
":",
"master_info",
"=",
"None",
"connection_errors",
"=",
"[",
"]",
"for",
"sentinel",
"in",
"self",
".",
"_sentinel",
".",
"sentinels",
":",
"try",
":",
"master_info",
"=",
"sentinel",
".",
"sentinel_masters",
... | Get a list of service names from Sentinel. Tries Sentinel hosts until one succeeds; if none succeed,
raises a ConnectionError.
:return: the list of service names from Sentinel. | [
"Get",
"a",
"list",
"of",
"service",
"names",
"from",
"Sentinel",
".",
"Tries",
"Sentinel",
"hosts",
"until",
"one",
"succeeds",
";",
"if",
"none",
"succeed",
"raises",
"a",
"ConnectionError",
"."
] | 9c052cae2397d13de3df8ae2c790846a70b53f18 | https://github.com/eventbrite/pysoa/blob/9c052cae2397d13de3df8ae2c790846a70b53f18/pysoa/common/transport/redis_gateway/backend/sentinel.py#L92-L114 | train |
Yelp/venv-update | venv_update.py | timid_relpath | def timid_relpath(arg):
"""convert an argument to a relative path, carefully"""
# TODO-TEST: unit tests
from os.path import isabs, relpath, sep
if isabs(arg):
result = relpath(arg)
if result.count(sep) + 1 < arg.count(sep):
return result
return arg | python | def timid_relpath(arg):
"""convert an argument to a relative path, carefully"""
# TODO-TEST: unit tests
from os.path import isabs, relpath, sep
if isabs(arg):
result = relpath(arg)
if result.count(sep) + 1 < arg.count(sep):
return result
return arg | [
"def",
"timid_relpath",
"(",
"arg",
")",
":",
"from",
"os",
".",
"path",
"import",
"isabs",
",",
"relpath",
",",
"sep",
"if",
"isabs",
"(",
"arg",
")",
":",
"result",
"=",
"relpath",
"(",
"arg",
")",
"if",
"result",
".",
"count",
"(",
"sep",
")",
... | convert an argument to a relative path, carefully | [
"convert",
"an",
"argument",
"to",
"a",
"relative",
"path",
"carefully"
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/venv_update.py#L104-L113 | train |
Yelp/venv-update | venv_update.py | ensure_virtualenv | def ensure_virtualenv(args, return_values):
"""Ensure we have a valid virtualenv."""
def adjust_options(options, args):
# TODO-TEST: proper error message with no arguments
venv_path = return_values.venv_path = args[0]
if venv_path == DEFAULT_VIRTUALENV_PATH or options.prompt == '<dirnam... | python | def ensure_virtualenv(args, return_values):
"""Ensure we have a valid virtualenv."""
def adjust_options(options, args):
# TODO-TEST: proper error message with no arguments
venv_path = return_values.venv_path = args[0]
if venv_path == DEFAULT_VIRTUALENV_PATH or options.prompt == '<dirnam... | [
"def",
"ensure_virtualenv",
"(",
"args",
",",
"return_values",
")",
":",
"def",
"adjust_options",
"(",
"options",
",",
"args",
")",
":",
"venv_path",
"=",
"return_values",
".",
"venv_path",
"=",
"args",
"[",
"0",
"]",
"if",
"venv_path",
"==",
"DEFAULT_VIRTUA... | Ensure we have a valid virtualenv. | [
"Ensure",
"we",
"have",
"a",
"valid",
"virtualenv",
"."
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/venv_update.py#L272-L313 | train |
Yelp/venv-update | venv_update.py | touch | def touch(filename, timestamp):
"""set the mtime of a file"""
if timestamp is not None:
timestamp = (timestamp, timestamp) # atime, mtime
from os import utime
utime(filename, timestamp) | python | def touch(filename, timestamp):
"""set the mtime of a file"""
if timestamp is not None:
timestamp = (timestamp, timestamp) # atime, mtime
from os import utime
utime(filename, timestamp) | [
"def",
"touch",
"(",
"filename",
",",
"timestamp",
")",
":",
"if",
"timestamp",
"is",
"not",
"None",
":",
"timestamp",
"=",
"(",
"timestamp",
",",
"timestamp",
")",
"from",
"os",
"import",
"utime",
"utime",
"(",
"filename",
",",
"timestamp",
")"
] | set the mtime of a file | [
"set",
"the",
"mtime",
"of",
"a",
"file"
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/venv_update.py#L328-L334 | train |
Yelp/venv-update | venv_update.py | pip_faster | def pip_faster(venv_path, pip_command, install, bootstrap_deps):
"""install and run pip-faster"""
# activate the virtualenv
execfile_(venv_executable(venv_path, 'activate_this.py'))
# disable a useless warning
# FIXME: ensure a "true SSLContext" is available
from os import environ
environ['... | python | def pip_faster(venv_path, pip_command, install, bootstrap_deps):
"""install and run pip-faster"""
# activate the virtualenv
execfile_(venv_executable(venv_path, 'activate_this.py'))
# disable a useless warning
# FIXME: ensure a "true SSLContext" is available
from os import environ
environ['... | [
"def",
"pip_faster",
"(",
"venv_path",
",",
"pip_command",
",",
"install",
",",
"bootstrap_deps",
")",
":",
"execfile_",
"(",
"venv_executable",
"(",
"venv_path",
",",
"'activate_this.py'",
")",
")",
"from",
"os",
"import",
"environ",
"environ",
"[",
"'PIP_DISAB... | install and run pip-faster | [
"install",
"and",
"run",
"pip",
"-",
"faster"
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/venv_update.py#L408-L423 | train |
Yelp/venv-update | venv_update.py | raise_on_failure | def raise_on_failure(mainfunc):
"""raise if and only if mainfunc fails"""
try:
errors = mainfunc()
if errors:
exit(errors)
except CalledProcessError as error:
exit(error.returncode)
except SystemExit as error:
if error.code:
raise
except Keyboa... | python | def raise_on_failure(mainfunc):
"""raise if and only if mainfunc fails"""
try:
errors = mainfunc()
if errors:
exit(errors)
except CalledProcessError as error:
exit(error.returncode)
except SystemExit as error:
if error.code:
raise
except Keyboa... | [
"def",
"raise_on_failure",
"(",
"mainfunc",
")",
":",
"try",
":",
"errors",
"=",
"mainfunc",
"(",
")",
"if",
"errors",
":",
"exit",
"(",
"errors",
")",
"except",
"CalledProcessError",
"as",
"error",
":",
"exit",
"(",
"error",
".",
"returncode",
")",
"exc... | raise if and only if mainfunc fails | [
"raise",
"if",
"and",
"only",
"if",
"mainfunc",
"fails"
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/venv_update.py#L426-L438 | train |
Yelp/venv-update | pip_faster.py | cache_installed_wheels | def cache_installed_wheels(index_url, installed_packages):
"""After installation, pip tells us what it installed and from where.
We build a structure that looks like
.cache/pip-faster/wheelhouse/$index_url/$wheel
"""
for installed_package in installed_packages:
if not _can_be_cached(instal... | python | def cache_installed_wheels(index_url, installed_packages):
"""After installation, pip tells us what it installed and from where.
We build a structure that looks like
.cache/pip-faster/wheelhouse/$index_url/$wheel
"""
for installed_package in installed_packages:
if not _can_be_cached(instal... | [
"def",
"cache_installed_wheels",
"(",
"index_url",
",",
"installed_packages",
")",
":",
"for",
"installed_package",
"in",
"installed_packages",
":",
"if",
"not",
"_can_be_cached",
"(",
"installed_package",
")",
":",
"continue",
"_store_wheel_in_cache",
"(",
"installed_p... | After installation, pip tells us what it installed and from where.
We build a structure that looks like
.cache/pip-faster/wheelhouse/$index_url/$wheel | [
"After",
"installation",
"pip",
"tells",
"us",
"what",
"it",
"installed",
"and",
"from",
"where",
"."
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/pip_faster.py#L171-L181 | train |
Yelp/venv-update | pip_faster.py | pip | def pip(args):
"""Run pip, in-process."""
from sys import stdout
stdout.write(colorize(('pip',) + args))
stdout.write('\n')
stdout.flush()
return pipmodule._internal.main(list(args)) | python | def pip(args):
"""Run pip, in-process."""
from sys import stdout
stdout.write(colorize(('pip',) + args))
stdout.write('\n')
stdout.flush()
return pipmodule._internal.main(list(args)) | [
"def",
"pip",
"(",
"args",
")",
":",
"from",
"sys",
"import",
"stdout",
"stdout",
".",
"write",
"(",
"colorize",
"(",
"(",
"'pip'",
",",
")",
"+",
"args",
")",
")",
"stdout",
".",
"write",
"(",
"'\\n'",
")",
"stdout",
".",
"flush",
"(",
")",
"ret... | Run pip, in-process. | [
"Run",
"pip",
"in",
"-",
"process",
"."
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/pip_faster.py#L204-L211 | train |
Yelp/venv-update | pip_faster.py | dist_to_req | def dist_to_req(dist):
"""Make a pip.FrozenRequirement from a pkg_resources distribution object"""
try: # :pragma:nocover: (pip>=10)
from pip._internal.operations.freeze import FrozenRequirement
except ImportError: # :pragma:nocover: (pip<10)
from pip import FrozenRequirement
# normal... | python | def dist_to_req(dist):
"""Make a pip.FrozenRequirement from a pkg_resources distribution object"""
try: # :pragma:nocover: (pip>=10)
from pip._internal.operations.freeze import FrozenRequirement
except ImportError: # :pragma:nocover: (pip<10)
from pip import FrozenRequirement
# normal... | [
"def",
"dist_to_req",
"(",
"dist",
")",
":",
"try",
":",
"from",
"pip",
".",
"_internal",
".",
"operations",
".",
"freeze",
"import",
"FrozenRequirement",
"except",
"ImportError",
":",
"from",
"pip",
"import",
"FrozenRequirement",
"orig_name",
",",
"dist",
"."... | Make a pip.FrozenRequirement from a pkg_resources distribution object | [
"Make",
"a",
"pip",
".",
"FrozenRequirement",
"from",
"a",
"pkg_resources",
"distribution",
"object"
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/pip_faster.py#L214-L227 | train |
Yelp/venv-update | pip_faster.py | req_cycle | def req_cycle(req):
"""is this requirement cyclic?"""
cls = req.__class__
seen = {req.name}
while isinstance(req.comes_from, cls):
req = req.comes_from
if req.name in seen:
return True
else:
seen.add(req.name)
return False | python | def req_cycle(req):
"""is this requirement cyclic?"""
cls = req.__class__
seen = {req.name}
while isinstance(req.comes_from, cls):
req = req.comes_from
if req.name in seen:
return True
else:
seen.add(req.name)
return False | [
"def",
"req_cycle",
"(",
"req",
")",
":",
"cls",
"=",
"req",
".",
"__class__",
"seen",
"=",
"{",
"req",
".",
"name",
"}",
"while",
"isinstance",
"(",
"req",
".",
"comes_from",
",",
"cls",
")",
":",
"req",
"=",
"req",
".",
"comes_from",
"if",
"req",... | is this requirement cyclic? | [
"is",
"this",
"requirement",
"cyclic?"
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/pip_faster.py#L283-L293 | train |
Yelp/venv-update | pip_faster.py | pretty_req | def pretty_req(req):
"""
return a copy of a pip requirement that is a bit more readable,
at the expense of removing some of its data
"""
from copy import copy
req = copy(req)
req.link = None
req.satisfied_by = None
return req | python | def pretty_req(req):
"""
return a copy of a pip requirement that is a bit more readable,
at the expense of removing some of its data
"""
from copy import copy
req = copy(req)
req.link = None
req.satisfied_by = None
return req | [
"def",
"pretty_req",
"(",
"req",
")",
":",
"from",
"copy",
"import",
"copy",
"req",
"=",
"copy",
"(",
"req",
")",
"req",
".",
"link",
"=",
"None",
"req",
".",
"satisfied_by",
"=",
"None",
"return",
"req"
] | return a copy of a pip requirement that is a bit more readable,
at the expense of removing some of its data | [
"return",
"a",
"copy",
"of",
"a",
"pip",
"requirement",
"that",
"is",
"a",
"bit",
"more",
"readable",
"at",
"the",
"expense",
"of",
"removing",
"some",
"of",
"its",
"data"
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/pip_faster.py#L296-L305 | train |
Yelp/venv-update | pip_faster.py | trace_requirements | def trace_requirements(requirements):
"""given an iterable of pip InstallRequirements,
return the set of required packages, given their transitive requirements.
"""
requirements = tuple(pretty_req(r) for r in requirements)
working_set = fresh_working_set()
# breadth-first traversal:
from co... | python | def trace_requirements(requirements):
"""given an iterable of pip InstallRequirements,
return the set of required packages, given their transitive requirements.
"""
requirements = tuple(pretty_req(r) for r in requirements)
working_set = fresh_working_set()
# breadth-first traversal:
from co... | [
"def",
"trace_requirements",
"(",
"requirements",
")",
":",
"requirements",
"=",
"tuple",
"(",
"pretty_req",
"(",
"r",
")",
"for",
"r",
"in",
"requirements",
")",
"working_set",
"=",
"fresh_working_set",
"(",
")",
"from",
"collections",
"import",
"deque",
"que... | given an iterable of pip InstallRequirements,
return the set of required packages, given their transitive requirements. | [
"given",
"an",
"iterable",
"of",
"pip",
"InstallRequirements",
"return",
"the",
"set",
"of",
"required",
"packages",
"given",
"their",
"transitive",
"requirements",
"."
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/pip_faster.py#L312-L359 | train |
Yelp/venv-update | pip_faster.py | patch | def patch(attrs, updates):
"""Perform a set of updates to a attribute dictionary, return the original values."""
orig = {}
for attr, value in updates:
orig[attr] = attrs[attr]
attrs[attr] = value
return orig | python | def patch(attrs, updates):
"""Perform a set of updates to a attribute dictionary, return the original values."""
orig = {}
for attr, value in updates:
orig[attr] = attrs[attr]
attrs[attr] = value
return orig | [
"def",
"patch",
"(",
"attrs",
",",
"updates",
")",
":",
"orig",
"=",
"{",
"}",
"for",
"attr",
",",
"value",
"in",
"updates",
":",
"orig",
"[",
"attr",
"]",
"=",
"attrs",
"[",
"attr",
"]",
"attrs",
"[",
"attr",
"]",
"=",
"value",
"return",
"orig"
... | Perform a set of updates to a attribute dictionary, return the original values. | [
"Perform",
"a",
"set",
"of",
"updates",
"to",
"a",
"attribute",
"dictionary",
"return",
"the",
"original",
"values",
"."
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/pip_faster.py#L430-L436 | train |
Yelp/venv-update | pip_faster.py | patched | def patched(attrs, updates):
"""A context in which some attributes temporarily have a modified value."""
orig = patch(attrs, updates.items())
try:
yield orig
finally:
patch(attrs, orig.items()) | python | def patched(attrs, updates):
"""A context in which some attributes temporarily have a modified value."""
orig = patch(attrs, updates.items())
try:
yield orig
finally:
patch(attrs, orig.items()) | [
"def",
"patched",
"(",
"attrs",
",",
"updates",
")",
":",
"orig",
"=",
"patch",
"(",
"attrs",
",",
"updates",
".",
"items",
"(",
")",
")",
"try",
":",
"yield",
"orig",
"finally",
":",
"patch",
"(",
"attrs",
",",
"orig",
".",
"items",
"(",
")",
")... | A context in which some attributes temporarily have a modified value. | [
"A",
"context",
"in",
"which",
"some",
"attributes",
"temporarily",
"have",
"a",
"modified",
"value",
"."
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/pip_faster.py#L440-L446 | train |
Yelp/venv-update | pip_faster.py | pipfaster_packagefinder | def pipfaster_packagefinder():
"""Provide a short-circuited search when the requirement is pinned and appears on disk.
Suggested upstream at: https://github.com/pypa/pip/pull/2114
"""
# A poor man's dependency injection: monkeypatch :(
try: # :pragma:nocover: pip>=18.1
from pip._internal.c... | python | def pipfaster_packagefinder():
"""Provide a short-circuited search when the requirement is pinned and appears on disk.
Suggested upstream at: https://github.com/pypa/pip/pull/2114
"""
# A poor man's dependency injection: monkeypatch :(
try: # :pragma:nocover: pip>=18.1
from pip._internal.c... | [
"def",
"pipfaster_packagefinder",
"(",
")",
":",
"try",
":",
"from",
"pip",
".",
"_internal",
".",
"cli",
"import",
"base_command",
"except",
"ImportError",
":",
"from",
"pip",
".",
"_internal",
"import",
"basecommand",
"as",
"base_command",
"return",
"patched",... | Provide a short-circuited search when the requirement is pinned and appears on disk.
Suggested upstream at: https://github.com/pypa/pip/pull/2114 | [
"Provide",
"a",
"short",
"-",
"circuited",
"search",
"when",
"the",
"requirement",
"is",
"pinned",
"and",
"appears",
"on",
"disk",
"."
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/pip_faster.py#L454-L464 | train |
Yelp/venv-update | pip_faster.py | pipfaster_download_cacher | def pipfaster_download_cacher(index_urls):
"""vanilla pip stores a cache of the http session in its cache and not the
wheel files. We intercept the download and save those files into our
cache
"""
from pip._internal import download
orig = download._download_http_url
patched_fn = get_patched... | python | def pipfaster_download_cacher(index_urls):
"""vanilla pip stores a cache of the http session in its cache and not the
wheel files. We intercept the download and save those files into our
cache
"""
from pip._internal import download
orig = download._download_http_url
patched_fn = get_patched... | [
"def",
"pipfaster_download_cacher",
"(",
"index_urls",
")",
":",
"from",
"pip",
".",
"_internal",
"import",
"download",
"orig",
"=",
"download",
".",
"_download_http_url",
"patched_fn",
"=",
"get_patched_download_http_url",
"(",
"orig",
",",
"index_urls",
")",
"retu... | vanilla pip stores a cache of the http session in its cache and not the
wheel files. We intercept the download and save those files into our
cache | [
"vanilla",
"pip",
"stores",
"a",
"cache",
"of",
"the",
"http",
"session",
"in",
"its",
"cache",
"and",
"not",
"the",
"wheel",
"files",
".",
"We",
"intercept",
"the",
"download",
"and",
"save",
"those",
"files",
"into",
"our",
"cache"
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/pip_faster.py#L467-L475 | train |
Yelp/venv-update | pip_faster.py | FasterInstallCommand.run | def run(self, options, args):
"""update install options with caching values"""
if options.prune:
previously_installed = pip_get_installed()
index_urls = [options.index_url] + options.extra_index_urls
with pipfaster_download_cacher(index_urls):
requirement_set = s... | python | def run(self, options, args):
"""update install options with caching values"""
if options.prune:
previously_installed = pip_get_installed()
index_urls = [options.index_url] + options.extra_index_urls
with pipfaster_download_cacher(index_urls):
requirement_set = s... | [
"def",
"run",
"(",
"self",
",",
"options",
",",
"args",
")",
":",
"if",
"options",
".",
"prune",
":",
"previously_installed",
"=",
"pip_get_installed",
"(",
")",
"index_urls",
"=",
"[",
"options",
".",
"index_url",
"]",
"+",
"options",
".",
"extra_index_ur... | update install options with caching values | [
"update",
"install",
"options",
"with",
"caching",
"values"
] | 6feae7ab09ee870c582b97443cfa8f0dc8626ba7 | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/pip_faster.py#L387-L423 | train |
RedisJSON/rejson-py | rejson/client.py | Client.setEncoder | def setEncoder(self, encoder):
"""
Sets the client's encoder
``encoder`` should be an instance of a ``json.JSONEncoder`` class
"""
if not encoder:
self._encoder = json.JSONEncoder()
else:
self._encoder = encoder
self._encode = self._encoder... | python | def setEncoder(self, encoder):
"""
Sets the client's encoder
``encoder`` should be an instance of a ``json.JSONEncoder`` class
"""
if not encoder:
self._encoder = json.JSONEncoder()
else:
self._encoder = encoder
self._encode = self._encoder... | [
"def",
"setEncoder",
"(",
"self",
",",
"encoder",
")",
":",
"if",
"not",
"encoder",
":",
"self",
".",
"_encoder",
"=",
"json",
".",
"JSONEncoder",
"(",
")",
"else",
":",
"self",
".",
"_encoder",
"=",
"encoder",
"self",
".",
"_encode",
"=",
"self",
".... | Sets the client's encoder
``encoder`` should be an instance of a ``json.JSONEncoder`` class | [
"Sets",
"the",
"client",
"s",
"encoder",
"encoder",
"should",
"be",
"an",
"instance",
"of",
"a",
"json",
".",
"JSONEncoder",
"class"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L78-L87 | train |
RedisJSON/rejson-py | rejson/client.py | Client.setDecoder | def setDecoder(self, decoder):
"""
Sets the client's decoder
``decoder`` should be an instance of a ``json.JSONDecoder`` class
"""
if not decoder:
self._decoder = json.JSONDecoder()
else:
self._decoder = decoder
self._decode = self._decoder... | python | def setDecoder(self, decoder):
"""
Sets the client's decoder
``decoder`` should be an instance of a ``json.JSONDecoder`` class
"""
if not decoder:
self._decoder = json.JSONDecoder()
else:
self._decoder = decoder
self._decode = self._decoder... | [
"def",
"setDecoder",
"(",
"self",
",",
"decoder",
")",
":",
"if",
"not",
"decoder",
":",
"self",
".",
"_decoder",
"=",
"json",
".",
"JSONDecoder",
"(",
")",
"else",
":",
"self",
".",
"_decoder",
"=",
"decoder",
"self",
".",
"_decode",
"=",
"self",
".... | Sets the client's decoder
``decoder`` should be an instance of a ``json.JSONDecoder`` class | [
"Sets",
"the",
"client",
"s",
"decoder",
"decoder",
"should",
"be",
"an",
"instance",
"of",
"a",
"json",
".",
"JSONDecoder",
"class"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L89-L98 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsondel | def jsondel(self, name, path=Path.rootPath()):
"""
Deletes the JSON value stored at key ``name`` under ``path``
"""
return self.execute_command('JSON.DEL', name, str_path(path)) | python | def jsondel(self, name, path=Path.rootPath()):
"""
Deletes the JSON value stored at key ``name`` under ``path``
"""
return self.execute_command('JSON.DEL', name, str_path(path)) | [
"def",
"jsondel",
"(",
"self",
",",
"name",
",",
"path",
"=",
"Path",
".",
"rootPath",
"(",
")",
")",
":",
"return",
"self",
".",
"execute_command",
"(",
"'JSON.DEL'",
",",
"name",
",",
"str_path",
"(",
"path",
")",
")"
] | Deletes the JSON value stored at key ``name`` under ``path`` | [
"Deletes",
"the",
"JSON",
"value",
"stored",
"at",
"key",
"name",
"under",
"path"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L100-L104 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsonget | def jsonget(self, name, *args):
"""
Get the object stored as a JSON value at key ``name``
``args`` is zero or more paths, and defaults to root path
"""
pieces = [name]
if len(args) == 0:
pieces.append(Path.rootPath())
else:
for p in args:
... | python | def jsonget(self, name, *args):
"""
Get the object stored as a JSON value at key ``name``
``args`` is zero or more paths, and defaults to root path
"""
pieces = [name]
if len(args) == 0:
pieces.append(Path.rootPath())
else:
for p in args:
... | [
"def",
"jsonget",
"(",
"self",
",",
"name",
",",
"*",
"args",
")",
":",
"pieces",
"=",
"[",
"name",
"]",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
"pieces",
".",
"append",
"(",
"Path",
".",
"rootPath",
"(",
")",
")",
"else",
":",
"for",
... | Get the object stored as a JSON value at key ``name``
``args`` is zero or more paths, and defaults to root path | [
"Get",
"the",
"object",
"stored",
"as",
"a",
"JSON",
"value",
"at",
"key",
"name",
"args",
"is",
"zero",
"or",
"more",
"paths",
"and",
"defaults",
"to",
"root",
"path"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L106-L123 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsonmget | def jsonmget(self, path, *args):
"""
Gets the objects stored as a JSON values under ``path`` from
keys ``args``
"""
pieces = []
pieces.extend(args)
pieces.append(str_path(path))
return self.execute_command('JSON.MGET', *pieces) | python | def jsonmget(self, path, *args):
"""
Gets the objects stored as a JSON values under ``path`` from
keys ``args``
"""
pieces = []
pieces.extend(args)
pieces.append(str_path(path))
return self.execute_command('JSON.MGET', *pieces) | [
"def",
"jsonmget",
"(",
"self",
",",
"path",
",",
"*",
"args",
")",
":",
"pieces",
"=",
"[",
"]",
"pieces",
".",
"extend",
"(",
"args",
")",
"pieces",
".",
"append",
"(",
"str_path",
"(",
"path",
")",
")",
"return",
"self",
".",
"execute_command",
... | Gets the objects stored as a JSON values under ``path`` from
keys ``args`` | [
"Gets",
"the",
"objects",
"stored",
"as",
"a",
"JSON",
"values",
"under",
"path",
"from",
"keys",
"args"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L125-L133 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsonset | def jsonset(self, name, path, obj, nx=False, xx=False):
"""
Set the JSON value at key ``name`` under the ``path`` to ``obj``
``nx`` if set to True, set ``value`` only if it does not exist
``xx`` if set to True, set ``value`` only if it exists
"""
pieces = [name, str_path(... | python | def jsonset(self, name, path, obj, nx=False, xx=False):
"""
Set the JSON value at key ``name`` under the ``path`` to ``obj``
``nx`` if set to True, set ``value`` only if it does not exist
``xx`` if set to True, set ``value`` only if it exists
"""
pieces = [name, str_path(... | [
"def",
"jsonset",
"(",
"self",
",",
"name",
",",
"path",
",",
"obj",
",",
"nx",
"=",
"False",
",",
"xx",
"=",
"False",
")",
":",
"pieces",
"=",
"[",
"name",
",",
"str_path",
"(",
"path",
")",
",",
"self",
".",
"_encode",
"(",
"obj",
")",
"]",
... | Set the JSON value at key ``name`` under the ``path`` to ``obj``
``nx`` if set to True, set ``value`` only if it does not exist
``xx`` if set to True, set ``value`` only if it exists | [
"Set",
"the",
"JSON",
"value",
"at",
"key",
"name",
"under",
"the",
"path",
"to",
"obj",
"nx",
"if",
"set",
"to",
"True",
"set",
"value",
"only",
"if",
"it",
"does",
"not",
"exist",
"xx",
"if",
"set",
"to",
"True",
"set",
"value",
"only",
"if",
"it... | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L135-L151 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsontype | def jsontype(self, name, path=Path.rootPath()):
"""
Gets the type of the JSON value under ``path`` from key ``name``
"""
return self.execute_command('JSON.TYPE', name, str_path(path)) | python | def jsontype(self, name, path=Path.rootPath()):
"""
Gets the type of the JSON value under ``path`` from key ``name``
"""
return self.execute_command('JSON.TYPE', name, str_path(path)) | [
"def",
"jsontype",
"(",
"self",
",",
"name",
",",
"path",
"=",
"Path",
".",
"rootPath",
"(",
")",
")",
":",
"return",
"self",
".",
"execute_command",
"(",
"'JSON.TYPE'",
",",
"name",
",",
"str_path",
"(",
"path",
")",
")"
] | Gets the type of the JSON value under ``path`` from key ``name`` | [
"Gets",
"the",
"type",
"of",
"the",
"JSON",
"value",
"under",
"path",
"from",
"key",
"name"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L153-L157 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsonstrappend | def jsonstrappend(self, name, string, path=Path.rootPath()):
"""
Appends to the string JSON value under ``path`` at key ``name`` the
provided ``string``
"""
return self.execute_command('JSON.STRAPPEND', name, str_path(path), self._encode(string)) | python | def jsonstrappend(self, name, string, path=Path.rootPath()):
"""
Appends to the string JSON value under ``path`` at key ``name`` the
provided ``string``
"""
return self.execute_command('JSON.STRAPPEND', name, str_path(path), self._encode(string)) | [
"def",
"jsonstrappend",
"(",
"self",
",",
"name",
",",
"string",
",",
"path",
"=",
"Path",
".",
"rootPath",
"(",
")",
")",
":",
"return",
"self",
".",
"execute_command",
"(",
"'JSON.STRAPPEND'",
",",
"name",
",",
"str_path",
"(",
"path",
")",
",",
"sel... | Appends to the string JSON value under ``path`` at key ``name`` the
provided ``string`` | [
"Appends",
"to",
"the",
"string",
"JSON",
"value",
"under",
"path",
"at",
"key",
"name",
"the",
"provided",
"string"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L173-L178 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsonstrlen | def jsonstrlen(self, name, path=Path.rootPath()):
"""
Returns the length of the string JSON value under ``path`` at key
``name``
"""
return self.execute_command('JSON.STRLEN', name, str_path(path)) | python | def jsonstrlen(self, name, path=Path.rootPath()):
"""
Returns the length of the string JSON value under ``path`` at key
``name``
"""
return self.execute_command('JSON.STRLEN', name, str_path(path)) | [
"def",
"jsonstrlen",
"(",
"self",
",",
"name",
",",
"path",
"=",
"Path",
".",
"rootPath",
"(",
")",
")",
":",
"return",
"self",
".",
"execute_command",
"(",
"'JSON.STRLEN'",
",",
"name",
",",
"str_path",
"(",
"path",
")",
")"
] | Returns the length of the string JSON value under ``path`` at key
``name`` | [
"Returns",
"the",
"length",
"of",
"the",
"string",
"JSON",
"value",
"under",
"path",
"at",
"key",
"name"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L180-L185 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsonarrappend | def jsonarrappend(self, name, path=Path.rootPath(), *args):
"""
Appends the objects ``args`` to the array under the ``path` in key
``name``
"""
pieces = [name, str_path(path)]
for o in args:
pieces.append(self._encode(o))
return self.execute_command('J... | python | def jsonarrappend(self, name, path=Path.rootPath(), *args):
"""
Appends the objects ``args`` to the array under the ``path` in key
``name``
"""
pieces = [name, str_path(path)]
for o in args:
pieces.append(self._encode(o))
return self.execute_command('J... | [
"def",
"jsonarrappend",
"(",
"self",
",",
"name",
",",
"path",
"=",
"Path",
".",
"rootPath",
"(",
")",
",",
"*",
"args",
")",
":",
"pieces",
"=",
"[",
"name",
",",
"str_path",
"(",
"path",
")",
"]",
"for",
"o",
"in",
"args",
":",
"pieces",
".",
... | Appends the objects ``args`` to the array under the ``path` in key
``name`` | [
"Appends",
"the",
"objects",
"args",
"to",
"the",
"array",
"under",
"the",
"path",
"in",
"key",
"name"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L187-L195 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsonarrindex | def jsonarrindex(self, name, path, scalar, start=0, stop=-1):
"""
Returns the index of ``scalar`` in the JSON array under ``path`` at key
``name``. The search can be limited using the optional inclusive
``start`` and exclusive ``stop`` indices.
"""
return self.execute_com... | python | def jsonarrindex(self, name, path, scalar, start=0, stop=-1):
"""
Returns the index of ``scalar`` in the JSON array under ``path`` at key
``name``. The search can be limited using the optional inclusive
``start`` and exclusive ``stop`` indices.
"""
return self.execute_com... | [
"def",
"jsonarrindex",
"(",
"self",
",",
"name",
",",
"path",
",",
"scalar",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"-",
"1",
")",
":",
"return",
"self",
".",
"execute_command",
"(",
"'JSON.ARRINDEX'",
",",
"name",
",",
"str_path",
"(",
"path",
")... | Returns the index of ``scalar`` in the JSON array under ``path`` at key
``name``. The search can be limited using the optional inclusive
``start`` and exclusive ``stop`` indices. | [
"Returns",
"the",
"index",
"of",
"scalar",
"in",
"the",
"JSON",
"array",
"under",
"path",
"at",
"key",
"name",
".",
"The",
"search",
"can",
"be",
"limited",
"using",
"the",
"optional",
"inclusive",
"start",
"and",
"exclusive",
"stop",
"indices",
"."
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L197-L203 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsonarrinsert | def jsonarrinsert(self, name, path, index, *args):
"""
Inserts the objects ``args`` to the array at index ``index`` under the
``path` in key ``name``
"""
pieces = [name, str_path(path), index]
for o in args:
pieces.append(self._encode(o))
return self.e... | python | def jsonarrinsert(self, name, path, index, *args):
"""
Inserts the objects ``args`` to the array at index ``index`` under the
``path` in key ``name``
"""
pieces = [name, str_path(path), index]
for o in args:
pieces.append(self._encode(o))
return self.e... | [
"def",
"jsonarrinsert",
"(",
"self",
",",
"name",
",",
"path",
",",
"index",
",",
"*",
"args",
")",
":",
"pieces",
"=",
"[",
"name",
",",
"str_path",
"(",
"path",
")",
",",
"index",
"]",
"for",
"o",
"in",
"args",
":",
"pieces",
".",
"append",
"("... | Inserts the objects ``args`` to the array at index ``index`` under the
``path` in key ``name`` | [
"Inserts",
"the",
"objects",
"args",
"to",
"the",
"array",
"at",
"index",
"index",
"under",
"the",
"path",
"in",
"key",
"name"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L205-L213 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsonarrlen | def jsonarrlen(self, name, path=Path.rootPath()):
"""
Returns the length of the array JSON value under ``path`` at key
``name``
"""
return self.execute_command('JSON.ARRLEN', name, str_path(path)) | python | def jsonarrlen(self, name, path=Path.rootPath()):
"""
Returns the length of the array JSON value under ``path`` at key
``name``
"""
return self.execute_command('JSON.ARRLEN', name, str_path(path)) | [
"def",
"jsonarrlen",
"(",
"self",
",",
"name",
",",
"path",
"=",
"Path",
".",
"rootPath",
"(",
")",
")",
":",
"return",
"self",
".",
"execute_command",
"(",
"'JSON.ARRLEN'",
",",
"name",
",",
"str_path",
"(",
"path",
")",
")"
] | Returns the length of the array JSON value under ``path`` at key
``name`` | [
"Returns",
"the",
"length",
"of",
"the",
"array",
"JSON",
"value",
"under",
"path",
"at",
"key",
"name"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L215-L220 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsonarrpop | def jsonarrpop(self, name, path=Path.rootPath(), index=-1):
"""
Pops the element at ``index`` in the array JSON value under ``path`` at
key ``name``
"""
return self.execute_command('JSON.ARRPOP', name, str_path(path), index) | python | def jsonarrpop(self, name, path=Path.rootPath(), index=-1):
"""
Pops the element at ``index`` in the array JSON value under ``path`` at
key ``name``
"""
return self.execute_command('JSON.ARRPOP', name, str_path(path), index) | [
"def",
"jsonarrpop",
"(",
"self",
",",
"name",
",",
"path",
"=",
"Path",
".",
"rootPath",
"(",
")",
",",
"index",
"=",
"-",
"1",
")",
":",
"return",
"self",
".",
"execute_command",
"(",
"'JSON.ARRPOP'",
",",
"name",
",",
"str_path",
"(",
"path",
")",... | Pops the element at ``index`` in the array JSON value under ``path`` at
key ``name`` | [
"Pops",
"the",
"element",
"at",
"index",
"in",
"the",
"array",
"JSON",
"value",
"under",
"path",
"at",
"key",
"name"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L222-L227 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsonarrtrim | def jsonarrtrim(self, name, path, start, stop):
"""
Trim the array JSON value under ``path`` at key ``name`` to the
inclusive range given by ``start`` and ``stop``
"""
return self.execute_command('JSON.ARRTRIM', name, str_path(path), start, stop) | python | def jsonarrtrim(self, name, path, start, stop):
"""
Trim the array JSON value under ``path`` at key ``name`` to the
inclusive range given by ``start`` and ``stop``
"""
return self.execute_command('JSON.ARRTRIM', name, str_path(path), start, stop) | [
"def",
"jsonarrtrim",
"(",
"self",
",",
"name",
",",
"path",
",",
"start",
",",
"stop",
")",
":",
"return",
"self",
".",
"execute_command",
"(",
"'JSON.ARRTRIM'",
",",
"name",
",",
"str_path",
"(",
"path",
")",
",",
"start",
",",
"stop",
")"
] | Trim the array JSON value under ``path`` at key ``name`` to the
inclusive range given by ``start`` and ``stop`` | [
"Trim",
"the",
"array",
"JSON",
"value",
"under",
"path",
"at",
"key",
"name",
"to",
"the",
"inclusive",
"range",
"given",
"by",
"start",
"and",
"stop"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L229-L234 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsonobjkeys | def jsonobjkeys(self, name, path=Path.rootPath()):
"""
Returns the key names in the dictionary JSON value under ``path`` at key
``name``
"""
return self.execute_command('JSON.OBJKEYS', name, str_path(path)) | python | def jsonobjkeys(self, name, path=Path.rootPath()):
"""
Returns the key names in the dictionary JSON value under ``path`` at key
``name``
"""
return self.execute_command('JSON.OBJKEYS', name, str_path(path)) | [
"def",
"jsonobjkeys",
"(",
"self",
",",
"name",
",",
"path",
"=",
"Path",
".",
"rootPath",
"(",
")",
")",
":",
"return",
"self",
".",
"execute_command",
"(",
"'JSON.OBJKEYS'",
",",
"name",
",",
"str_path",
"(",
"path",
")",
")"
] | Returns the key names in the dictionary JSON value under ``path`` at key
``name`` | [
"Returns",
"the",
"key",
"names",
"in",
"the",
"dictionary",
"JSON",
"value",
"under",
"path",
"at",
"key",
"name"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L236-L241 | train |
RedisJSON/rejson-py | rejson/client.py | Client.jsonobjlen | def jsonobjlen(self, name, path=Path.rootPath()):
"""
Returns the length of the dictionary JSON value under ``path`` at key
``name``
"""
return self.execute_command('JSON.OBJLEN', name, str_path(path)) | python | def jsonobjlen(self, name, path=Path.rootPath()):
"""
Returns the length of the dictionary JSON value under ``path`` at key
``name``
"""
return self.execute_command('JSON.OBJLEN', name, str_path(path)) | [
"def",
"jsonobjlen",
"(",
"self",
",",
"name",
",",
"path",
"=",
"Path",
".",
"rootPath",
"(",
")",
")",
":",
"return",
"self",
".",
"execute_command",
"(",
"'JSON.OBJLEN'",
",",
"name",
",",
"str_path",
"(",
"path",
")",
")"
] | Returns the length of the dictionary JSON value under ``path`` at key
``name`` | [
"Returns",
"the",
"length",
"of",
"the",
"dictionary",
"JSON",
"value",
"under",
"path",
"at",
"key",
"name"
] | 55f0adf3adc40f5a769e28e541dbbf5377b90ec6 | https://github.com/RedisJSON/rejson-py/blob/55f0adf3adc40f5a769e28e541dbbf5377b90ec6/rejson/client.py#L243-L248 | train |
mitodl/django-server-status | server_status/views.py | get_pg_info | def get_pg_info():
"""Check PostgreSQL connection."""
from psycopg2 import connect, OperationalError
log.debug("entered get_pg_info")
try:
conf = settings.DATABASES['default']
database = conf["NAME"]
user = conf["USER"]
host = conf["HOST"]
port = conf["PORT"]
... | python | def get_pg_info():
"""Check PostgreSQL connection."""
from psycopg2 import connect, OperationalError
log.debug("entered get_pg_info")
try:
conf = settings.DATABASES['default']
database = conf["NAME"]
user = conf["USER"]
host = conf["HOST"]
port = conf["PORT"]
... | [
"def",
"get_pg_info",
"(",
")",
":",
"from",
"psycopg2",
"import",
"connect",
",",
"OperationalError",
"log",
".",
"debug",
"(",
"\"entered get_pg_info\"",
")",
"try",
":",
"conf",
"=",
"settings",
".",
"DATABASES",
"[",
"'default'",
"]",
"database",
"=",
"c... | Check PostgreSQL connection. | [
"Check",
"PostgreSQL",
"connection",
"."
] | 99bd29343138f94a08718fdbd9285e551751777b | https://github.com/mitodl/django-server-status/blob/99bd29343138f94a08718fdbd9285e551751777b/server_status/views.py#L30-L61 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.