_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q22700 | load_builtin_plugins | train | def load_builtin_plugins() -> int:
"""
Load built-in plugins distributed along with "nonebot" package.
"""
plugin_dir = os.path.join(os.path.dirname(__file__), 'plugins')
return load_plugins(plugin_dir, 'nonebot.plugins') | python | {
"resource": ""
} |
q22701 | _extract_image_urls | train | def _extract_image_urls(arg: Message_T) -> List[str]:
"""Extract all image urls from a message-like object."""
arg_as_msg = Message(arg)
return [s.data['url'] for s in arg_as_msg
if s.type == 'image' and 'url' in s.data] | python | {
"resource": ""
} |
q22702 | on_natural_language | train | def on_natural_language(keywords: Union[Optional[Iterable], Callable] = None,
*, permission: int = perm.EVERYBODY,
only_to_me: bool = True,
only_short_message: bool = True,
allow_empty_message: bool = False) -> Callable:
... | python | {
"resource": ""
} |
q22703 | handle_natural_language | train | async def handle_natural_language(bot: NoneBot, ctx: Context_T) -> bool:
"""
Handle a message as natural language.
This function is typically called by "handle_message".
:param bot: NoneBot instance
:param ctx: message context
:return: the message is handled as natural language
"""
ses... | python | {
"resource": ""
} |
q22704 | check_permission | train | async def check_permission(bot: NoneBot, ctx: Context_T,
permission_required: int) -> bool:
"""
Check if the context has the permission required.
:param bot: NoneBot instance
:param ctx: message context
:param permission_required: permission required
:return: the cont... | python | {
"resource": ""
} |
q22705 | match_regex | train | def match_regex(pattern: str, message=None, *, flags=0,
fullmatch: bool = False) -> Filter_T:
"""
Validate any string object to ensure it matches a given pattern.
"""
pattern = re.compile(pattern, flags)
def validate(value):
if fullmatch:
if not re.fullmatch(pat... | python | {
"resource": ""
} |
q22706 | ensure_true | train | def ensure_true(bool_func: Callable[[Any], bool],
message=None) -> Filter_T:
"""
Validate any object to ensure the result of applying
a boolean function to it is True.
"""
def validate(value):
if bool_func(value) is not True:
_raise_failure(message)
retur... | python | {
"resource": ""
} |
q22707 | between_inclusive | train | def between_inclusive(start=None, end=None, message=None) -> Filter_T:
"""
Validate any comparable object to ensure it's between
`start` and `end` inclusively.
"""
def validate(value):
if start is not None and value < start:
_raise_failure(message)
if end is not None and... | python | {
"resource": ""
} |
q22708 | check_docstring_first | train | def check_docstring_first(src, filename='<unknown>'):
# type: (bytes, str) -> int
"""Returns nonzero if the source has what looks like a docstring that is
not at the beginning of the source.
A string will be considered a docstring if it is a STRING token with a
col offset of 0.
"""
found_do... | python | {
"resource": ""
} |
q22709 | get_aws_secrets_from_env | train | def get_aws_secrets_from_env(): # type: () -> Set[str]
"""Extract AWS secrets from environment variables."""
keys = set()
for env_var in (
'AWS_SECRET_ACCESS_KEY', 'AWS_SECURITY_TOKEN', 'AWS_SESSION_TOKEN',
):
if env_var in os.environ:
keys.add(os.environ[env_var])
retur... | python | {
"resource": ""
} |
q22710 | get_aws_secrets_from_file | train | def get_aws_secrets_from_file(credentials_file): # type: (str) -> Set[str]
"""Extract AWS secrets from configuration files.
Read an ini-style configuration file and return a set with all found AWS
secret access keys.
"""
aws_credentials_file_path = os.path.expanduser(credentials_file)
if not o... | python | {
"resource": ""
} |
q22711 | check_file_for_aws_keys | train | def check_file_for_aws_keys(filenames, keys):
# type: (Sequence[str], Set[str]) -> List[Dict[str, str]]
"""Check if files contain AWS secrets.
Return a list of all files containing AWS secrets and keys found, with all
but the first four characters obfuscated to ease debugging.
"""
bad_files = [... | python | {
"resource": ""
} |
q22712 | sort | train | def sort(lines): # type: (List[str]) -> List[str]
"""Sort a YAML file in alphabetical order, keeping blocks together.
:param lines: array of strings (without newlines)
:return: sorted array of strings
"""
# make a copy of lines since we will clobber it
lines = list(lines)
new_lines = parse... | python | {
"resource": ""
} |
q22713 | parse_block | train | def parse_block(lines, header=False): # type: (List[str], bool) -> List[str]
"""Parse and return a single block, popping off the start of `lines`.
If parsing a header block, we stop after we reach a line that is not a
comment. Otherwise, we stop after reaching an empty line.
:param lines: list of lin... | python | {
"resource": ""
} |
q22714 | parse_blocks | train | def parse_blocks(lines): # type: (List[str]) -> List[List[str]]
"""Parse and return all possible blocks, popping off the start of `lines`.
:param lines: list of lines
:return: list of blocks, where each block is a list of lines
"""
blocks = []
while lines:
if lines[0] == '':
... | python | {
"resource": ""
} |
q22715 | first_key | train | def first_key(lines): # type: (List[str]) -> str
"""Returns a string representing the sort key of a block.
The sort key is the first YAML key we encounter, ignoring comments, and
stripping leading quotes.
>>> print(test)
# some comment
'foo': true
>>> first_key(test)
'foo'
"""
... | python | {
"resource": ""
} |
q22716 | create_sentinel | train | async def create_sentinel(sentinels, *, db=None, password=None,
encoding=None, minsize=1, maxsize=10,
ssl=None, timeout=0.2, loop=None):
"""Creates Redis Sentinel client.
`sentinels` is a list of sentinel nodes.
"""
if loop is None:
loop = as... | python | {
"resource": ""
} |
q22717 | RedisSentinel.execute | train | def execute(self, command, *args, **kwargs):
"""Execute Sentinel command.
It will be prefixed with SENTINEL automatically.
"""
return self._pool.execute(
b'SENTINEL', command, *args, **kwargs) | python | {
"resource": ""
} |
q22718 | RedisSentinel.master | train | def master(self, name):
"""Returns a dictionary containing the specified masters state."""
fut = self.execute(b'MASTER', name, encoding='utf-8')
return wait_convert(fut, parse_sentinel_master) | python | {
"resource": ""
} |
q22719 | RedisSentinel.masters | train | def masters(self):
"""Returns a list of dictionaries containing each master's state."""
fut = self.execute(b'MASTERS', encoding='utf-8')
# TODO: process masters: we can adjust internal state
return wait_convert(fut, parse_sentinel_masters) | python | {
"resource": ""
} |
q22720 | RedisSentinel.slaves | train | def slaves(self, name):
"""Returns a list of slaves for ``name``."""
fut = self.execute(b'SLAVES', name, encoding='utf-8')
return wait_convert(fut, parse_sentinel_slaves_and_sentinels) | python | {
"resource": ""
} |
q22721 | RedisSentinel.sentinels | train | def sentinels(self, name):
"""Returns a list of sentinels for ``name``."""
fut = self.execute(b'SENTINELS', name, encoding='utf-8')
return wait_convert(fut, parse_sentinel_slaves_and_sentinels) | python | {
"resource": ""
} |
q22722 | RedisSentinel.monitor | train | def monitor(self, name, ip, port, quorum):
"""Add a new master to Sentinel to be monitored."""
fut = self.execute(b'MONITOR', name, ip, port, quorum)
return wait_ok(fut) | python | {
"resource": ""
} |
q22723 | RedisSentinel.remove | train | def remove(self, name):
"""Remove a master from Sentinel's monitoring."""
fut = self.execute(b'REMOVE', name)
return wait_ok(fut) | python | {
"resource": ""
} |
q22724 | RedisSentinel.set | train | def set(self, name, option, value):
"""Set Sentinel monitoring parameters for a given master."""
fut = self.execute(b"SET", name, option, value)
return wait_ok(fut) | python | {
"resource": ""
} |
q22725 | RedisSentinel.failover | train | def failover(self, name):
"""Force a failover of a named master."""
fut = self.execute(b'FAILOVER', name)
return wait_ok(fut) | python | {
"resource": ""
} |
q22726 | ListCommandsMixin.blpop | train | def blpop(self, key, *keys, timeout=0, encoding=_NOTSET):
"""Remove and get the first element in a list, or block until
one is available.
:raises TypeError: if timeout is not int
:raises ValueError: if timeout is less than 0
"""
if not isinstance(timeout, int):
... | python | {
"resource": ""
} |
q22727 | ListCommandsMixin.lindex | train | def lindex(self, key, index, *, encoding=_NOTSET):
"""Get an element from a list by its index.
:raises TypeError: if index is not int
"""
if not isinstance(index, int):
raise TypeError("index argument must be int")
return self.execute(b'LINDEX', key, index, encoding=... | python | {
"resource": ""
} |
q22728 | ListCommandsMixin.linsert | train | def linsert(self, key, pivot, value, before=False):
"""Inserts value in the list stored at key either before or
after the reference value pivot.
"""
where = b'AFTER' if not before else b'BEFORE'
return self.execute(b'LINSERT', key, where, pivot, value) | python | {
"resource": ""
} |
q22729 | ListCommandsMixin.lpop | train | def lpop(self, key, *, encoding=_NOTSET):
"""Removes and returns the first element of the list stored at key."""
return self.execute(b'LPOP', key, encoding=encoding) | python | {
"resource": ""
} |
q22730 | ListCommandsMixin.lrem | train | def lrem(self, key, count, value):
"""Removes the first count occurrences of elements equal to value
from the list stored at key.
:raises TypeError: if count is not int
"""
if not isinstance(count, int):
raise TypeError("count argument must be int")
return se... | python | {
"resource": ""
} |
q22731 | ListCommandsMixin.lset | train | def lset(self, key, index, value):
"""Sets the list element at index to value.
:raises TypeError: if index is not int
"""
if not isinstance(index, int):
raise TypeError("index argument must be int")
return self.execute(b'LSET', key, index, value) | python | {
"resource": ""
} |
q22732 | ListCommandsMixin.ltrim | train | def ltrim(self, key, start, stop):
"""Trim an existing list so that it will contain only the specified
range of elements specified.
:raises TypeError: if start or stop is not int
"""
if not isinstance(start, int):
raise TypeError("start argument must be int")
... | python | {
"resource": ""
} |
q22733 | ListCommandsMixin.rpop | train | def rpop(self, key, *, encoding=_NOTSET):
"""Removes and returns the last element of the list stored at key."""
return self.execute(b'RPOP', key, encoding=encoding) | python | {
"resource": ""
} |
q22734 | Pipeline.execute | train | async def execute(self, *, return_exceptions=False):
"""Execute all buffered commands.
Any exception that is raised by any command is caught and
raised later when processing results.
Exceptions can also be returned in result if
`return_exceptions` flag is set to True.
"... | python | {
"resource": ""
} |
q22735 | StreamReader.readobj | train | async def readobj(self):
"""
Return a parsed Redis object or an exception
when something wrong happened.
"""
assert self._parser is not None, "set_parser must be called"
while True:
obj = self._parser.gets()
if obj is not False:
# ... | python | {
"resource": ""
} |
q22736 | ServerCommandsMixin.client_list | train | def client_list(self):
"""Get the list of client connections.
Returns list of ClientInfo named tuples.
"""
fut = self.execute(b'CLIENT', b'LIST', encoding='utf-8')
return wait_convert(fut, to_tuples) | python | {
"resource": ""
} |
q22737 | ServerCommandsMixin.client_getname | train | def client_getname(self, encoding=_NOTSET):
"""Get the current connection name."""
return self.execute(b'CLIENT', b'GETNAME', encoding=encoding) | python | {
"resource": ""
} |
q22738 | ServerCommandsMixin.client_setname | train | def client_setname(self, name):
"""Set the current connection name."""
fut = self.execute(b'CLIENT', b'SETNAME', name)
return wait_ok(fut) | python | {
"resource": ""
} |
q22739 | ServerCommandsMixin.command_getkeys | train | def command_getkeys(self, command, *args, encoding='utf-8'):
"""Extract keys given a full Redis command."""
return self.execute(b'COMMAND', b'GETKEYS', command, *args,
encoding=encoding) | python | {
"resource": ""
} |
q22740 | ServerCommandsMixin.command_info | train | def command_info(self, command, *commands):
"""Get array of specific Redis command details."""
return self.execute(b'COMMAND', b'INFO', command, *commands,
encoding='utf-8') | python | {
"resource": ""
} |
q22741 | ServerCommandsMixin.config_set | train | def config_set(self, parameter, value):
"""Set a configuration parameter to the given value."""
if not isinstance(parameter, str):
raise TypeError("parameter must be str")
fut = self.execute(b'CONFIG', b'SET', parameter, value)
return wait_ok(fut) | python | {
"resource": ""
} |
q22742 | ServerCommandsMixin.debug_sleep | train | def debug_sleep(self, timeout):
"""Suspend connection for timeout seconds."""
fut = self.execute(b'DEBUG', b'SLEEP', timeout)
return wait_ok(fut) | python | {
"resource": ""
} |
q22743 | ServerCommandsMixin.flushall | train | def flushall(self, async_op=False):
"""
Remove all keys from all databases.
:param async_op: lets the entire dataset to be freed asynchronously. \
Defaults to False
"""
if async_op:
fut = self.execute(b'FLUSHALL', b'ASYNC')
else:
fut = sel... | python | {
"resource": ""
} |
q22744 | ServerCommandsMixin.flushdb | train | def flushdb(self, async_op=False):
"""
Remove all keys from the current database.
:param async_op: lets a single database to be freed asynchronously. \
Defaults to False
"""
if async_op:
fut = self.execute(b'FLUSHDB', b'ASYNC')
else:
fut =... | python | {
"resource": ""
} |
q22745 | ServerCommandsMixin.info | train | def info(self, section='default'):
"""Get information and statistics about the server.
If called without argument will return default set of sections.
For available sections, see http://redis.io/commands/INFO
:raises ValueError: if section is invalid
"""
if not section... | python | {
"resource": ""
} |
q22746 | ServerCommandsMixin.role | train | def role(self):
"""Return the role of the server instance.
Returns named tuples describing role of the instance.
For fields information see http://redis.io/commands/role#output-format
"""
fut = self.execute(b'ROLE', encoding='utf-8')
return wait_convert(fut, parse_role) | python | {
"resource": ""
} |
q22747 | ServerCommandsMixin.shutdown | train | def shutdown(self, save=None):
"""Synchronously save the dataset to disk and then
shut down the server.
"""
if save is self.SHUTDOWN_SAVE:
return self.execute(b'SHUTDOWN', b'SAVE')
elif save is self.SHUTDOWN_NOSAVE:
return self.execute(b'SHUTDOWN', b'NOSAV... | python | {
"resource": ""
} |
q22748 | ServerCommandsMixin.slaveof | train | def slaveof(self, host, port=None):
"""Make the server a slave of another instance,
or promote it as master.
Calling ``slaveof(None)`` will send ``SLAVEOF NO ONE``.
.. versionchanged:: v0.2.6
``slaveof()`` form deprecated
in favour of explicit ``slaveof(None)``.
... | python | {
"resource": ""
} |
q22749 | ServerCommandsMixin.slowlog_get | train | def slowlog_get(self, length=None):
"""Returns the Redis slow queries log."""
if length is not None:
if not isinstance(length, int):
raise TypeError("length must be int or None")
return self.execute(b'SLOWLOG', b'GET', length)
else:
return self... | python | {
"resource": ""
} |
q22750 | PubSubCommandsMixin.publish_json | train | def publish_json(self, channel, obj):
"""Post a JSON-encoded message to channel."""
return self.publish(channel, json.dumps(obj)) | python | {
"resource": ""
} |
q22751 | PubSubCommandsMixin.unsubscribe | train | def unsubscribe(self, channel, *channels):
"""Unsubscribe from specific channels.
Arguments can be instances of :class:`~aioredis.Channel`.
"""
conn = self._pool_or_conn
return conn.execute_pubsub(b'UNSUBSCRIBE', channel, *channels) | python | {
"resource": ""
} |
q22752 | PubSubCommandsMixin.punsubscribe | train | def punsubscribe(self, pattern, *patterns):
"""Unsubscribe from specific patterns.
Arguments can be instances of :class:`~aioredis.Channel`.
"""
conn = self._pool_or_conn
return conn.execute_pubsub(b'PUNSUBSCRIBE', pattern, *patterns) | python | {
"resource": ""
} |
q22753 | PubSubCommandsMixin.pubsub_channels | train | def pubsub_channels(self, pattern=None):
"""Lists the currently active channels."""
args = [b'PUBSUB', b'CHANNELS']
if pattern is not None:
args.append(pattern)
return self.execute(*args) | python | {
"resource": ""
} |
q22754 | Channel.get | train | async def get(self, *, encoding=None, decoder=None):
"""Coroutine that waits for and returns a message.
:raises aioredis.ChannelClosedError: If channel is unsubscribed
and has no messages.
"""
assert decoder is None or callable(decoder), decoder
if self._queue.exhaus... | python | {
"resource": ""
} |
q22755 | Channel.get_json | train | async def get_json(self, encoding='utf-8'):
"""Shortcut to get JSON messages."""
return (await self.get(encoding=encoding, decoder=json.loads)) | python | {
"resource": ""
} |
q22756 | Channel.iter | train | def iter(self, *, encoding=None, decoder=None):
"""Same as get method but its native coroutine.
Usage example:
>>> async for msg in ch.iter():
... print(msg)
"""
return _IterHelper(self,
is_active=lambda ch: ch.is_active,
... | python | {
"resource": ""
} |
q22757 | Receiver.pattern | train | def pattern(self, pattern):
"""Create a pattern channel.
Returns ``_Sender`` object implementing
:class:`~aioredis.abc.AbcChannel`.
"""
enc_pattern = _converters[type(pattern)](pattern)
if (enc_pattern, True) not in self._refs:
ch = _Sender(self, enc_pattern,... | python | {
"resource": ""
} |
q22758 | Receiver.channels | train | def channels(self):
"""Read-only channels dict."""
return types.MappingProxyType({
ch.name: ch for ch in self._refs.values()
if not ch.is_pattern}) | python | {
"resource": ""
} |
q22759 | Receiver.wait_message | train | async def wait_message(self):
"""Blocks until new message appear."""
if not self._queue.empty():
return True
if self._queue.closed:
return False
await self._queue.wait()
return self.is_active | python | {
"resource": ""
} |
q22760 | Receiver.is_active | train | def is_active(self):
"""Returns True if listener has any active subscription."""
if self._queue.exhausted:
return False
return any(ch.is_active for ch in self._refs.values()) | python | {
"resource": ""
} |
q22761 | Receiver.iter | train | def iter(self, *, encoding=None, decoder=None):
"""Returns async iterator.
Usage example:
>>> async for ch, msg in mpsc.iter():
... print(ch, msg)
"""
return _IterHelper(self,
is_active=lambda r: not r._queue.exhausted,
... | python | {
"resource": ""
} |
q22762 | create_pool | train | async def create_pool(address, *, db=None, password=None, ssl=None,
encoding=None, minsize=1, maxsize=10,
parser=None, loop=None, create_connection_timeout=None,
pool_cls=None, connection_cls=None):
# FIXME: rewrite docstring
"""Creates Redis Poo... | python | {
"resource": ""
} |
q22763 | ConnectionsPool.execute | train | def execute(self, command, *args, **kw):
"""Executes redis command in a free connection and returns
future waiting for result.
Picks connection from free pool and send command through
that connection.
If no connection is found, returns coroutine waiting for
free connecti... | python | {
"resource": ""
} |
q22764 | ConnectionsPool.get_connection | train | def get_connection(self, command, args=()):
"""Get free connection from pool.
Returns connection.
"""
# TODO: find a better way to determine if connection is free
# and not havily used.
command = command.upper().strip()
is_pubsub = command in _PUBSUB_COMMAN... | python | {
"resource": ""
} |
q22765 | ConnectionsPool._wait_execute | train | async def _wait_execute(self, address, command, args, kw):
"""Acquire connection and execute command."""
conn = await self.acquire(command, args)
try:
return (await conn.execute(command, *args, **kw))
finally:
self.release(conn) | python | {
"resource": ""
} |
q22766 | ConnectionsPool.select | train | async def select(self, db):
"""Changes db index for all free connections.
All previously acquired connections will be closed when released.
"""
res = True
async with self._cond:
for i in range(self.freesize):
res = res and (await self._pool[i].select(... | python | {
"resource": ""
} |
q22767 | ConnectionsPool.acquire | train | async def acquire(self, command=None, args=()):
"""Acquires a connection from free pool.
Creates new connection if needed.
"""
if self.closed:
raise PoolClosedError("Pool is closed")
async with self._cond:
if self.closed:
raise PoolClosedE... | python | {
"resource": ""
} |
q22768 | ConnectionsPool.release | train | def release(self, conn):
"""Returns used connection back into pool.
When returned connection has db index that differs from one in pool
the connection will be closed and dropped.
When queue of free connections is full the connection will be dropped.
"""
assert conn in se... | python | {
"resource": ""
} |
q22769 | PyReader.feed | train | def feed(self, data, o: int = 0, l: int = -1):
"""Feed data to parser."""
if l == -1:
l = len(data) - o
if o < 0 or l < 0:
raise ValueError("negative input")
if o + l > len(data):
raise ValueError("input is larger than buffer size")
self._parse... | python | {
"resource": ""
} |
q22770 | encode_command | train | def encode_command(*args, buf=None):
"""Encodes arguments into redis bulk-strings array.
Raises TypeError if any of args not of bytearray, bytes, float, int, or str
type.
"""
if buf is None:
buf = bytearray()
buf.extend(b'*%d\r\n' % len(args))
try:
for arg in args:
... | python | {
"resource": ""
} |
q22771 | parse_url | train | def parse_url(url):
"""Parse Redis connection URI.
Parse according to IANA specs:
* https://www.iana.org/assignments/uri-schemes/prov/redis
* https://www.iana.org/assignments/uri-schemes/prov/rediss
Also more rules applied:
* empty scheme is treated as unix socket path no further parsing is d... | python | {
"resource": ""
} |
q22772 | create_connection | train | async def create_connection(address, *, db=None, password=None, ssl=None,
encoding=None, parser=None, loop=None,
timeout=None, connection_cls=None):
"""Creates redis connection.
Opens connection to Redis server specified by address argument.
Address a... | python | {
"resource": ""
} |
q22773 | RedisConnection._read_data | train | async def _read_data(self):
"""Response reader task."""
last_error = ConnectionClosedError(
"Connection has been closed by server")
while not self._reader.at_eof():
try:
obj = await self._reader.readobj()
except asyncio.CancelledError:
... | python | {
"resource": ""
} |
q22774 | RedisConnection._process_data | train | def _process_data(self, obj):
"""Processes command results."""
assert len(self._waiters) > 0, (type(obj), obj)
waiter, encoding, cb = self._waiters.popleft()
if isinstance(obj, RedisError):
if isinstance(obj, ReplyError):
if obj.args[0].startswith('READONLY'):... | python | {
"resource": ""
} |
q22775 | RedisConnection.execute | train | def execute(self, command, *args, encoding=_NOTSET):
"""Executes redis command and returns Future waiting for the answer.
Raises:
* TypeError if any of args can not be encoded as bytes.
* ReplyError on redis '-ERR' responses.
* ProtocolError when response can not be decoded mean... | python | {
"resource": ""
} |
q22776 | RedisConnection.closed | train | def closed(self):
"""True if connection is closed."""
closed = self._closing or self._closed
if not closed and self._reader and self._reader.at_eof():
self._closing = closed = True
self._loop.call_soon(self._do_close, None)
return closed | python | {
"resource": ""
} |
q22777 | RedisConnection.select | train | def select(self, db):
"""Change the selected database for the current connection."""
if not isinstance(db, int):
raise TypeError("DB must be of int type, not {!r}".format(db))
if db < 0:
raise ValueError("DB must be greater or equal 0, got {!r}"
... | python | {
"resource": ""
} |
q22778 | GeoCommandsMixin.geoadd | train | def geoadd(self, key, longitude, latitude, member, *args, **kwargs):
"""Add one or more geospatial items in the geospatial index represented
using a sorted set.
:rtype: int
"""
return self.execute(
b'GEOADD', key, longitude, latitude, member, *args, **kwargs
... | python | {
"resource": ""
} |
q22779 | GeoCommandsMixin.geohash | train | def geohash(self, key, member, *members, **kwargs):
"""Returns members of a geospatial index as standard geohash strings.
:rtype: list[str or bytes or None]
"""
return self.execute(
b'GEOHASH', key, member, *members, **kwargs
) | python | {
"resource": ""
} |
q22780 | GeoCommandsMixin.geopos | train | def geopos(self, key, member, *members, **kwargs):
"""Returns longitude and latitude of members of a geospatial index.
:rtype: list[GeoPoint or None]
"""
fut = self.execute(b'GEOPOS', key, member, *members, **kwargs)
return wait_convert(fut, make_geopos) | python | {
"resource": ""
} |
q22781 | GeoCommandsMixin.geodist | train | def geodist(self, key, member1, member2, unit='m'):
"""Returns the distance between two members of a geospatial index.
:rtype: list[float or None]
"""
fut = self.execute(b'GEODIST', key, member1, member2, unit)
return wait_convert(fut, make_geodist) | python | {
"resource": ""
} |
q22782 | GeoCommandsMixin.georadius | train | def georadius(self, key, longitude, latitude, radius, unit='m', *,
with_dist=False, with_hash=False, with_coord=False,
count=None, sort=None, encoding=_NOTSET):
"""Query a sorted set representing a geospatial index to fetch members
matching a given maximum distance fr... | python | {
"resource": ""
} |
q22783 | GeoCommandsMixin.georadiusbymember | train | def georadiusbymember(self, key, member, radius, unit='m', *,
with_dist=False, with_hash=False, with_coord=False,
count=None, sort=None, encoding=_NOTSET):
"""Query a sorted set representing a geospatial index to fetch members
matching a given maximum ... | python | {
"resource": ""
} |
q22784 | ScriptingCommandsMixin.eval | train | def eval(self, script, keys=[], args=[]):
"""Execute a Lua script server side."""
return self.execute(b'EVAL', script, len(keys), *(keys + args)) | python | {
"resource": ""
} |
q22785 | ScriptingCommandsMixin.evalsha | train | def evalsha(self, digest, keys=[], args=[]):
"""Execute a Lua script server side by its SHA1 digest."""
return self.execute(b'EVALSHA', digest, len(keys), *(keys + args)) | python | {
"resource": ""
} |
q22786 | ScriptingCommandsMixin.script_exists | train | def script_exists(self, digest, *digests):
"""Check existence of scripts in the script cache."""
return self.execute(b'SCRIPT', b'EXISTS', digest, *digests) | python | {
"resource": ""
} |
q22787 | StringCommandsMixin.bitcount | train | def bitcount(self, key, start=None, end=None):
"""Count set bits in a string.
:raises TypeError: if only start or end specified.
"""
if start is None and end is not None:
raise TypeError("both start and stop must be specified")
elif start is not None and end is None:... | python | {
"resource": ""
} |
q22788 | StringCommandsMixin.bitop_and | train | def bitop_and(self, dest, key, *keys):
"""Perform bitwise AND operations between strings."""
return self.execute(b'BITOP', b'AND', dest, key, *keys) | python | {
"resource": ""
} |
q22789 | StringCommandsMixin.bitop_or | train | def bitop_or(self, dest, key, *keys):
"""Perform bitwise OR operations between strings."""
return self.execute(b'BITOP', b'OR', dest, key, *keys) | python | {
"resource": ""
} |
q22790 | StringCommandsMixin.bitop_xor | train | def bitop_xor(self, dest, key, *keys):
"""Perform bitwise XOR operations between strings."""
return self.execute(b'BITOP', b'XOR', dest, key, *keys) | python | {
"resource": ""
} |
q22791 | StringCommandsMixin.bitop_not | train | def bitop_not(self, dest, key):
"""Perform bitwise NOT operations between strings."""
return self.execute(b'BITOP', b'NOT', dest, key) | python | {
"resource": ""
} |
q22792 | StringCommandsMixin.bitpos | train | def bitpos(self, key, bit, start=None, end=None):
"""Find first bit set or clear in a string.
:raises ValueError: if bit is not 0 or 1
"""
if bit not in (1, 0):
raise ValueError("bit argument must be either 1 or 0")
bytes_range = []
if start is not None:
... | python | {
"resource": ""
} |
q22793 | StringCommandsMixin.decrby | train | def decrby(self, key, decrement):
"""Decrement the integer value of a key by the given number.
:raises TypeError: if decrement is not int
"""
if not isinstance(decrement, int):
raise TypeError("decrement must be of type int")
return self.execute(b'DECRBY', key, decre... | python | {
"resource": ""
} |
q22794 | StringCommandsMixin.get | train | def get(self, key, *, encoding=_NOTSET):
"""Get the value of a key."""
return self.execute(b'GET', key, encoding=encoding) | python | {
"resource": ""
} |
q22795 | StringCommandsMixin.getrange | train | def getrange(self, key, start, end, *, encoding=_NOTSET):
"""Get a substring of the string stored at a key.
:raises TypeError: if start or end is not int
"""
if not isinstance(start, int):
raise TypeError("start argument must be int")
if not isinstance(end, int):
... | python | {
"resource": ""
} |
q22796 | StringCommandsMixin.getset | train | def getset(self, key, value, *, encoding=_NOTSET):
"""Set the string value of a key and return its old value."""
return self.execute(b'GETSET', key, value, encoding=encoding) | python | {
"resource": ""
} |
q22797 | StringCommandsMixin.incrby | train | def incrby(self, key, increment):
"""Increment the integer value of a key by the given amount.
:raises TypeError: if increment is not int
"""
if not isinstance(increment, int):
raise TypeError("increment must be of type int")
return self.execute(b'INCRBY', key, incre... | python | {
"resource": ""
} |
q22798 | StringCommandsMixin.incrbyfloat | train | def incrbyfloat(self, key, increment):
"""Increment the float value of a key by the given amount.
:raises TypeError: if increment is not int
"""
if not isinstance(increment, float):
raise TypeError("increment must be of type int")
fut = self.execute(b'INCRBYFLOAT', k... | python | {
"resource": ""
} |
q22799 | StringCommandsMixin.mget | train | def mget(self, key, *keys, encoding=_NOTSET):
"""Get the values of all the given keys."""
return self.execute(b'MGET', key, *keys, encoding=encoding) | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.