repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
locationlabs/mockredis | mockredis/client.py | MockRedis.lset | def lset(self, key, index, value):
"""Emulate lset."""
redis_list = self._get_list(key, 'LSET')
if redis_list is None:
raise ResponseError("no such key")
try:
redis_list[index] = self._encode(value)
except IndexError:
raise ResponseError("index... | python | def lset(self, key, index, value):
"""Emulate lset."""
redis_list = self._get_list(key, 'LSET')
if redis_list is None:
raise ResponseError("no such key")
try:
redis_list[index] = self._encode(value)
except IndexError:
raise ResponseError("index... | [
"def",
"lset",
"(",
"self",
",",
"key",
",",
"index",
",",
"value",
")",
":",
"redis_list",
"=",
"self",
".",
"_get_list",
"(",
"key",
",",
"'LSET'",
")",
"if",
"redis_list",
"is",
"None",
":",
"raise",
"ResponseError",
"(",
"\"no such key\"",
")",
"tr... | Emulate lset. | [
"Emulate",
"lset",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L792-L800 |
locationlabs/mockredis | mockredis/client.py | MockRedis._common_scan | def _common_scan(self, values_function, cursor='0', match=None, count=10, key=None):
"""
Common scanning skeleton.
:param key: optional function used to identify what 'match' is applied to
"""
if count is None:
count = 10
cursor = int(cursor)
count = ... | python | def _common_scan(self, values_function, cursor='0', match=None, count=10, key=None):
"""
Common scanning skeleton.
:param key: optional function used to identify what 'match' is applied to
"""
if count is None:
count = 10
cursor = int(cursor)
count = ... | [
"def",
"_common_scan",
"(",
"self",
",",
"values_function",
",",
"cursor",
"=",
"'0'",
",",
"match",
"=",
"None",
",",
"count",
"=",
"10",
",",
"key",
"=",
"None",
")",
":",
"if",
"count",
"is",
"None",
":",
"count",
"=",
"10",
"cursor",
"=",
"int"... | Common scanning skeleton.
:param key: optional function used to identify what 'match' is applied to | [
"Common",
"scanning",
"skeleton",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L882-L910 |
locationlabs/mockredis | mockredis/client.py | MockRedis.scan | def scan(self, cursor='0', match=None, count=10):
"""Emulate scan."""
def value_function():
return sorted(self.redis.keys()) # sorted list for consistent order
return self._common_scan(value_function, cursor=cursor, match=match, count=count) | python | def scan(self, cursor='0', match=None, count=10):
"""Emulate scan."""
def value_function():
return sorted(self.redis.keys()) # sorted list for consistent order
return self._common_scan(value_function, cursor=cursor, match=match, count=count) | [
"def",
"scan",
"(",
"self",
",",
"cursor",
"=",
"'0'",
",",
"match",
"=",
"None",
",",
"count",
"=",
"10",
")",
":",
"def",
"value_function",
"(",
")",
":",
"return",
"sorted",
"(",
"self",
".",
"redis",
".",
"keys",
"(",
")",
")",
"# sorted list f... | Emulate scan. | [
"Emulate",
"scan",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L912-L916 |
locationlabs/mockredis | mockredis/client.py | MockRedis.sscan | def sscan(self, name, cursor='0', match=None, count=10):
"""Emulate sscan."""
def value_function():
members = list(self.smembers(name))
members.sort() # sort for consistent order
return members
return self._common_scan(value_function, cursor=cursor, match=mat... | python | def sscan(self, name, cursor='0', match=None, count=10):
"""Emulate sscan."""
def value_function():
members = list(self.smembers(name))
members.sort() # sort for consistent order
return members
return self._common_scan(value_function, cursor=cursor, match=mat... | [
"def",
"sscan",
"(",
"self",
",",
"name",
",",
"cursor",
"=",
"'0'",
",",
"match",
"=",
"None",
",",
"count",
"=",
"10",
")",
":",
"def",
"value_function",
"(",
")",
":",
"members",
"=",
"list",
"(",
"self",
".",
"smembers",
"(",
"name",
")",
")"... | Emulate sscan. | [
"Emulate",
"sscan",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L926-L932 |
locationlabs/mockredis | mockredis/client.py | MockRedis.zscan | def zscan(self, name, cursor='0', match=None, count=10):
"""Emulate zscan."""
def value_function():
values = self.zrange(name, 0, -1, withscores=True)
values.sort(key=lambda x: x[1]) # sort for consistent order
return values
return self._common_scan(value_fun... | python | def zscan(self, name, cursor='0', match=None, count=10):
"""Emulate zscan."""
def value_function():
values = self.zrange(name, 0, -1, withscores=True)
values.sort(key=lambda x: x[1]) # sort for consistent order
return values
return self._common_scan(value_fun... | [
"def",
"zscan",
"(",
"self",
",",
"name",
",",
"cursor",
"=",
"'0'",
",",
"match",
"=",
"None",
",",
"count",
"=",
"10",
")",
":",
"def",
"value_function",
"(",
")",
":",
"values",
"=",
"self",
".",
"zrange",
"(",
"name",
",",
"0",
",",
"-",
"1... | Emulate zscan. | [
"Emulate",
"zscan",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L943-L949 |
locationlabs/mockredis | mockredis/client.py | MockRedis.hscan | def hscan(self, name, cursor='0', match=None, count=10):
"""Emulate hscan."""
def value_function():
values = self.hgetall(name)
values = list(values.items()) # list of tuples for sorting and matching
values.sort(key=lambda x: x[0]) # sort for consistent order
... | python | def hscan(self, name, cursor='0', match=None, count=10):
"""Emulate hscan."""
def value_function():
values = self.hgetall(name)
values = list(values.items()) # list of tuples for sorting and matching
values.sort(key=lambda x: x[0]) # sort for consistent order
... | [
"def",
"hscan",
"(",
"self",
",",
"name",
",",
"cursor",
"=",
"'0'",
",",
"match",
"=",
"None",
",",
"count",
"=",
"10",
")",
":",
"def",
"value_function",
"(",
")",
":",
"values",
"=",
"self",
".",
"hgetall",
"(",
"name",
")",
"values",
"=",
"li... | Emulate hscan. | [
"Emulate",
"hscan",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L960-L969 |
locationlabs/mockredis | mockredis/client.py | MockRedis.hscan_iter | def hscan_iter(self, name, match=None, count=10):
"""Emulate hscan_iter."""
cursor = '0'
while cursor != 0:
cursor, data = self.hscan(name, cursor=cursor,
match=match, count=count)
for item in data.items():
yield item | python | def hscan_iter(self, name, match=None, count=10):
"""Emulate hscan_iter."""
cursor = '0'
while cursor != 0:
cursor, data = self.hscan(name, cursor=cursor,
match=match, count=count)
for item in data.items():
yield item | [
"def",
"hscan_iter",
"(",
"self",
",",
"name",
",",
"match",
"=",
"None",
",",
"count",
"=",
"10",
")",
":",
"cursor",
"=",
"'0'",
"while",
"cursor",
"!=",
"0",
":",
"cursor",
",",
"data",
"=",
"self",
".",
"hscan",
"(",
"name",
",",
"cursor",
"=... | Emulate hscan_iter. | [
"Emulate",
"hscan_iter",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L971-L978 |
locationlabs/mockredis | mockredis/client.py | MockRedis.sadd | def sadd(self, key, *values):
"""Emulate sadd."""
if len(values) == 0:
raise ResponseError("wrong number of arguments for 'sadd' command")
redis_set = self._get_set(key, 'SADD', create=True)
before_count = len(redis_set)
redis_set.update(map(self._encode, values))
... | python | def sadd(self, key, *values):
"""Emulate sadd."""
if len(values) == 0:
raise ResponseError("wrong number of arguments for 'sadd' command")
redis_set = self._get_set(key, 'SADD', create=True)
before_count = len(redis_set)
redis_set.update(map(self._encode, values))
... | [
"def",
"sadd",
"(",
"self",
",",
"key",
",",
"*",
"values",
")",
":",
"if",
"len",
"(",
"values",
")",
"==",
"0",
":",
"raise",
"ResponseError",
"(",
"\"wrong number of arguments for 'sadd' command\"",
")",
"redis_set",
"=",
"self",
".",
"_get_set",
"(",
"... | Emulate sadd. | [
"Emulate",
"sadd",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L982-L990 |
locationlabs/mockredis | mockredis/client.py | MockRedis.sdiff | def sdiff(self, keys, *args):
"""Emulate sdiff."""
func = lambda left, right: left.difference(right)
return self._apply_to_sets(func, "SDIFF", keys, *args) | python | def sdiff(self, keys, *args):
"""Emulate sdiff."""
func = lambda left, right: left.difference(right)
return self._apply_to_sets(func, "SDIFF", keys, *args) | [
"def",
"sdiff",
"(",
"self",
",",
"keys",
",",
"*",
"args",
")",
":",
"func",
"=",
"lambda",
"left",
",",
"right",
":",
"left",
".",
"difference",
"(",
"right",
")",
"return",
"self",
".",
"_apply_to_sets",
"(",
"func",
",",
"\"SDIFF\"",
",",
"keys",... | Emulate sdiff. | [
"Emulate",
"sdiff",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L997-L1000 |
locationlabs/mockredis | mockredis/client.py | MockRedis.sdiffstore | def sdiffstore(self, dest, keys, *args):
"""Emulate sdiffstore."""
result = self.sdiff(keys, *args)
self.redis[self._encode(dest)] = result
return len(result) | python | def sdiffstore(self, dest, keys, *args):
"""Emulate sdiffstore."""
result = self.sdiff(keys, *args)
self.redis[self._encode(dest)] = result
return len(result) | [
"def",
"sdiffstore",
"(",
"self",
",",
"dest",
",",
"keys",
",",
"*",
"args",
")",
":",
"result",
"=",
"self",
".",
"sdiff",
"(",
"keys",
",",
"*",
"args",
")",
"self",
".",
"redis",
"[",
"self",
".",
"_encode",
"(",
"dest",
")",
"]",
"=",
"res... | Emulate sdiffstore. | [
"Emulate",
"sdiffstore",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1002-L1006 |
locationlabs/mockredis | mockredis/client.py | MockRedis.sinter | def sinter(self, keys, *args):
"""Emulate sinter."""
func = lambda left, right: left.intersection(right)
return self._apply_to_sets(func, "SINTER", keys, *args) | python | def sinter(self, keys, *args):
"""Emulate sinter."""
func = lambda left, right: left.intersection(right)
return self._apply_to_sets(func, "SINTER", keys, *args) | [
"def",
"sinter",
"(",
"self",
",",
"keys",
",",
"*",
"args",
")",
":",
"func",
"=",
"lambda",
"left",
",",
"right",
":",
"left",
".",
"intersection",
"(",
"right",
")",
"return",
"self",
".",
"_apply_to_sets",
"(",
"func",
",",
"\"SINTER\"",
",",
"ke... | Emulate sinter. | [
"Emulate",
"sinter",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1008-L1011 |
locationlabs/mockredis | mockredis/client.py | MockRedis.sinterstore | def sinterstore(self, dest, keys, *args):
"""Emulate sinterstore."""
result = self.sinter(keys, *args)
self.redis[self._encode(dest)] = result
return len(result) | python | def sinterstore(self, dest, keys, *args):
"""Emulate sinterstore."""
result = self.sinter(keys, *args)
self.redis[self._encode(dest)] = result
return len(result) | [
"def",
"sinterstore",
"(",
"self",
",",
"dest",
",",
"keys",
",",
"*",
"args",
")",
":",
"result",
"=",
"self",
".",
"sinter",
"(",
"keys",
",",
"*",
"args",
")",
"self",
".",
"redis",
"[",
"self",
".",
"_encode",
"(",
"dest",
")",
"]",
"=",
"r... | Emulate sinterstore. | [
"Emulate",
"sinterstore",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1013-L1017 |
locationlabs/mockredis | mockredis/client.py | MockRedis.sismember | def sismember(self, name, value):
"""Emulate sismember."""
redis_set = self._get_set(name, 'SISMEMBER')
if not redis_set:
return 0
result = self._encode(value) in redis_set
return 1 if result else 0 | python | def sismember(self, name, value):
"""Emulate sismember."""
redis_set = self._get_set(name, 'SISMEMBER')
if not redis_set:
return 0
result = self._encode(value) in redis_set
return 1 if result else 0 | [
"def",
"sismember",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"redis_set",
"=",
"self",
".",
"_get_set",
"(",
"name",
",",
"'SISMEMBER'",
")",
"if",
"not",
"redis_set",
":",
"return",
"0",
"result",
"=",
"self",
".",
"_encode",
"(",
"value",
... | Emulate sismember. | [
"Emulate",
"sismember",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1019-L1026 |
locationlabs/mockredis | mockredis/client.py | MockRedis.smove | def smove(self, src, dst, value):
"""Emulate smove."""
src_set = self._get_set(src, 'SMOVE')
dst_set = self._get_set(dst, 'SMOVE')
value = self._encode(value)
if value not in src_set:
return False
src_set.discard(value)
dst_set.add(value)
sel... | python | def smove(self, src, dst, value):
"""Emulate smove."""
src_set = self._get_set(src, 'SMOVE')
dst_set = self._get_set(dst, 'SMOVE')
value = self._encode(value)
if value not in src_set:
return False
src_set.discard(value)
dst_set.add(value)
sel... | [
"def",
"smove",
"(",
"self",
",",
"src",
",",
"dst",
",",
"value",
")",
":",
"src_set",
"=",
"self",
".",
"_get_set",
"(",
"src",
",",
"'SMOVE'",
")",
"dst_set",
"=",
"self",
".",
"_get_set",
"(",
"dst",
",",
"'SMOVE'",
")",
"value",
"=",
"self",
... | Emulate smove. | [
"Emulate",
"smove",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1032-L1044 |
locationlabs/mockredis | mockredis/client.py | MockRedis.spop | def spop(self, name):
"""Emulate spop."""
redis_set = self._get_set(name, 'SPOP')
if not redis_set:
return None
member = choice(list(redis_set))
redis_set.remove(member)
if len(redis_set) == 0:
self.delete(name)
return member | python | def spop(self, name):
"""Emulate spop."""
redis_set = self._get_set(name, 'SPOP')
if not redis_set:
return None
member = choice(list(redis_set))
redis_set.remove(member)
if len(redis_set) == 0:
self.delete(name)
return member | [
"def",
"spop",
"(",
"self",
",",
"name",
")",
":",
"redis_set",
"=",
"self",
".",
"_get_set",
"(",
"name",
",",
"'SPOP'",
")",
"if",
"not",
"redis_set",
":",
"return",
"None",
"member",
"=",
"choice",
"(",
"list",
"(",
"redis_set",
")",
")",
"redis_s... | Emulate spop. | [
"Emulate",
"spop",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1046-L1055 |
locationlabs/mockredis | mockredis/client.py | MockRedis.srandmember | def srandmember(self, name, number=None):
"""Emulate srandmember."""
redis_set = self._get_set(name, 'SRANDMEMBER')
if not redis_set:
return None if number is None else []
if number is None:
return choice(list(redis_set))
elif number > 0:
retur... | python | def srandmember(self, name, number=None):
"""Emulate srandmember."""
redis_set = self._get_set(name, 'SRANDMEMBER')
if not redis_set:
return None if number is None else []
if number is None:
return choice(list(redis_set))
elif number > 0:
retur... | [
"def",
"srandmember",
"(",
"self",
",",
"name",
",",
"number",
"=",
"None",
")",
":",
"redis_set",
"=",
"self",
".",
"_get_set",
"(",
"name",
",",
"'SRANDMEMBER'",
")",
"if",
"not",
"redis_set",
":",
"return",
"None",
"if",
"number",
"is",
"None",
"els... | Emulate srandmember. | [
"Emulate",
"srandmember",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1057-L1067 |
locationlabs/mockredis | mockredis/client.py | MockRedis.srem | def srem(self, key, *values):
"""Emulate srem."""
redis_set = self._get_set(key, 'SREM')
if not redis_set:
return 0
before_count = len(redis_set)
for value in values:
redis_set.discard(self._encode(value))
after_count = len(redis_set)
if be... | python | def srem(self, key, *values):
"""Emulate srem."""
redis_set = self._get_set(key, 'SREM')
if not redis_set:
return 0
before_count = len(redis_set)
for value in values:
redis_set.discard(self._encode(value))
after_count = len(redis_set)
if be... | [
"def",
"srem",
"(",
"self",
",",
"key",
",",
"*",
"values",
")",
":",
"redis_set",
"=",
"self",
".",
"_get_set",
"(",
"key",
",",
"'SREM'",
")",
"if",
"not",
"redis_set",
":",
"return",
"0",
"before_count",
"=",
"len",
"(",
"redis_set",
")",
"for",
... | Emulate srem. | [
"Emulate",
"srem",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1069-L1080 |
locationlabs/mockredis | mockredis/client.py | MockRedis.sunion | def sunion(self, keys, *args):
"""Emulate sunion."""
func = lambda left, right: left.union(right)
return self._apply_to_sets(func, "SUNION", keys, *args) | python | def sunion(self, keys, *args):
"""Emulate sunion."""
func = lambda left, right: left.union(right)
return self._apply_to_sets(func, "SUNION", keys, *args) | [
"def",
"sunion",
"(",
"self",
",",
"keys",
",",
"*",
"args",
")",
":",
"func",
"=",
"lambda",
"left",
",",
"right",
":",
"left",
".",
"union",
"(",
"right",
")",
"return",
"self",
".",
"_apply_to_sets",
"(",
"func",
",",
"\"SUNION\"",
",",
"keys",
... | Emulate sunion. | [
"Emulate",
"sunion",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1082-L1085 |
locationlabs/mockredis | mockredis/client.py | MockRedis.sunionstore | def sunionstore(self, dest, keys, *args):
"""Emulate sunionstore."""
result = self.sunion(keys, *args)
self.redis[self._encode(dest)] = result
return len(result) | python | def sunionstore(self, dest, keys, *args):
"""Emulate sunionstore."""
result = self.sunion(keys, *args)
self.redis[self._encode(dest)] = result
return len(result) | [
"def",
"sunionstore",
"(",
"self",
",",
"dest",
",",
"keys",
",",
"*",
"args",
")",
":",
"result",
"=",
"self",
".",
"sunion",
"(",
"keys",
",",
"*",
"args",
")",
"self",
".",
"redis",
"[",
"self",
".",
"_encode",
"(",
"dest",
")",
"]",
"=",
"r... | Emulate sunionstore. | [
"Emulate",
"sunionstore",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1087-L1091 |
locationlabs/mockredis | mockredis/client.py | MockRedis.eval | def eval(self, script, numkeys, *keys_and_args):
"""Emulate eval"""
sha = self.script_load(script)
return self.evalsha(sha, numkeys, *keys_and_args) | python | def eval(self, script, numkeys, *keys_and_args):
"""Emulate eval"""
sha = self.script_load(script)
return self.evalsha(sha, numkeys, *keys_and_args) | [
"def",
"eval",
"(",
"self",
",",
"script",
",",
"numkeys",
",",
"*",
"keys_and_args",
")",
":",
"sha",
"=",
"self",
".",
"script_load",
"(",
"script",
")",
"return",
"self",
".",
"evalsha",
"(",
"sha",
",",
"numkeys",
",",
"*",
"keys_and_args",
")"
] | Emulate eval | [
"Emulate",
"eval"
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1306-L1309 |
locationlabs/mockredis | mockredis/client.py | MockRedis.evalsha | def evalsha(self, sha, numkeys, *keys_and_args):
"""Emulates evalsha"""
if not self.script_exists(sha)[0]:
raise RedisError("Sha not registered")
script_callable = Script(self, self.shas[sha], self.load_lua_dependencies)
numkeys = max(numkeys, 0)
keys = keys_and_args[... | python | def evalsha(self, sha, numkeys, *keys_and_args):
"""Emulates evalsha"""
if not self.script_exists(sha)[0]:
raise RedisError("Sha not registered")
script_callable = Script(self, self.shas[sha], self.load_lua_dependencies)
numkeys = max(numkeys, 0)
keys = keys_and_args[... | [
"def",
"evalsha",
"(",
"self",
",",
"sha",
",",
"numkeys",
",",
"*",
"keys_and_args",
")",
":",
"if",
"not",
"self",
".",
"script_exists",
"(",
"sha",
")",
"[",
"0",
"]",
":",
"raise",
"RedisError",
"(",
"\"Sha not registered\"",
")",
"script_callable",
... | Emulates evalsha | [
"Emulates",
"evalsha"
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1311-L1319 |
locationlabs/mockredis | mockredis/client.py | MockRedis.script_load | def script_load(self, script):
"""Emulate script_load"""
sha_digest = sha1(script.encode("utf-8")).hexdigest()
self.shas[sha_digest] = script
return sha_digest | python | def script_load(self, script):
"""Emulate script_load"""
sha_digest = sha1(script.encode("utf-8")).hexdigest()
self.shas[sha_digest] = script
return sha_digest | [
"def",
"script_load",
"(",
"self",
",",
"script",
")",
":",
"sha_digest",
"=",
"sha1",
"(",
"script",
".",
"encode",
"(",
"\"utf-8\"",
")",
")",
".",
"hexdigest",
"(",
")",
"self",
".",
"shas",
"[",
"sha_digest",
"]",
"=",
"script",
"return",
"sha_dige... | Emulate script_load | [
"Emulate",
"script_load"
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1334-L1338 |
locationlabs/mockredis | mockredis/client.py | MockRedis.call | def call(self, command, *args):
"""
Sends call to the function, whose name is specified by command.
Used by Script invocations and normalizes calls using standard
Redis arguments to use the expected redis-py arguments.
"""
command = self._normalize_command_name(command)
... | python | def call(self, command, *args):
"""
Sends call to the function, whose name is specified by command.
Used by Script invocations and normalizes calls using standard
Redis arguments to use the expected redis-py arguments.
"""
command = self._normalize_command_name(command)
... | [
"def",
"call",
"(",
"self",
",",
"command",
",",
"*",
"args",
")",
":",
"command",
"=",
"self",
".",
"_normalize_command_name",
"(",
"command",
")",
"args",
"=",
"self",
".",
"_normalize_command_args",
"(",
"command",
",",
"*",
"args",
")",
"redis_function... | Sends call to the function, whose name is specified by command.
Used by Script invocations and normalizes calls using standard
Redis arguments to use the expected redis-py arguments. | [
"Sends",
"call",
"to",
"the",
"function",
"whose",
"name",
"is",
"specified",
"by",
"command",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1344-L1356 |
locationlabs/mockredis | mockredis/client.py | MockRedis._normalize_command_args | def _normalize_command_args(self, command, *args):
"""
Modifies the command arguments to match the
strictness of the redis client.
"""
if command == 'zadd' and not self.strict and len(args) >= 3:
# Reorder score and name
zadd_args = [x for tup in zip(args[... | python | def _normalize_command_args(self, command, *args):
"""
Modifies the command arguments to match the
strictness of the redis client.
"""
if command == 'zadd' and not self.strict and len(args) >= 3:
# Reorder score and name
zadd_args = [x for tup in zip(args[... | [
"def",
"_normalize_command_args",
"(",
"self",
",",
"command",
",",
"*",
"args",
")",
":",
"if",
"command",
"==",
"'zadd'",
"and",
"not",
"self",
".",
"strict",
"and",
"len",
"(",
"args",
")",
">=",
"3",
":",
"# Reorder score and name",
"zadd_args",
"=",
... | Modifies the command arguments to match the
strictness of the redis client. | [
"Modifies",
"the",
"command",
"arguments",
"to",
"match",
"the",
"strictness",
"of",
"the",
"redis",
"client",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1369-L1404 |
locationlabs/mockredis | mockredis/client.py | MockRedis.config_get | def config_get(self, pattern='*'):
"""
Get one or more configuration parameters.
"""
result = {}
for name, value in self.redis_config.items():
if fnmatch.fnmatch(name, pattern):
try:
result[name] = int(value)
except ... | python | def config_get(self, pattern='*'):
"""
Get one or more configuration parameters.
"""
result = {}
for name, value in self.redis_config.items():
if fnmatch.fnmatch(name, pattern):
try:
result[name] = int(value)
except ... | [
"def",
"config_get",
"(",
"self",
",",
"pattern",
"=",
"'*'",
")",
":",
"result",
"=",
"{",
"}",
"for",
"name",
",",
"value",
"in",
"self",
".",
"redis_config",
".",
"items",
"(",
")",
":",
"if",
"fnmatch",
".",
"fnmatch",
"(",
"name",
",",
"patter... | Get one or more configuration parameters. | [
"Get",
"one",
"or",
"more",
"configuration",
"parameters",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1421-L1432 |
locationlabs/mockredis | mockredis/client.py | MockRedis._get_list | def _get_list(self, key, operation, create=False):
"""
Get (and maybe create) a list by name.
"""
return self._get_by_type(key, operation, create, b'list', []) | python | def _get_list(self, key, operation, create=False):
"""
Get (and maybe create) a list by name.
"""
return self._get_by_type(key, operation, create, b'list', []) | [
"def",
"_get_list",
"(",
"self",
",",
"key",
",",
"operation",
",",
"create",
"=",
"False",
")",
":",
"return",
"self",
".",
"_get_by_type",
"(",
"key",
",",
"operation",
",",
"create",
",",
"b'list'",
",",
"[",
"]",
")"
] | Get (and maybe create) a list by name. | [
"Get",
"(",
"and",
"maybe",
"create",
")",
"a",
"list",
"by",
"name",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1441-L1445 |
locationlabs/mockredis | mockredis/client.py | MockRedis._get_set | def _get_set(self, key, operation, create=False):
"""
Get (and maybe create) a set by name.
"""
return self._get_by_type(key, operation, create, b'set', set()) | python | def _get_set(self, key, operation, create=False):
"""
Get (and maybe create) a set by name.
"""
return self._get_by_type(key, operation, create, b'set', set()) | [
"def",
"_get_set",
"(",
"self",
",",
"key",
",",
"operation",
",",
"create",
"=",
"False",
")",
":",
"return",
"self",
".",
"_get_by_type",
"(",
"key",
",",
"operation",
",",
"create",
",",
"b'set'",
",",
"set",
"(",
")",
")"
] | Get (and maybe create) a set by name. | [
"Get",
"(",
"and",
"maybe",
"create",
")",
"a",
"set",
"by",
"name",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1447-L1451 |
locationlabs/mockredis | mockredis/client.py | MockRedis._get_hash | def _get_hash(self, name, operation, create=False):
"""
Get (and maybe create) a hash by name.
"""
return self._get_by_type(name, operation, create, b'hash', {}) | python | def _get_hash(self, name, operation, create=False):
"""
Get (and maybe create) a hash by name.
"""
return self._get_by_type(name, operation, create, b'hash', {}) | [
"def",
"_get_hash",
"(",
"self",
",",
"name",
",",
"operation",
",",
"create",
"=",
"False",
")",
":",
"return",
"self",
".",
"_get_by_type",
"(",
"name",
",",
"operation",
",",
"create",
",",
"b'hash'",
",",
"{",
"}",
")"
] | Get (and maybe create) a hash by name. | [
"Get",
"(",
"and",
"maybe",
"create",
")",
"a",
"hash",
"by",
"name",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1453-L1457 |
locationlabs/mockredis | mockredis/client.py | MockRedis._get_zset | def _get_zset(self, name, operation, create=False):
"""
Get (and maybe create) a sorted set by name.
"""
return self._get_by_type(name, operation, create, b'zset', SortedSet(), return_default=False) | python | def _get_zset(self, name, operation, create=False):
"""
Get (and maybe create) a sorted set by name.
"""
return self._get_by_type(name, operation, create, b'zset', SortedSet(), return_default=False) | [
"def",
"_get_zset",
"(",
"self",
",",
"name",
",",
"operation",
",",
"create",
"=",
"False",
")",
":",
"return",
"self",
".",
"_get_by_type",
"(",
"name",
",",
"operation",
",",
"create",
",",
"b'zset'",
",",
"SortedSet",
"(",
")",
",",
"return_default",... | Get (and maybe create) a sorted set by name. | [
"Get",
"(",
"and",
"maybe",
"create",
")",
"a",
"sorted",
"set",
"by",
"name",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1459-L1463 |
locationlabs/mockredis | mockredis/client.py | MockRedis._get_by_type | def _get_by_type(self, key, operation, create, type_, default, return_default=True):
"""
Get (and maybe create) a redis data structure by name and type.
"""
key = self._encode(key)
if self.type(key) in [type_, b'none']:
if create:
return self.redis.set... | python | def _get_by_type(self, key, operation, create, type_, default, return_default=True):
"""
Get (and maybe create) a redis data structure by name and type.
"""
key = self._encode(key)
if self.type(key) in [type_, b'none']:
if create:
return self.redis.set... | [
"def",
"_get_by_type",
"(",
"self",
",",
"key",
",",
"operation",
",",
"create",
",",
"type_",
",",
"default",
",",
"return_default",
"=",
"True",
")",
":",
"key",
"=",
"self",
".",
"_encode",
"(",
"key",
")",
"if",
"self",
".",
"type",
"(",
"key",
... | Get (and maybe create) a redis data structure by name and type. | [
"Get",
"(",
"and",
"maybe",
"create",
")",
"a",
"redis",
"data",
"structure",
"by",
"name",
"and",
"type",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1465-L1476 |
locationlabs/mockredis | mockredis/client.py | MockRedis._translate_range | def _translate_range(self, len_, start, end):
"""
Translate range to valid bounds.
"""
if start < 0:
start += len_
start = max(0, min(start, len_))
if end < 0:
end += len_
end = max(-1, min(end, len_ - 1))
return start, end | python | def _translate_range(self, len_, start, end):
"""
Translate range to valid bounds.
"""
if start < 0:
start += len_
start = max(0, min(start, len_))
if end < 0:
end += len_
end = max(-1, min(end, len_ - 1))
return start, end | [
"def",
"_translate_range",
"(",
"self",
",",
"len_",
",",
"start",
",",
"end",
")",
":",
"if",
"start",
"<",
"0",
":",
"start",
"+=",
"len_",
"start",
"=",
"max",
"(",
"0",
",",
"min",
"(",
"start",
",",
"len_",
")",
")",
"if",
"end",
"<",
"0",... | Translate range to valid bounds. | [
"Translate",
"range",
"to",
"valid",
"bounds",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1478-L1488 |
locationlabs/mockredis | mockredis/client.py | MockRedis._translate_limit | def _translate_limit(self, len_, start, num):
"""
Translate limit to valid bounds.
"""
if start > len_ or num <= 0:
return 0, 0
return min(start, len_), num | python | def _translate_limit(self, len_, start, num):
"""
Translate limit to valid bounds.
"""
if start > len_ or num <= 0:
return 0, 0
return min(start, len_), num | [
"def",
"_translate_limit",
"(",
"self",
",",
"len_",
",",
"start",
",",
"num",
")",
":",
"if",
"start",
">",
"len_",
"or",
"num",
"<=",
"0",
":",
"return",
"0",
",",
"0",
"return",
"min",
"(",
"start",
",",
"len_",
")",
",",
"num"
] | Translate limit to valid bounds. | [
"Translate",
"limit",
"to",
"valid",
"bounds",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1490-L1496 |
locationlabs/mockredis | mockredis/client.py | MockRedis._range_func | def _range_func(self, withscores, score_cast_func):
"""
Return a suitable function from (score, member)
"""
if withscores:
return lambda score_member: (score_member[1], score_cast_func(self._encode(score_member[0]))) # noqa
else:
return lambda score_membe... | python | def _range_func(self, withscores, score_cast_func):
"""
Return a suitable function from (score, member)
"""
if withscores:
return lambda score_member: (score_member[1], score_cast_func(self._encode(score_member[0]))) # noqa
else:
return lambda score_membe... | [
"def",
"_range_func",
"(",
"self",
",",
"withscores",
",",
"score_cast_func",
")",
":",
"if",
"withscores",
":",
"return",
"lambda",
"score_member",
":",
"(",
"score_member",
"[",
"1",
"]",
",",
"score_cast_func",
"(",
"self",
".",
"_encode",
"(",
"score_mem... | Return a suitable function from (score, member) | [
"Return",
"a",
"suitable",
"function",
"from",
"(",
"score",
"member",
")"
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1498-L1505 |
locationlabs/mockredis | mockredis/client.py | MockRedis._aggregate_func | def _aggregate_func(self, aggregate):
"""
Return a suitable aggregate score function.
"""
funcs = {"sum": add, "min": min, "max": max}
func_name = aggregate.lower() if aggregate else 'sum'
try:
return funcs[func_name]
except KeyError:
raise... | python | def _aggregate_func(self, aggregate):
"""
Return a suitable aggregate score function.
"""
funcs = {"sum": add, "min": min, "max": max}
func_name = aggregate.lower() if aggregate else 'sum'
try:
return funcs[func_name]
except KeyError:
raise... | [
"def",
"_aggregate_func",
"(",
"self",
",",
"aggregate",
")",
":",
"funcs",
"=",
"{",
"\"sum\"",
":",
"add",
",",
"\"min\"",
":",
"min",
",",
"\"max\"",
":",
"max",
"}",
"func_name",
"=",
"aggregate",
".",
"lower",
"(",
")",
"if",
"aggregate",
"else",
... | Return a suitable aggregate score function. | [
"Return",
"a",
"suitable",
"aggregate",
"score",
"function",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1507-L1516 |
locationlabs/mockredis | mockredis/client.py | MockRedis._apply_to_sets | def _apply_to_sets(self, func, operation, keys, *args):
"""Helper function for sdiff, sinter, and sunion"""
keys = self._list_or_args(keys, args)
if not keys:
raise TypeError("{} takes at least two arguments".format(operation.lower()))
left = self._get_set(keys[0], operation)... | python | def _apply_to_sets(self, func, operation, keys, *args):
"""Helper function for sdiff, sinter, and sunion"""
keys = self._list_or_args(keys, args)
if not keys:
raise TypeError("{} takes at least two arguments".format(operation.lower()))
left = self._get_set(keys[0], operation)... | [
"def",
"_apply_to_sets",
"(",
"self",
",",
"func",
",",
"operation",
",",
"keys",
",",
"*",
"args",
")",
":",
"keys",
"=",
"self",
".",
"_list_or_args",
"(",
"keys",
",",
"args",
")",
"if",
"not",
"keys",
":",
"raise",
"TypeError",
"(",
"\"{} takes at ... | Helper function for sdiff, sinter, and sunion | [
"Helper",
"function",
"for",
"sdiff",
"sinter",
"and",
"sunion"
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1518-L1527 |
locationlabs/mockredis | mockredis/client.py | MockRedis._list_or_args | def _list_or_args(self, keys, args):
"""
Shamelessly copied from redis-py.
"""
# returns a single list combining keys and args
try:
iter(keys)
# a string can be iterated, but indicates
# keys wasn't passed as a list
if isinstance(ke... | python | def _list_or_args(self, keys, args):
"""
Shamelessly copied from redis-py.
"""
# returns a single list combining keys and args
try:
iter(keys)
# a string can be iterated, but indicates
# keys wasn't passed as a list
if isinstance(ke... | [
"def",
"_list_or_args",
"(",
"self",
",",
"keys",
",",
"args",
")",
":",
"# returns a single list combining keys and args",
"try",
":",
"iter",
"(",
"keys",
")",
"# a string can be iterated, but indicates",
"# keys wasn't passed as a list",
"if",
"isinstance",
"(",
"keys"... | Shamelessly copied from redis-py. | [
"Shamelessly",
"copied",
"from",
"redis",
"-",
"py",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1529-L1544 |
locationlabs/mockredis | mockredis/client.py | MockRedis._encode | def _encode(self, value):
"Return a bytestring representation of the value. Taken from redis-py connection.py"
if isinstance(value, bytes):
return value
elif isinstance(value, (int, long)):
value = str(value).encode('utf-8')
elif isinstance(value, float):
... | python | def _encode(self, value):
"Return a bytestring representation of the value. Taken from redis-py connection.py"
if isinstance(value, bytes):
return value
elif isinstance(value, (int, long)):
value = str(value).encode('utf-8')
elif isinstance(value, float):
... | [
"def",
"_encode",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bytes",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"long",
")",
")",
":",
"value",
"=",
"str",
"(",
"value",
... | Return a bytestring representation of the value. Taken from redis-py connection.py | [
"Return",
"a",
"bytestring",
"representation",
"of",
"the",
"value",
".",
"Taken",
"from",
"redis",
"-",
"py",
"connection",
".",
"py"
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1551-L1563 |
locationlabs/mockredis | mockredis/sortedset.py | SortedSet.insert | def insert(self, member, score):
"""
Identical to __setitem__, but returns whether a member was
inserted (True) or updated (False)
"""
found = self.remove(member)
index = bisect_left(self._scores, (score, member))
self._scores.insert(index, (score, member))
... | python | def insert(self, member, score):
"""
Identical to __setitem__, but returns whether a member was
inserted (True) or updated (False)
"""
found = self.remove(member)
index = bisect_left(self._scores, (score, member))
self._scores.insert(index, (score, member))
... | [
"def",
"insert",
"(",
"self",
",",
"member",
",",
"score",
")",
":",
"found",
"=",
"self",
".",
"remove",
"(",
"member",
")",
"index",
"=",
"bisect_left",
"(",
"self",
".",
"_scores",
",",
"(",
"score",
",",
"member",
")",
")",
"self",
".",
"_score... | Identical to __setitem__, but returns whether a member was
inserted (True) or updated (False) | [
"Identical",
"to",
"__setitem__",
"but",
"returns",
"whether",
"a",
"member",
"was",
"inserted",
"(",
"True",
")",
"or",
"updated",
"(",
"False",
")"
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/sortedset.py#L78-L87 |
locationlabs/mockredis | mockredis/sortedset.py | SortedSet.remove | def remove(self, member):
"""
Identical to __delitem__, but returns whether a member was removed.
"""
if member not in self:
return False
score = self._members[member]
score_index = bisect_left(self._scores, (score, member))
del self._scores[score_inde... | python | def remove(self, member):
"""
Identical to __delitem__, but returns whether a member was removed.
"""
if member not in self:
return False
score = self._members[member]
score_index = bisect_left(self._scores, (score, member))
del self._scores[score_inde... | [
"def",
"remove",
"(",
"self",
",",
"member",
")",
":",
"if",
"member",
"not",
"in",
"self",
":",
"return",
"False",
"score",
"=",
"self",
".",
"_members",
"[",
"member",
"]",
"score_index",
"=",
"bisect_left",
"(",
"self",
".",
"_scores",
",",
"(",
"... | Identical to __delitem__, but returns whether a member was removed. | [
"Identical",
"to",
"__delitem__",
"but",
"returns",
"whether",
"a",
"member",
"was",
"removed",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/sortedset.py#L89-L99 |
locationlabs/mockredis | mockredis/sortedset.py | SortedSet.rank | def rank(self, member):
"""
Get the rank (index of a member).
"""
score = self._members.get(member)
if score is None:
return None
return bisect_left(self._scores, (score, member)) | python | def rank(self, member):
"""
Get the rank (index of a member).
"""
score = self._members.get(member)
if score is None:
return None
return bisect_left(self._scores, (score, member)) | [
"def",
"rank",
"(",
"self",
",",
"member",
")",
":",
"score",
"=",
"self",
".",
"_members",
".",
"get",
"(",
"member",
")",
"if",
"score",
"is",
"None",
":",
"return",
"None",
"return",
"bisect_left",
"(",
"self",
".",
"_scores",
",",
"(",
"score",
... | Get the rank (index of a member). | [
"Get",
"the",
"rank",
"(",
"index",
"of",
"a",
"member",
")",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/sortedset.py#L108-L115 |
locationlabs/mockredis | mockredis/sortedset.py | SortedSet.range | def range(self, start, end, desc=False):
"""
Return (score, member) pairs between min and max ranks.
"""
if not self:
return []
if desc:
return reversed(self._scores[len(self) - end - 1:len(self) - start])
else:
return self._scores[sta... | python | def range(self, start, end, desc=False):
"""
Return (score, member) pairs between min and max ranks.
"""
if not self:
return []
if desc:
return reversed(self._scores[len(self) - end - 1:len(self) - start])
else:
return self._scores[sta... | [
"def",
"range",
"(",
"self",
",",
"start",
",",
"end",
",",
"desc",
"=",
"False",
")",
":",
"if",
"not",
"self",
":",
"return",
"[",
"]",
"if",
"desc",
":",
"return",
"reversed",
"(",
"self",
".",
"_scores",
"[",
"len",
"(",
"self",
")",
"-",
"... | Return (score, member) pairs between min and max ranks. | [
"Return",
"(",
"score",
"member",
")",
"pairs",
"between",
"min",
"and",
"max",
"ranks",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/sortedset.py#L117-L127 |
locationlabs/mockredis | mockredis/sortedset.py | SortedSet.scorerange | def scorerange(self, start, end, start_inclusive=True, end_inclusive=True):
"""
Return (score, member) pairs between min and max scores.
"""
if not self:
return []
left = bisect_left(self._scores, (start,))
right = bisect_right(self._scores, (end,))
... | python | def scorerange(self, start, end, start_inclusive=True, end_inclusive=True):
"""
Return (score, member) pairs between min and max scores.
"""
if not self:
return []
left = bisect_left(self._scores, (start,))
right = bisect_right(self._scores, (end,))
... | [
"def",
"scorerange",
"(",
"self",
",",
"start",
",",
"end",
",",
"start_inclusive",
"=",
"True",
",",
"end_inclusive",
"=",
"True",
")",
":",
"if",
"not",
"self",
":",
"return",
"[",
"]",
"left",
"=",
"bisect_left",
"(",
"self",
".",
"_scores",
",",
... | Return (score, member) pairs between min and max scores. | [
"Return",
"(",
"score",
"member",
")",
"pairs",
"between",
"min",
"and",
"max",
"scores",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/sortedset.py#L129-L147 |
locationlabs/mockredis | mockredis/pipeline.py | MockRedisPipeline.watch | def watch(self, *keys):
"""
Put the pipeline into immediate execution mode.
Does not actually watch any keys.
"""
if self.explicit_transaction:
raise RedisError("Cannot issue a WATCH after a MULTI")
self.watching = True
for key in keys:
sel... | python | def watch(self, *keys):
"""
Put the pipeline into immediate execution mode.
Does not actually watch any keys.
"""
if self.explicit_transaction:
raise RedisError("Cannot issue a WATCH after a MULTI")
self.watching = True
for key in keys:
sel... | [
"def",
"watch",
"(",
"self",
",",
"*",
"keys",
")",
":",
"if",
"self",
".",
"explicit_transaction",
":",
"raise",
"RedisError",
"(",
"\"Cannot issue a WATCH after a MULTI\"",
")",
"self",
".",
"watching",
"=",
"True",
"for",
"key",
"in",
"keys",
":",
"self",... | Put the pipeline into immediate execution mode.
Does not actually watch any keys. | [
"Put",
"the",
"pipeline",
"into",
"immediate",
"execution",
"mode",
".",
"Does",
"not",
"actually",
"watch",
"any",
"keys",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/pipeline.py#L33-L42 |
locationlabs/mockredis | mockredis/pipeline.py | MockRedisPipeline.multi | def multi(self):
"""
Start a transactional block of the pipeline after WATCH commands
are issued. End the transactional block with `execute`.
"""
if self.explicit_transaction:
raise RedisError("Cannot issue nested calls to MULTI")
if self.commands:
... | python | def multi(self):
"""
Start a transactional block of the pipeline after WATCH commands
are issued. End the transactional block with `execute`.
"""
if self.explicit_transaction:
raise RedisError("Cannot issue nested calls to MULTI")
if self.commands:
... | [
"def",
"multi",
"(",
"self",
")",
":",
"if",
"self",
".",
"explicit_transaction",
":",
"raise",
"RedisError",
"(",
"\"Cannot issue nested calls to MULTI\"",
")",
"if",
"self",
".",
"commands",
":",
"raise",
"RedisError",
"(",
"\"Commands without an initial WATCH have ... | Start a transactional block of the pipeline after WATCH commands
are issued. End the transactional block with `execute`. | [
"Start",
"a",
"transactional",
"block",
"of",
"the",
"pipeline",
"after",
"WATCH",
"commands",
"are",
"issued",
".",
"End",
"the",
"transactional",
"block",
"with",
"execute",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/pipeline.py#L44-L53 |
locationlabs/mockredis | mockredis/pipeline.py | MockRedisPipeline.execute | def execute(self):
"""
Execute all of the saved commands and return results.
"""
try:
for key, value in self._watched_keys.items():
if self.mock_redis.redis.get(self.mock_redis._encode(key)) != value:
raise WatchError("Watched variable chan... | python | def execute(self):
"""
Execute all of the saved commands and return results.
"""
try:
for key, value in self._watched_keys.items():
if self.mock_redis.redis.get(self.mock_redis._encode(key)) != value:
raise WatchError("Watched variable chan... | [
"def",
"execute",
"(",
"self",
")",
":",
"try",
":",
"for",
"key",
",",
"value",
"in",
"self",
".",
"_watched_keys",
".",
"items",
"(",
")",
":",
"if",
"self",
".",
"mock_redis",
".",
"redis",
".",
"get",
"(",
"self",
".",
"mock_redis",
".",
"_enco... | Execute all of the saved commands and return results. | [
"Execute",
"all",
"of",
"the",
"saved",
"commands",
"and",
"return",
"results",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/pipeline.py#L55-L65 |
locationlabs/mockredis | mockredis/pipeline.py | MockRedisPipeline._reset | def _reset(self):
"""
Reset instance variables.
"""
self.commands = []
self.watching = False
self._watched_keys = {}
self.explicit_transaction = False | python | def _reset(self):
"""
Reset instance variables.
"""
self.commands = []
self.watching = False
self._watched_keys = {}
self.explicit_transaction = False | [
"def",
"_reset",
"(",
"self",
")",
":",
"self",
".",
"commands",
"=",
"[",
"]",
"self",
".",
"watching",
"=",
"False",
"self",
".",
"_watched_keys",
"=",
"{",
"}",
"self",
".",
"explicit_transaction",
"=",
"False"
] | Reset instance variables. | [
"Reset",
"instance",
"variables",
"."
] | train | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/pipeline.py#L67-L74 |
FraBle/python-duckling | duckling/language.py | Language.convert_to_duckling_language_id | def convert_to_duckling_language_id(cls, lang):
"""Ensure a language identifier has the correct duckling format and is supported."""
if lang is not None and cls.is_supported(lang):
return lang
elif lang is not None and cls.is_supported(lang + "$core"): # Support ISO 639-1 Language... | python | def convert_to_duckling_language_id(cls, lang):
"""Ensure a language identifier has the correct duckling format and is supported."""
if lang is not None and cls.is_supported(lang):
return lang
elif lang is not None and cls.is_supported(lang + "$core"): # Support ISO 639-1 Language... | [
"def",
"convert_to_duckling_language_id",
"(",
"cls",
",",
"lang",
")",
":",
"if",
"lang",
"is",
"not",
"None",
"and",
"cls",
".",
"is_supported",
"(",
"lang",
")",
":",
"return",
"lang",
"elif",
"lang",
"is",
"not",
"None",
"and",
"cls",
".",
"is_suppor... | Ensure a language identifier has the correct duckling format and is supported. | [
"Ensure",
"a",
"language",
"identifier",
"has",
"the",
"correct",
"duckling",
"format",
"and",
"is",
"supported",
"."
] | train | https://github.com/FraBle/python-duckling/blob/e6a34192e35fd4fc287b4bc93c938fcd5c2d9024/duckling/language.py#L51-L60 |
FraBle/python-duckling | duckling/duckling.py | Duckling.load | def load(self, languages=[]):
"""Loads the Duckling corpus.
Languages can be specified, defaults to all.
Args:
languages: Optional parameter to specify languages,
e.g. [Duckling.ENGLISH, Duckling.FRENCH] or supported ISO 639-1 Codes (e.g. ["en", "fr"])
"""
... | python | def load(self, languages=[]):
"""Loads the Duckling corpus.
Languages can be specified, defaults to all.
Args:
languages: Optional parameter to specify languages,
e.g. [Duckling.ENGLISH, Duckling.FRENCH] or supported ISO 639-1 Codes (e.g. ["en", "fr"])
"""
... | [
"def",
"load",
"(",
"self",
",",
"languages",
"=",
"[",
"]",
")",
":",
"duckling_load",
"=",
"self",
".",
"clojure",
".",
"var",
"(",
"\"duckling.core\"",
",",
"\"load!\"",
")",
"clojure_hashmap",
"=",
"self",
".",
"clojure",
".",
"var",
"(",
"\"clojure.... | Loads the Duckling corpus.
Languages can be specified, defaults to all.
Args:
languages: Optional parameter to specify languages,
e.g. [Duckling.ENGLISH, Duckling.FRENCH] or supported ISO 639-1 Codes (e.g. ["en", "fr"]) | [
"Loads",
"the",
"Duckling",
"corpus",
"."
] | train | https://github.com/FraBle/python-duckling/blob/e6a34192e35fd4fc287b4bc93c938fcd5c2d9024/duckling/duckling.py#L81-L107 |
FraBle/python-duckling | duckling/duckling.py | Duckling.parse | def parse(self, input_str, language=Language.ENGLISH, dim_filter=None, reference_time=''):
"""Parses datetime information out of string input.
It invokes the Duckling.parse() function in Clojure.
A language can be specified, default is English.
Args:
input_str: The input as... | python | def parse(self, input_str, language=Language.ENGLISH, dim_filter=None, reference_time=''):
"""Parses datetime information out of string input.
It invokes the Duckling.parse() function in Clojure.
A language can be specified, default is English.
Args:
input_str: The input as... | [
"def",
"parse",
"(",
"self",
",",
"input_str",
",",
"language",
"=",
"Language",
".",
"ENGLISH",
",",
"dim_filter",
"=",
"None",
",",
"reference_time",
"=",
"''",
")",
":",
"if",
"self",
".",
"_is_loaded",
"is",
"False",
":",
"raise",
"RuntimeError",
"("... | Parses datetime information out of string input.
It invokes the Duckling.parse() function in Clojure.
A language can be specified, default is English.
Args:
input_str: The input as string that has to be parsed.
language: Optional parameter to specify language,
... | [
"Parses",
"datetime",
"information",
"out",
"of",
"string",
"input",
"."
] | train | https://github.com/FraBle/python-duckling/blob/e6a34192e35fd4fc287b4bc93c938fcd5c2d9024/duckling/duckling.py#L109-L160 |
FraBle/python-duckling | duckling/wrapper.py | DucklingWrapper.parse_time | def parse_time(self, input_str, reference_time=''):
"""Parses input with Duckling for occurences of times.
Args:
input_str: An input string, e.g. 'Let's meet at 11:45am'.
reference_time: Optional reference time for Duckling.
Returns:
A preprocessed list of r... | python | def parse_time(self, input_str, reference_time=''):
"""Parses input with Duckling for occurences of times.
Args:
input_str: An input string, e.g. 'Let's meet at 11:45am'.
reference_time: Optional reference time for Duckling.
Returns:
A preprocessed list of r... | [
"def",
"parse_time",
"(",
"self",
",",
"input_str",
",",
"reference_time",
"=",
"''",
")",
":",
"return",
"self",
".",
"_parse",
"(",
"input_str",
",",
"dim",
"=",
"Dim",
".",
"TIME",
",",
"reference_time",
"=",
"reference_time",
")"
] | Parses input with Duckling for occurences of times.
Args:
input_str: An input string, e.g. 'Let's meet at 11:45am'.
reference_time: Optional reference time for Duckling.
Returns:
A preprocessed list of results (dicts) from Duckling output. For
example:
... | [
"Parses",
"input",
"with",
"Duckling",
"for",
"occurences",
"of",
"times",
"."
] | train | https://github.com/FraBle/python-duckling/blob/e6a34192e35fd4fc287b4bc93c938fcd5c2d9024/duckling/wrapper.py#L258-L287 |
horazont/aioxmpp | aioxmpp/adhoc/service.py | AdHocClient.get_commands | def get_commands(self, peer_jid):
"""
Return the list of commands offered by the peer.
:param peer_jid: JID of the peer to query
:type peer_jid: :class:`~aioxmpp.JID`
:rtype: :class:`list` of :class:`~.disco.xso.Item`
:return: List of command items
In the return... | python | def get_commands(self, peer_jid):
"""
Return the list of commands offered by the peer.
:param peer_jid: JID of the peer to query
:type peer_jid: :class:`~aioxmpp.JID`
:rtype: :class:`list` of :class:`~.disco.xso.Item`
:return: List of command items
In the return... | [
"def",
"get_commands",
"(",
"self",
",",
"peer_jid",
")",
":",
"disco",
"=",
"self",
".",
"dependencies",
"[",
"aioxmpp",
".",
"disco",
".",
"DiscoClient",
"]",
"response",
"=",
"yield",
"from",
"disco",
".",
"query_items",
"(",
"peer_jid",
",",
"node",
... | Return the list of commands offered by the peer.
:param peer_jid: JID of the peer to query
:type peer_jid: :class:`~aioxmpp.JID`
:rtype: :class:`list` of :class:`~.disco.xso.Item`
:return: List of command items
In the returned list, each :class:`~.disco.xso.Item` represents one... | [
"Return",
"the",
"list",
"of",
"commands",
"offered",
"by",
"the",
"peer",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/adhoc/service.py#L72-L92 |
horazont/aioxmpp | aioxmpp/adhoc/service.py | AdHocClient.get_command_info | def get_command_info(self, peer_jid, command_name):
"""
Obtain information about a command.
:param peer_jid: JID of the peer to query
:type peer_jid: :class:`~aioxmpp.JID`
:param command_name: Node name of the command
:type command_name: :class:`str`
:rtype: :cla... | python | def get_command_info(self, peer_jid, command_name):
"""
Obtain information about a command.
:param peer_jid: JID of the peer to query
:type peer_jid: :class:`~aioxmpp.JID`
:param command_name: Node name of the command
:type command_name: :class:`str`
:rtype: :cla... | [
"def",
"get_command_info",
"(",
"self",
",",
"peer_jid",
",",
"command_name",
")",
":",
"disco",
"=",
"self",
".",
"dependencies",
"[",
"aioxmpp",
".",
"disco",
".",
"DiscoClient",
"]",
"response",
"=",
"yield",
"from",
"disco",
".",
"query_info",
"(",
"pe... | Obtain information about a command.
:param peer_jid: JID of the peer to query
:type peer_jid: :class:`~aioxmpp.JID`
:param command_name: Node name of the command
:type command_name: :class:`str`
:rtype: :class:`~.disco.xso.InfoQuery`
:return: Service discovery informatio... | [
"Obtain",
"information",
"about",
"a",
"command",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/adhoc/service.py#L95-L122 |
horazont/aioxmpp | aioxmpp/adhoc/service.py | AdHocClient.supports_commands | def supports_commands(self, peer_jid):
"""
Detect whether a peer supports :xep:`50` Ad-Hoc commands.
:param peer_jid: JID of the peer to query
:type peer_jid: :class:`aioxmpp.JID`
:rtype: :class:`bool`
:return: True if the peer supports the Ad-Hoc commands protocol, fals... | python | def supports_commands(self, peer_jid):
"""
Detect whether a peer supports :xep:`50` Ad-Hoc commands.
:param peer_jid: JID of the peer to query
:type peer_jid: :class:`aioxmpp.JID`
:rtype: :class:`bool`
:return: True if the peer supports the Ad-Hoc commands protocol, fals... | [
"def",
"supports_commands",
"(",
"self",
",",
"peer_jid",
")",
":",
"disco",
"=",
"self",
".",
"dependencies",
"[",
"aioxmpp",
".",
"disco",
".",
"DiscoClient",
"]",
"response",
"=",
"yield",
"from",
"disco",
".",
"query_info",
"(",
"peer_jid",
",",
")",
... | Detect whether a peer supports :xep:`50` Ad-Hoc commands.
:param peer_jid: JID of the peer to query
:type peer_jid: :class:`aioxmpp.JID`
:rtype: :class:`bool`
:return: True if the peer supports the Ad-Hoc commands protocol, false
otherwise.
Note that the fact t... | [
"Detect",
"whether",
"a",
"peer",
"supports",
":",
"xep",
":",
"50",
"Ad",
"-",
"Hoc",
"commands",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/adhoc/service.py#L125-L144 |
horazont/aioxmpp | aioxmpp/adhoc/service.py | AdHocClient.execute | def execute(self, peer_jid, command_name):
"""
Start execution of a command with a peer.
:param peer_jid: JID of the peer to start the command at.
:type peer_jid: :class:`~aioxmpp.JID`
:param command_name: Node name of the command to execute.
:type command_name: :class:`... | python | def execute(self, peer_jid, command_name):
"""
Start execution of a command with a peer.
:param peer_jid: JID of the peer to start the command at.
:type peer_jid: :class:`~aioxmpp.JID`
:param command_name: Node name of the command to execute.
:type command_name: :class:`... | [
"def",
"execute",
"(",
"self",
",",
"peer_jid",
",",
"command_name",
")",
":",
"session",
"=",
"ClientSession",
"(",
"self",
".",
"client",
".",
"stream",
",",
"peer_jid",
",",
"command_name",
",",
")",
"yield",
"from",
"session",
".",
"start",
"(",
")",... | Start execution of a command with a peer.
:param peer_jid: JID of the peer to start the command at.
:type peer_jid: :class:`~aioxmpp.JID`
:param command_name: Node name of the command to execute.
:type command_name: :class:`str`
:rtype: :class:`~.adhoc.service.ClientSession`
... | [
"Start",
"execution",
"of",
"a",
"command",
"with",
"a",
"peer",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/adhoc/service.py#L147-L171 |
horazont/aioxmpp | aioxmpp/adhoc/service.py | AdHocServer.register_stateless_command | def register_stateless_command(self, node, name, handler, *,
is_allowed=None,
features={namespaces.xep0004_data}):
"""
Register a handler for a stateless command.
:param node: Name of the command (``node`` in the service disc... | python | def register_stateless_command(self, node, name, handler, *,
is_allowed=None,
features={namespaces.xep0004_data}):
"""
Register a handler for a stateless command.
:param node: Name of the command (``node`` in the service disc... | [
"def",
"register_stateless_command",
"(",
"self",
",",
"node",
",",
"name",
",",
"handler",
",",
"*",
",",
"is_allowed",
"=",
"None",
",",
"features",
"=",
"{",
"namespaces",
".",
"xep0004_data",
"}",
")",
":",
"info",
"=",
"CommandEntry",
"(",
"name",
"... | Register a handler for a stateless command.
:param node: Name of the command (``node`` in the service discovery
list).
:type node: :class:`str`
:param name: Human-readable name of the command
:type name: :class:`str` or :class:`~.LanguageMap`
:param handler:... | [
"Register",
"a",
"handler",
"for",
"a",
"stateless",
"command",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/adhoc/service.py#L299-L349 |
horazont/aioxmpp | aioxmpp/adhoc/service.py | ClientSession.allowed_actions | def allowed_actions(self):
"""
Shorthand to access :attr:`~.xso.Actions.allowed_actions` of the
:attr:`response`.
If no response has been received yet or if the response specifies no
set of valid actions, this is the minimal set of allowed actions (
:attr:`~.ActionType.E... | python | def allowed_actions(self):
"""
Shorthand to access :attr:`~.xso.Actions.allowed_actions` of the
:attr:`response`.
If no response has been received yet or if the response specifies no
set of valid actions, this is the minimal set of allowed actions (
:attr:`~.ActionType.E... | [
"def",
"allowed_actions",
"(",
"self",
")",
":",
"if",
"self",
".",
"_response",
"is",
"not",
"None",
"and",
"self",
".",
"_response",
".",
"actions",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_response",
".",
"actions",
".",
"allowed_actions",
"... | Shorthand to access :attr:`~.xso.Actions.allowed_actions` of the
:attr:`response`.
If no response has been received yet or if the response specifies no
set of valid actions, this is the minimal set of allowed actions (
:attr:`~.ActionType.EXECUTE` and :attr:`~.ActionType.CANCEL`). | [
"Shorthand",
"to",
"access",
":",
"attr",
":",
"~",
".",
"xso",
".",
"Actions",
".",
"allowed_actions",
"of",
"the",
":",
"attr",
":",
"response",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/adhoc/service.py#L464-L477 |
horazont/aioxmpp | aioxmpp/adhoc/service.py | ClientSession.start | def start(self):
"""
Initiate the session by starting to execute the command with the peer.
:return: The :attr:`~.xso.Command.first_payload` of the response
This sends an empty command IQ request with the
:attr:`~.ActionType.EXECUTE` action.
The :attr:`status`, :attr:`... | python | def start(self):
"""
Initiate the session by starting to execute the command with the peer.
:return: The :attr:`~.xso.Command.first_payload` of the response
This sends an empty command IQ request with the
:attr:`~.ActionType.EXECUTE` action.
The :attr:`status`, :attr:`... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"_response",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"command execution already started\"",
")",
"request",
"=",
"aioxmpp",
".",
"IQ",
"(",
"type_",
"=",
"aioxmpp",
".",
"IQType",
... | Initiate the session by starting to execute the command with the peer.
:return: The :attr:`~.xso.Command.first_payload` of the response
This sends an empty command IQ request with the
:attr:`~.ActionType.EXECUTE` action.
The :attr:`status`, :attr:`response` and related attributes get ... | [
"Initiate",
"the",
"session",
"by",
"starting",
"to",
"execute",
"the",
"command",
"with",
"the",
"peer",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/adhoc/service.py#L480-L506 |
horazont/aioxmpp | aioxmpp/adhoc/service.py | ClientSession.proceed | def proceed(self, *,
action=adhoc_xso.ActionType.EXECUTE,
payload=None):
"""
Proceed command execution to the next stage.
:param action: Action type for proceeding
:type action: :class:`~.ActionTyp`
:param payload: Payload for the request, or :dat... | python | def proceed(self, *,
action=adhoc_xso.ActionType.EXECUTE,
payload=None):
"""
Proceed command execution to the next stage.
:param action: Action type for proceeding
:type action: :class:`~.ActionTyp`
:param payload: Payload for the request, or :dat... | [
"def",
"proceed",
"(",
"self",
",",
"*",
",",
"action",
"=",
"adhoc_xso",
".",
"ActionType",
".",
"EXECUTE",
",",
"payload",
"=",
"None",
")",
":",
"if",
"self",
".",
"_response",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"command execution not st... | Proceed command execution to the next stage.
:param action: Action type for proceeding
:type action: :class:`~.ActionTyp`
:param payload: Payload for the request, or :data:`None`
:return: The :attr:`~.xso.Command.first_payload` of the response
`action` must be one of the action... | [
"Proceed",
"command",
"execution",
"to",
"the",
"next",
"stage",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/adhoc/service.py#L509-L572 |
horazont/aioxmpp | aioxmpp/ibb/service.py | IBBTransport.write | def write(self, data):
"""
Send `data` over the IBB. If `data` is larger than the block size
is is chunked and sent in chunks.
Chunks from one call of :meth:`write` will always be sent in
series.
"""
if self.is_closing():
return
self._write_... | python | def write(self, data):
"""
Send `data` over the IBB. If `data` is larger than the block size
is is chunked and sent in chunks.
Chunks from one call of :meth:`write` will always be sent in
series.
"""
if self.is_closing():
return
self._write_... | [
"def",
"write",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"is_closing",
"(",
")",
":",
"return",
"self",
".",
"_write_buffer",
"+=",
"data",
"if",
"len",
"(",
"self",
".",
"_write_buffer",
")",
">=",
"self",
".",
"_output_buffer_limit_high",... | Send `data` over the IBB. If `data` is larger than the block size
is is chunked and sent in chunks.
Chunks from one call of :meth:`write` will always be sent in
series. | [
"Send",
"data",
"over",
"the",
"IBB",
".",
"If",
"data",
"is",
"larger",
"than",
"the",
"block",
"size",
"is",
"is",
"chunked",
"and",
"sent",
"in",
"chunks",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/ibb/service.py#L232-L250 |
horazont/aioxmpp | aioxmpp/ibb/service.py | IBBTransport.close | def close(self):
"""
Close the session.
"""
if self.is_closing():
return
self._closing = True
# make sure the writer wakes up
self._can_write.set() | python | def close(self):
"""
Close the session.
"""
if self.is_closing():
return
self._closing = True
# make sure the writer wakes up
self._can_write.set() | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_closing",
"(",
")",
":",
"return",
"self",
".",
"_closing",
"=",
"True",
"# make sure the writer wakes up",
"self",
".",
"_can_write",
".",
"set",
"(",
")"
] | Close the session. | [
"Close",
"the",
"session",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/ibb/service.py#L265-L274 |
horazont/aioxmpp | aioxmpp/ibb/service.py | IBBService.expect_session | def expect_session(self, protocol_factory, peer_jid, sid):
"""
Whitelist the session with `peer_jid` and the session id `sid` and
return it when it is established. This is meant to be used
with signalling protocols like Jingle and is the counterpart
to :meth:`open_session`.
... | python | def expect_session(self, protocol_factory, peer_jid, sid):
"""
Whitelist the session with `peer_jid` and the session id `sid` and
return it when it is established. This is meant to be used
with signalling protocols like Jingle and is the counterpart
to :meth:`open_session`.
... | [
"def",
"expect_session",
"(",
"self",
",",
"protocol_factory",
",",
"peer_jid",
",",
"sid",
")",
":",
"def",
"on_done",
"(",
"fut",
")",
":",
"del",
"self",
".",
"_expected_sessions",
"[",
"sid",
",",
"peer_jid",
"]",
"_",
",",
"fut",
"=",
"self",
".",... | Whitelist the session with `peer_jid` and the session id `sid` and
return it when it is established. This is meant to be used
with signalling protocols like Jingle and is the counterpart
to :meth:`open_session`.
:returns: an awaitable object, whose result is the tuple
... | [
"Whitelist",
"the",
"session",
"with",
"peer_jid",
"and",
"the",
"session",
"id",
"sid",
"and",
"return",
"it",
"when",
"it",
"is",
"established",
".",
"This",
"is",
"meant",
"to",
"be",
"used",
"with",
"signalling",
"protocols",
"like",
"Jingle",
"and",
"... | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/ibb/service.py#L399-L416 |
horazont/aioxmpp | aioxmpp/ibb/service.py | IBBService.open_session | def open_session(self, protocol_factory, peer_jid, *,
stanza_type=ibb_xso.IBBStanzaType.IQ,
block_size=4096, sid=None):
"""
Establish an in-band bytestream session with `peer_jid` and
return the transport and protocol.
:param protocol_factory: t... | python | def open_session(self, protocol_factory, peer_jid, *,
stanza_type=ibb_xso.IBBStanzaType.IQ,
block_size=4096, sid=None):
"""
Establish an in-band bytestream session with `peer_jid` and
return the transport and protocol.
:param protocol_factory: t... | [
"def",
"open_session",
"(",
"self",
",",
"protocol_factory",
",",
"peer_jid",
",",
"*",
",",
"stanza_type",
"=",
"ibb_xso",
".",
"IBBStanzaType",
".",
"IQ",
",",
"block_size",
"=",
"4096",
",",
"sid",
"=",
"None",
")",
":",
"if",
"block_size",
">",
"MAX_... | Establish an in-band bytestream session with `peer_jid` and
return the transport and protocol.
:param protocol_factory: the protocol factory
:type protocol_factory: a nullary callable returning an
:class:`asyncio.Protocol` instance
:param peer_jid: the JI... | [
"Establish",
"an",
"in",
"-",
"band",
"bytestream",
"session",
"with",
"peer_jid",
"and",
"return",
"the",
"transport",
"and",
"protocol",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/ibb/service.py#L419-L471 |
horazont/aioxmpp | docs/sphinx-data/extensions/aioxmppspecific.py | xep_role | def xep_role(typ, rawtext, text, lineno, inliner,
options={}, content=[]):
"""Role for PEP/RFC references that generate an index entry."""
env = inliner.document.settings.env
if not typ:
typ = env.config.default_role
else:
typ = typ.lower()
has_explicit_title, title, tar... | python | def xep_role(typ, rawtext, text, lineno, inliner,
options={}, content=[]):
"""Role for PEP/RFC references that generate an index entry."""
env = inliner.document.settings.env
if not typ:
typ = env.config.default_role
else:
typ = typ.lower()
has_explicit_title, title, tar... | [
"def",
"xep_role",
"(",
"typ",
",",
"rawtext",
",",
"text",
",",
"lineno",
",",
"inliner",
",",
"options",
"=",
"{",
"}",
",",
"content",
"=",
"[",
"]",
")",
":",
"env",
"=",
"inliner",
".",
"document",
".",
"settings",
".",
"env",
"if",
"not",
"... | Role for PEP/RFC references that generate an index entry. | [
"Role",
"for",
"PEP",
"/",
"RFC",
"references",
"that",
"generate",
"an",
"index",
"entry",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/docs/sphinx-data/extensions/aioxmppspecific.py#L136-L171 |
horazont/aioxmpp | aioxmpp/xso/types.py | EnumType | def EnumType(enum_class, nested_type=_Undefined, **kwargs):
"""
Create and return a :class:`EnumCDataType` or :class:`EnumElementType`,
depending on the type of `nested_type`.
If `nested_type` is a :class:`AbstractCDataType` or omitted, a
:class:`EnumCDataType` is constructed. Otherwise, :class:`En... | python | def EnumType(enum_class, nested_type=_Undefined, **kwargs):
"""
Create and return a :class:`EnumCDataType` or :class:`EnumElementType`,
depending on the type of `nested_type`.
If `nested_type` is a :class:`AbstractCDataType` or omitted, a
:class:`EnumCDataType` is constructed. Otherwise, :class:`En... | [
"def",
"EnumType",
"(",
"enum_class",
",",
"nested_type",
"=",
"_Undefined",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"nested_type",
"is",
"_Undefined",
":",
"return",
"EnumCDataType",
"(",
"enum_class",
",",
"*",
"*",
"kwargs",
")",
"if",
"isinstance",
"(... | Create and return a :class:`EnumCDataType` or :class:`EnumElementType`,
depending on the type of `nested_type`.
If `nested_type` is a :class:`AbstractCDataType` or omitted, a
:class:`EnumCDataType` is constructed. Otherwise, :class:`EnumElementType`
is used.
The arguments are forwarded to the resp... | [
"Create",
"and",
"return",
"a",
":",
"class",
":",
"EnumCDataType",
"or",
":",
"class",
":",
"EnumElementType",
"depending",
"on",
"the",
"type",
"of",
"nested_type",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/xso/types.py#L1169-L1196 |
horazont/aioxmpp | aioxmpp/muc/service.py | _extract_one_pair | def _extract_one_pair(body):
"""
Extract one language-text pair from a :class:`~.LanguageMap`.
This is used for tracking.
"""
if not body:
return None, None
try:
return None, body[None]
except KeyError:
return min(body.items(), key=lambda x: x[0]) | python | def _extract_one_pair(body):
"""
Extract one language-text pair from a :class:`~.LanguageMap`.
This is used for tracking.
"""
if not body:
return None, None
try:
return None, body[None]
except KeyError:
return min(body.items(), key=lambda x: x[0]) | [
"def",
"_extract_one_pair",
"(",
"body",
")",
":",
"if",
"not",
"body",
":",
"return",
"None",
",",
"None",
"try",
":",
"return",
"None",
",",
"body",
"[",
"None",
"]",
"except",
"KeyError",
":",
"return",
"min",
"(",
"body",
".",
"items",
"(",
")",
... | Extract one language-text pair from a :class:`~.LanguageMap`.
This is used for tracking. | [
"Extract",
"one",
"language",
"-",
"text",
"pair",
"from",
"a",
":",
"class",
":",
"~",
".",
"LanguageMap",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L48-L60 |
horazont/aioxmpp | aioxmpp/muc/service.py | Room.members | def members(self):
"""
A copy of the list of occupants. The local user is always the first
item in the list, unless the :meth:`on_enter` has not fired yet.
"""
if self._this_occupant is not None:
items = [self._this_occupant]
else:
items = []
... | python | def members(self):
"""
A copy of the list of occupants. The local user is always the first
item in the list, unless the :meth:`on_enter` has not fired yet.
"""
if self._this_occupant is not None:
items = [self._this_occupant]
else:
items = []
... | [
"def",
"members",
"(",
"self",
")",
":",
"if",
"self",
".",
"_this_occupant",
"is",
"not",
"None",
":",
"items",
"=",
"[",
"self",
".",
"_this_occupant",
"]",
"else",
":",
"items",
"=",
"[",
"]",
"items",
"+=",
"list",
"(",
"self",
".",
"_occupant_in... | A copy of the list of occupants. The local user is always the first
item in the list, unless the :meth:`on_enter` has not fired yet. | [
"A",
"copy",
"of",
"the",
"list",
"of",
"occupants",
".",
"The",
"local",
"user",
"is",
"always",
"the",
"first",
"item",
"in",
"the",
"list",
"unless",
"the",
":",
"meth",
":",
"on_enter",
"has",
"not",
"fired",
"yet",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L986-L997 |
horazont/aioxmpp | aioxmpp/muc/service.py | Room.features | def features(self):
"""
The set of features supported by this MUC. This may vary depending on
features exported by the MUC service, so be sure to check this for each
individual MUC.
"""
return {
aioxmpp.im.conversation.ConversationFeature.BAN,
aio... | python | def features(self):
"""
The set of features supported by this MUC. This may vary depending on
features exported by the MUC service, so be sure to check this for each
individual MUC.
"""
return {
aioxmpp.im.conversation.ConversationFeature.BAN,
aio... | [
"def",
"features",
"(",
"self",
")",
":",
"return",
"{",
"aioxmpp",
".",
"im",
".",
"conversation",
".",
"ConversationFeature",
".",
"BAN",
",",
"aioxmpp",
".",
"im",
".",
"conversation",
".",
"ConversationFeature",
".",
"BAN_WITH_KICK",
",",
"aioxmpp",
".",... | The set of features supported by this MUC. This may vary depending on
features exported by the MUC service, so be sure to check this for each
individual MUC. | [
"The",
"set",
"of",
"features",
"supported",
"by",
"this",
"MUC",
".",
"This",
"may",
"vary",
"depending",
"on",
"features",
"exported",
"by",
"the",
"MUC",
"service",
"so",
"be",
"sure",
"to",
"check",
"this",
"for",
"each",
"individual",
"MUC",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1018-L1035 |
horazont/aioxmpp | aioxmpp/muc/service.py | Room.send_message | def send_message(self, msg):
"""
Send a message to the MUC.
:param msg: The message to send.
:type msg: :class:`aioxmpp.Message`
:return: The stanza token of the message.
:rtype: :class:`~aioxmpp.stream.StanzaToken`
There is no need to set the address attributes... | python | def send_message(self, msg):
"""
Send a message to the MUC.
:param msg: The message to send.
:type msg: :class:`aioxmpp.Message`
:return: The stanza token of the message.
:rtype: :class:`~aioxmpp.stream.StanzaToken`
There is no need to set the address attributes... | [
"def",
"send_message",
"(",
"self",
",",
"msg",
")",
":",
"msg",
".",
"type_",
"=",
"aioxmpp",
".",
"MessageType",
".",
"GROUPCHAT",
"msg",
".",
"to",
"=",
"self",
".",
"_mucjid",
"# see https://mail.jabber.org/pipermail/standards/2017-January/032048.html # NOQA",
... | Send a message to the MUC.
:param msg: The message to send.
:type msg: :class:`aioxmpp.Message`
:return: The stanza token of the message.
:rtype: :class:`~aioxmpp.stream.StanzaToken`
There is no need to set the address attributes or the type of the
message correctly; th... | [
"Send",
"a",
"message",
"to",
"the",
"MUC",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1470-L1498 |
horazont/aioxmpp | aioxmpp/muc/service.py | Room.send_message_tracked | def send_message_tracked(self, msg):
"""
Send a message to the MUC with tracking.
:param msg: The message to send.
:type msg: :class:`aioxmpp.Message`
.. warning::
Please read :ref:`api-tracking-memory`. This is especially relevant
for MUCs because trac... | python | def send_message_tracked(self, msg):
"""
Send a message to the MUC with tracking.
:param msg: The message to send.
:type msg: :class:`aioxmpp.Message`
.. warning::
Please read :ref:`api-tracking-memory`. This is especially relevant
for MUCs because trac... | [
"def",
"send_message_tracked",
"(",
"self",
",",
"msg",
")",
":",
"msg",
".",
"type_",
"=",
"aioxmpp",
".",
"MessageType",
".",
"GROUPCHAT",
"msg",
".",
"to",
"=",
"self",
".",
"_mucjid",
"# see https://mail.jabber.org/pipermail/standards/2017-January/032048.html # N... | Send a message to the MUC with tracking.
:param msg: The message to send.
:type msg: :class:`aioxmpp.Message`
.. warning::
Please read :ref:`api-tracking-memory`. This is especially relevant
for MUCs because tracking is not guaranteed to work due to how
:xe... | [
"Send",
"a",
"message",
"to",
"the",
"MUC",
"with",
"tracking",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1508-L1610 |
horazont/aioxmpp | aioxmpp/muc/service.py | Room.set_nick | def set_nick(self, new_nick):
"""
Change the nick name of the occupant.
:param new_nick: New nickname to use
:type new_nick: :class:`str`
This sends the request to change the nickname and waits for the request
to be sent over the stream.
The nick change may or ... | python | def set_nick(self, new_nick):
"""
Change the nick name of the occupant.
:param new_nick: New nickname to use
:type new_nick: :class:`str`
This sends the request to change the nickname and waits for the request
to be sent over the stream.
The nick change may or ... | [
"def",
"set_nick",
"(",
"self",
",",
"new_nick",
")",
":",
"stanza",
"=",
"aioxmpp",
".",
"Presence",
"(",
"type_",
"=",
"aioxmpp",
".",
"PresenceType",
".",
"AVAILABLE",
",",
"to",
"=",
"self",
".",
"_mucjid",
".",
"replace",
"(",
"resource",
"=",
"ne... | Change the nick name of the occupant.
:param new_nick: New nickname to use
:type new_nick: :class:`str`
This sends the request to change the nickname and waits for the request
to be sent over the stream.
The nick change may or may not happen, or the service may modify the
... | [
"Change",
"the",
"nick",
"name",
"of",
"the",
"occupant",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1613-L1638 |
horazont/aioxmpp | aioxmpp/muc/service.py | Room.kick | def kick(self, member, reason=None):
"""
Kick an occupant from the MUC.
:param member: The member to kick.
:type member: :class:`Occupant`
:param reason: A reason to show to the members of the conversation
including the kicked member.
:type reason: :class:`st... | python | def kick(self, member, reason=None):
"""
Kick an occupant from the MUC.
:param member: The member to kick.
:type member: :class:`Occupant`
:param reason: A reason to show to the members of the conversation
including the kicked member.
:type reason: :class:`st... | [
"def",
"kick",
"(",
"self",
",",
"member",
",",
"reason",
"=",
"None",
")",
":",
"yield",
"from",
"self",
".",
"muc_set_role",
"(",
"member",
".",
"nick",
",",
"\"none\"",
",",
"reason",
"=",
"reason",
")"
] | Kick an occupant from the MUC.
:param member: The member to kick.
:type member: :class:`Occupant`
:param reason: A reason to show to the members of the conversation
including the kicked member.
:type reason: :class:`str`
:raises aioxmpp.errors.XMPPError: if the serve... | [
"Kick",
"an",
"occupant",
"from",
"the",
"MUC",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1641-L1662 |
horazont/aioxmpp | aioxmpp/muc/service.py | Room.muc_set_role | def muc_set_role(self, nick, role, *, reason=None):
"""
Change the role of an occupant.
:param nick: The nickname of the occupant whose role shall be changed.
:type nick: :class:`str`
:param role: The new role for the occupant.
:type role: :class:`str`
:param rea... | python | def muc_set_role(self, nick, role, *, reason=None):
"""
Change the role of an occupant.
:param nick: The nickname of the occupant whose role shall be changed.
:type nick: :class:`str`
:param role: The new role for the occupant.
:type role: :class:`str`
:param rea... | [
"def",
"muc_set_role",
"(",
"self",
",",
"nick",
",",
"role",
",",
"*",
",",
"reason",
"=",
"None",
")",
":",
"if",
"nick",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"nick must not be None\"",
")",
"if",
"role",
"is",
"None",
":",
"raise",
"Valu... | Change the role of an occupant.
:param nick: The nickname of the occupant whose role shall be changed.
:type nick: :class:`str`
:param role: The new role for the occupant.
:type role: :class:`str`
:param reason: An optional reason to show to the occupant (and all
oth... | [
"Change",
"the",
"role",
"of",
"an",
"occupant",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1665-L1708 |
horazont/aioxmpp | aioxmpp/muc/service.py | Room.ban | def ban(self, member, reason=None, *, request_kick=True):
"""
Ban an occupant from re-joining the MUC.
:param member: The occupant to ban.
:type member: :class:`Occupant`
:param reason: A reason to show to the members of the conversation
including the banned member.
... | python | def ban(self, member, reason=None, *, request_kick=True):
"""
Ban an occupant from re-joining the MUC.
:param member: The occupant to ban.
:type member: :class:`Occupant`
:param reason: A reason to show to the members of the conversation
including the banned member.
... | [
"def",
"ban",
"(",
"self",
",",
"member",
",",
"reason",
"=",
"None",
",",
"*",
",",
"request_kick",
"=",
"True",
")",
":",
"if",
"member",
".",
"direct_jid",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"cannot ban members whose direct JID is not \"",
"... | Ban an occupant from re-joining the MUC.
:param member: The occupant to ban.
:type member: :class:`Occupant`
:param reason: A reason to show to the members of the conversation
including the banned member.
:type reason: :class:`str`
:param request_kick: A flag indicat... | [
"Ban",
"an",
"occupant",
"from",
"re",
"-",
"joining",
"the",
"MUC",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1711-L1741 |
horazont/aioxmpp | aioxmpp/muc/service.py | Room.muc_set_affiliation | def muc_set_affiliation(self, jid, affiliation, *, reason=None):
"""
Convenience wrapper around :meth:`.MUCClient.set_affiliation`. See
there for details, and consider its `mucjid` argument to be set to
:attr:`mucjid`.
"""
return (yield from self.service.set_affiliation(
... | python | def muc_set_affiliation(self, jid, affiliation, *, reason=None):
"""
Convenience wrapper around :meth:`.MUCClient.set_affiliation`. See
there for details, and consider its `mucjid` argument to be set to
:attr:`mucjid`.
"""
return (yield from self.service.set_affiliation(
... | [
"def",
"muc_set_affiliation",
"(",
"self",
",",
"jid",
",",
"affiliation",
",",
"*",
",",
"reason",
"=",
"None",
")",
":",
"return",
"(",
"yield",
"from",
"self",
".",
"service",
".",
"set_affiliation",
"(",
"self",
".",
"_mucjid",
",",
"jid",
",",
"af... | Convenience wrapper around :meth:`.MUCClient.set_affiliation`. See
there for details, and consider its `mucjid` argument to be set to
:attr:`mucjid`. | [
"Convenience",
"wrapper",
"around",
":",
"meth",
":",
".",
"MUCClient",
".",
"set_affiliation",
".",
"See",
"there",
"for",
"details",
"and",
"consider",
"its",
"mucjid",
"argument",
"to",
"be",
"set",
"to",
":",
"attr",
":",
"mucjid",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1744-L1753 |
horazont/aioxmpp | aioxmpp/muc/service.py | Room.set_topic | def set_topic(self, new_topic):
"""
Change the (possibly publicly) visible topic of the conversation.
:param new_topic: The new topic for the conversation.
:type new_topic: :class:`str`
Request to set the subject to `new_topic`. `new_topic` must be a
mapping which maps ... | python | def set_topic(self, new_topic):
"""
Change the (possibly publicly) visible topic of the conversation.
:param new_topic: The new topic for the conversation.
:type new_topic: :class:`str`
Request to set the subject to `new_topic`. `new_topic` must be a
mapping which maps ... | [
"def",
"set_topic",
"(",
"self",
",",
"new_topic",
")",
":",
"msg",
"=",
"aioxmpp",
".",
"stanza",
".",
"Message",
"(",
"type_",
"=",
"aioxmpp",
".",
"structs",
".",
"MessageType",
".",
"GROUPCHAT",
",",
"to",
"=",
"self",
".",
"_mucjid",
")",
"msg",
... | Change the (possibly publicly) visible topic of the conversation.
:param new_topic: The new topic for the conversation.
:type new_topic: :class:`str`
Request to set the subject to `new_topic`. `new_topic` must be a
mapping which maps :class:`~.structs.LanguageTag` tags to strings;
... | [
"Change",
"the",
"(",
"possibly",
"publicly",
")",
"visible",
"topic",
"of",
"the",
"conversation",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1756-L1774 |
horazont/aioxmpp | aioxmpp/muc/service.py | Room.leave | def leave(self):
"""
Leave the MUC.
"""
fut = self.on_exit.future()
def cb(**kwargs):
fut.set_result(None)
return True # disconnect
self.on_exit.connect(cb)
presence = aioxmpp.stanza.Presence(
type_=aioxmpp.structs.PresenceT... | python | def leave(self):
"""
Leave the MUC.
"""
fut = self.on_exit.future()
def cb(**kwargs):
fut.set_result(None)
return True # disconnect
self.on_exit.connect(cb)
presence = aioxmpp.stanza.Presence(
type_=aioxmpp.structs.PresenceT... | [
"def",
"leave",
"(",
"self",
")",
":",
"fut",
"=",
"self",
".",
"on_exit",
".",
"future",
"(",
")",
"def",
"cb",
"(",
"*",
"*",
"kwargs",
")",
":",
"fut",
".",
"set_result",
"(",
"None",
")",
"return",
"True",
"# disconnect",
"self",
".",
"on_exit"... | Leave the MUC. | [
"Leave",
"the",
"MUC",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1777-L1795 |
horazont/aioxmpp | aioxmpp/muc/service.py | Room.muc_request_voice | def muc_request_voice(self):
"""
Request voice (participant role) in the room and wait for the request
to be sent.
The participant role allows occupants to send messages while the room
is in moderated mode.
There is no guarantee that the request will be granted. To dete... | python | def muc_request_voice(self):
"""
Request voice (participant role) in the room and wait for the request
to be sent.
The participant role allows occupants to send messages while the room
is in moderated mode.
There is no guarantee that the request will be granted. To dete... | [
"def",
"muc_request_voice",
"(",
"self",
")",
":",
"msg",
"=",
"aioxmpp",
".",
"Message",
"(",
"to",
"=",
"self",
".",
"_mucjid",
",",
"type_",
"=",
"aioxmpp",
".",
"MessageType",
".",
"NORMAL",
")",
"data",
"=",
"aioxmpp",
".",
"forms",
".",
"Data",
... | Request voice (participant role) in the room and wait for the request
to be sent.
The participant role allows occupants to send messages while the room
is in moderated mode.
There is no guarantee that the request will be granted. To detect that
voice has been granted, observe t... | [
"Request",
"voice",
"(",
"participant",
"role",
")",
"in",
"the",
"room",
"and",
"wait",
"for",
"the",
"request",
"to",
"be",
"sent",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1798-L1838 |
horazont/aioxmpp | aioxmpp/muc/service.py | MUCClient.join | def join(self, mucjid, nick, *,
password=None, history=None, autorejoin=True):
"""
Join a multi-user chat and create a conversation for it.
:param mucjid: The bare JID of the room to join.
:type mucjid: :class:`~aioxmpp.JID`.
:param nick: The nickname to use in the ... | python | def join(self, mucjid, nick, *,
password=None, history=None, autorejoin=True):
"""
Join a multi-user chat and create a conversation for it.
:param mucjid: The bare JID of the room to join.
:type mucjid: :class:`~aioxmpp.JID`.
:param nick: The nickname to use in the ... | [
"def",
"join",
"(",
"self",
",",
"mucjid",
",",
"nick",
",",
"*",
",",
"password",
"=",
"None",
",",
"history",
"=",
"None",
",",
"autorejoin",
"=",
"True",
")",
":",
"if",
"history",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"history",
... | Join a multi-user chat and create a conversation for it.
:param mucjid: The bare JID of the room to join.
:type mucjid: :class:`~aioxmpp.JID`.
:param nick: The nickname to use in the room.
:type nick: :class:`str`
:param password: The password to join the room, if required.
... | [
"Join",
"a",
"multi",
"-",
"user",
"chat",
"and",
"create",
"a",
"conversation",
"for",
"it",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L2265-L2379 |
horazont/aioxmpp | aioxmpp/muc/service.py | MUCClient.set_affiliation | def set_affiliation(self, mucjid, jid, affiliation, *, reason=None):
"""
Change the affiliation of an entity with a MUC.
:param mucjid: The bare JID identifying the MUC.
:type mucjid: :class:`~aioxmpp.JID`
:param jid: The bare JID of the entity whose affiliation shall be
... | python | def set_affiliation(self, mucjid, jid, affiliation, *, reason=None):
"""
Change the affiliation of an entity with a MUC.
:param mucjid: The bare JID identifying the MUC.
:type mucjid: :class:`~aioxmpp.JID`
:param jid: The bare JID of the entity whose affiliation shall be
... | [
"def",
"set_affiliation",
"(",
"self",
",",
"mucjid",
",",
"jid",
",",
"affiliation",
",",
"*",
",",
"reason",
"=",
"None",
")",
":",
"if",
"mucjid",
"is",
"None",
"or",
"not",
"mucjid",
".",
"is_bare",
":",
"raise",
"ValueError",
"(",
"\"mucjid must be ... | Change the affiliation of an entity with a MUC.
:param mucjid: The bare JID identifying the MUC.
:type mucjid: :class:`~aioxmpp.JID`
:param jid: The bare JID of the entity whose affiliation shall be
changed.
:type jid: :class:`~aioxmpp.JID`
:param affiliation: The ne... | [
"Change",
"the",
"affiliation",
"of",
"an",
"entity",
"with",
"a",
"MUC",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L2382-L2435 |
horazont/aioxmpp | aioxmpp/muc/service.py | MUCClient.get_room_config | def get_room_config(self, mucjid):
"""
Query and return the room configuration form for the given MUC.
:param mucjid: JID of the room to query
:type mucjid: bare :class:`~.JID`
:return: data form template for the room configuration
:rtype: :class:`aioxmpp.forms.Data`
... | python | def get_room_config(self, mucjid):
"""
Query and return the room configuration form for the given MUC.
:param mucjid: JID of the room to query
:type mucjid: bare :class:`~.JID`
:return: data form template for the room configuration
:rtype: :class:`aioxmpp.forms.Data`
... | [
"def",
"get_room_config",
"(",
"self",
",",
"mucjid",
")",
":",
"if",
"mucjid",
"is",
"None",
"or",
"not",
"mucjid",
".",
"is_bare",
":",
"raise",
"ValueError",
"(",
"\"mucjid must be bare JID\"",
")",
"iq",
"=",
"aioxmpp",
".",
"stanza",
".",
"IQ",
"(",
... | Query and return the room configuration form for the given MUC.
:param mucjid: JID of the room to query
:type mucjid: bare :class:`~.JID`
:return: data form template for the room configuration
:rtype: :class:`aioxmpp.forms.Data`
.. seealso::
:class:`~.ConfigurationF... | [
"Query",
"and",
"return",
"the",
"room",
"configuration",
"form",
"for",
"the",
"given",
"MUC",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L2438-L2464 |
horazont/aioxmpp | aioxmpp/muc/service.py | MUCClient.set_room_config | def set_room_config(self, mucjid, data):
"""
Set the room configuration using a :xep:`4` data form.
:param mucjid: JID of the room to query
:type mucjid: bare :class:`~.JID`
:param data: Filled-out configuration form
:type data: :class:`aioxmpp.forms.Data`
.. se... | python | def set_room_config(self, mucjid, data):
"""
Set the room configuration using a :xep:`4` data form.
:param mucjid: JID of the room to query
:type mucjid: bare :class:`~.JID`
:param data: Filled-out configuration form
:type data: :class:`aioxmpp.forms.Data`
.. se... | [
"def",
"set_room_config",
"(",
"self",
",",
"mucjid",
",",
"data",
")",
":",
"iq",
"=",
"aioxmpp",
".",
"stanza",
".",
"IQ",
"(",
"type_",
"=",
"aioxmpp",
".",
"structs",
".",
"IQType",
".",
"SET",
",",
"to",
"=",
"mucjid",
",",
"payload",
"=",
"mu... | Set the room configuration using a :xep:`4` data form.
:param mucjid: JID of the room to query
:type mucjid: bare :class:`~.JID`
:param data: Filled-out configuration form
:type data: :class:`aioxmpp.forms.Data`
.. seealso::
:class:`~.ConfigurationForm`
... | [
"Set",
"the",
"room",
"configuration",
"using",
"a",
":",
"xep",
":",
"4",
"data",
"form",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L2467-L2499 |
horazont/aioxmpp | aioxmpp/httpupload/__init__.py | request_slot | def request_slot(client,
service: JID,
filename: str,
size: int,
content_type: str):
"""
Request an HTTP upload slot.
:param client: The client to request the slot with.
:type client: :class:`aioxmpp.Client`
:param service: Address... | python | def request_slot(client,
service: JID,
filename: str,
size: int,
content_type: str):
"""
Request an HTTP upload slot.
:param client: The client to request the slot with.
:type client: :class:`aioxmpp.Client`
:param service: Address... | [
"def",
"request_slot",
"(",
"client",
",",
"service",
":",
"JID",
",",
"filename",
":",
"str",
",",
"size",
":",
"int",
",",
"content_type",
":",
"str",
")",
":",
"payload",
"=",
"Request",
"(",
"filename",
",",
"size",
",",
"content_type",
")",
"retur... | Request an HTTP upload slot.
:param client: The client to request the slot with.
:type client: :class:`aioxmpp.Client`
:param service: Address of the HTTP upload service.
:type service: :class:`~aioxmpp.JID`
:param filename: Name of the file (without path), may be used by the server
to gene... | [
"Request",
"an",
"HTTP",
"upload",
"slot",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/httpupload/__init__.py#L76-L109 |
horazont/aioxmpp | aioxmpp/version/service.py | query_version | def query_version(stream: aioxmpp.stream.StanzaStream,
target: aioxmpp.JID) -> version_xso.Query:
"""
Query the software version of an entity.
:param stream: A stanza stream to send the query on.
:type stream: :class:`aioxmpp.stream.StanzaStream`
:param target: The address of the ... | python | def query_version(stream: aioxmpp.stream.StanzaStream,
target: aioxmpp.JID) -> version_xso.Query:
"""
Query the software version of an entity.
:param stream: A stanza stream to send the query on.
:type stream: :class:`aioxmpp.stream.StanzaStream`
:param target: The address of the ... | [
"def",
"query_version",
"(",
"stream",
":",
"aioxmpp",
".",
"stream",
".",
"StanzaStream",
",",
"target",
":",
"aioxmpp",
".",
"JID",
")",
"->",
"version_xso",
".",
"Query",
":",
"return",
"(",
"yield",
"from",
"stream",
".",
"send",
"(",
"aioxmpp",
".",... | Query the software version of an entity.
:param stream: A stanza stream to send the query on.
:type stream: :class:`aioxmpp.stream.StanzaStream`
:param target: The address of the entity to query.
:type target: :class:`aioxmpp.JID`
:raises OSError: if a connection issue occured before a reply was re... | [
"Query",
"the",
"software",
"version",
"of",
"an",
"entity",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/version/service.py#L185-L212 |
horazont/aioxmpp | aioxmpp/bookmarks/xso.py | as_bookmark_class | def as_bookmark_class(xso_class):
"""
Decorator to register `xso_class` as a custom bookmark class.
This is necessary to store and retrieve such bookmarks.
The registered class must be a subclass of the abstract base class
:class:`Bookmark`.
:raises TypeError: if `xso_class` is not a subclass ... | python | def as_bookmark_class(xso_class):
"""
Decorator to register `xso_class` as a custom bookmark class.
This is necessary to store and retrieve such bookmarks.
The registered class must be a subclass of the abstract base class
:class:`Bookmark`.
:raises TypeError: if `xso_class` is not a subclass ... | [
"def",
"as_bookmark_class",
"(",
"xso_class",
")",
":",
"if",
"not",
"issubclass",
"(",
"xso_class",
",",
"Bookmark",
")",
":",
"raise",
"TypeError",
"(",
"\"Classes registered as bookmark types must be Bookmark subclasses\"",
")",
"Storage",
".",
"register_child",
"(",... | Decorator to register `xso_class` as a custom bookmark class.
This is necessary to store and retrieve such bookmarks.
The registered class must be a subclass of the abstract base class
:class:`Bookmark`.
:raises TypeError: if `xso_class` is not a subclass of :class:`Bookmark`. | [
"Decorator",
"to",
"register",
"xso_class",
"as",
"a",
"custom",
"bookmark",
"class",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/bookmarks/xso.py#L241-L262 |
horazont/aioxmpp | aioxmpp/structs.py | basic_filter_languages | def basic_filter_languages(languages, ranges):
"""
Filter languages using the string-based basic filter algorithm described in
RFC4647.
`languages` must be a sequence of :class:`LanguageTag` instances which are
to be filtered.
`ranges` must be an iterable which represent the basic language ran... | python | def basic_filter_languages(languages, ranges):
"""
Filter languages using the string-based basic filter algorithm described in
RFC4647.
`languages` must be a sequence of :class:`LanguageTag` instances which are
to be filtered.
`ranges` must be an iterable which represent the basic language ran... | [
"def",
"basic_filter_languages",
"(",
"languages",
",",
"ranges",
")",
":",
"if",
"LanguageRange",
".",
"WILDCARD",
"in",
"ranges",
":",
"yield",
"from",
"languages",
"return",
"found",
"=",
"set",
"(",
")",
"for",
"language_range",
"in",
"ranges",
":",
"ran... | Filter languages using the string-based basic filter algorithm described in
RFC4647.
`languages` must be a sequence of :class:`LanguageTag` instances which are
to be filtered.
`ranges` must be an iterable which represent the basic language ranges to
filter with, in priority order. The language ran... | [
"Filter",
"languages",
"using",
"the",
"string",
"-",
"based",
"basic",
"filter",
"algorithm",
"described",
"in",
"RFC4647",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/structs.py#L1228-L1269 |
horazont/aioxmpp | aioxmpp/structs.py | lookup_language | def lookup_language(languages, ranges):
"""
Look up a single language in the sequence `languages` using the lookup
mechansim described in RFC4647. If no match is found, :data:`None` is
returned. Otherwise, the first matching language is returned.
`languages` must be a sequence of :class:`LanguageTa... | python | def lookup_language(languages, ranges):
"""
Look up a single language in the sequence `languages` using the lookup
mechansim described in RFC4647. If no match is found, :data:`None` is
returned. Otherwise, the first matching language is returned.
`languages` must be a sequence of :class:`LanguageTa... | [
"def",
"lookup_language",
"(",
"languages",
",",
"ranges",
")",
":",
"for",
"language_range",
"in",
"ranges",
":",
"while",
"True",
":",
"try",
":",
"return",
"next",
"(",
"iter",
"(",
"basic_filter_languages",
"(",
"languages",
",",
"[",
"language_range",
"... | Look up a single language in the sequence `languages` using the lookup
mechansim described in RFC4647. If no match is found, :data:`None` is
returned. Otherwise, the first matching language is returned.
`languages` must be a sequence of :class:`LanguageTag` objects, while
`ranges` must be an iterable o... | [
"Look",
"up",
"a",
"single",
"language",
"in",
"the",
"sequence",
"languages",
"using",
"the",
"lookup",
"mechansim",
"described",
"in",
"RFC4647",
".",
"If",
"no",
"match",
"is",
"found",
":",
"data",
":",
"None",
"is",
"returned",
".",
"Otherwise",
"the"... | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/structs.py#L1272-L1294 |
horazont/aioxmpp | aioxmpp/structs.py | JID.replace | def replace(self, **kwargs):
"""
Construct a new :class:`JID` object, using the values of the current
JID. Use the arguments to override specific attributes on the new
object.
All arguments are keyword arguments.
:param localpart: Set the local part of the resulting JID... | python | def replace(self, **kwargs):
"""
Construct a new :class:`JID` object, using the values of the current
JID. Use the arguments to override specific attributes on the new
object.
All arguments are keyword arguments.
:param localpart: Set the local part of the resulting JID... | [
"def",
"replace",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"new_kwargs",
"=",
"{",
"}",
"strict",
"=",
"kwargs",
".",
"pop",
"(",
"\"strict\"",
",",
"True",
")",
"try",
":",
"localpart",
"=",
"kwargs",
".",
"pop",
"(",
"\"localpart\"",
")",
... | Construct a new :class:`JID` object, using the values of the current
JID. Use the arguments to override specific attributes on the new
object.
All arguments are keyword arguments.
:param localpart: Set the local part of the resulting JID.
:param domain: Set the domain of the re... | [
"Construct",
"a",
"new",
":",
"class",
":",
"JID",
"object",
"using",
"the",
"values",
"of",
"the",
"current",
"JID",
".",
"Use",
"the",
"arguments",
"to",
"override",
"specific",
"attributes",
"on",
"the",
"new",
"object",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/structs.py#L689-L754 |
horazont/aioxmpp | aioxmpp/structs.py | JID.fromstr | def fromstr(cls, s, *, strict=True):
"""
Construct a JID out of a string containing it.
:param s: The string to parse.
:type s: :class:`str`
:param strict: Whether to enable strict parsing.
:type strict: :class:`bool`
:raises: See :class:`JID`
:return: Th... | python | def fromstr(cls, s, *, strict=True):
"""
Construct a JID out of a string containing it.
:param s: The string to parse.
:type s: :class:`str`
:param strict: Whether to enable strict parsing.
:type strict: :class:`bool`
:raises: See :class:`JID`
:return: Th... | [
"def",
"fromstr",
"(",
"cls",
",",
"s",
",",
"*",
",",
"strict",
"=",
"True",
")",
":",
"nodedomain",
",",
"sep",
",",
"resource",
"=",
"s",
".",
"partition",
"(",
"\"/\"",
")",
"if",
"not",
"sep",
":",
"resource",
"=",
"None",
"localpart",
",",
... | Construct a JID out of a string containing it.
:param s: The string to parse.
:type s: :class:`str`
:param strict: Whether to enable strict parsing.
:type strict: :class:`bool`
:raises: See :class:`JID`
:return: The parsed JID
:rtype: :class:`JID`
See th... | [
"Construct",
"a",
"JID",
"out",
"of",
"a",
"string",
"containing",
"it",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/structs.py#L792-L815 |
horazont/aioxmpp | aioxmpp/structs.py | LanguageRange.strip_rightmost | def strip_rightmost(self):
"""
Strip the rightmost part of the language range. If the new rightmost
part is a singleton or ``x`` (i.e. starts an extension or private use
part), it is also stripped.
Return the newly created :class:`LanguageRange`.
"""
parts = sel... | python | def strip_rightmost(self):
"""
Strip the rightmost part of the language range. If the new rightmost
part is a singleton or ``x`` (i.e. starts an extension or private use
part), it is also stripped.
Return the newly created :class:`LanguageRange`.
"""
parts = sel... | [
"def",
"strip_rightmost",
"(",
"self",
")",
":",
"parts",
"=",
"self",
".",
"print_str",
".",
"split",
"(",
"\"-\"",
")",
"parts",
".",
"pop",
"(",
")",
"if",
"parts",
"and",
"len",
"(",
"parts",
"[",
"-",
"1",
"]",
")",
"==",
"1",
":",
"parts",
... | Strip the rightmost part of the language range. If the new rightmost
part is a singleton or ``x`` (i.e. starts an extension or private use
part), it is also stripped.
Return the newly created :class:`LanguageRange`. | [
"Strip",
"the",
"rightmost",
"part",
"of",
"the",
"language",
"range",
".",
"If",
"the",
"new",
"rightmost",
"part",
"is",
"a",
"singleton",
"or",
"x",
"(",
"i",
".",
"e",
".",
"starts",
"an",
"extension",
"or",
"private",
"use",
"part",
")",
"it",
"... | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/structs.py#L1209-L1222 |
horazont/aioxmpp | aioxmpp/structs.py | LanguageMap.lookup | def lookup(self, language_ranges):
"""
Perform an RFC4647 language range lookup on the keys in the
dictionary. `language_ranges` must be a sequence of
:class:`LanguageRange` instances.
Return the entry in the dictionary with a key as produced by
`lookup_language`. If `lo... | python | def lookup(self, language_ranges):
"""
Perform an RFC4647 language range lookup on the keys in the
dictionary. `language_ranges` must be a sequence of
:class:`LanguageRange` instances.
Return the entry in the dictionary with a key as produced by
`lookup_language`. If `lo... | [
"def",
"lookup",
"(",
"self",
",",
"language_ranges",
")",
":",
"keys",
"=",
"list",
"(",
"self",
".",
"keys",
"(",
")",
")",
"try",
":",
"keys",
".",
"remove",
"(",
"None",
")",
"except",
"ValueError",
":",
"pass",
"keys",
".",
"sort",
"(",
")",
... | Perform an RFC4647 language range lookup on the keys in the
dictionary. `language_ranges` must be a sequence of
:class:`LanguageRange` instances.
Return the entry in the dictionary with a key as produced by
`lookup_language`. If `lookup_language` does not find a match and the
ma... | [
"Perform",
"an",
"RFC4647",
"language",
"range",
"lookup",
"on",
"the",
"keys",
"in",
"the",
"dictionary",
".",
"language_ranges",
"must",
"be",
"a",
"sequence",
"of",
":",
"class",
":",
"LanguageRange",
"instances",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/structs.py#L1310-L1328 |
horazont/aioxmpp | aioxmpp/im/p2p.py | Service.get_conversation | def get_conversation(self, peer_jid, *, current_jid=None):
"""
Get or create a new one-to-one conversation with a peer.
:param peer_jid: The JID of the peer to converse with.
:type peer_jid: :class:`aioxmpp.JID`
:param current_jid: The current JID to lock the conversation to (se... | python | def get_conversation(self, peer_jid, *, current_jid=None):
"""
Get or create a new one-to-one conversation with a peer.
:param peer_jid: The JID of the peer to converse with.
:type peer_jid: :class:`aioxmpp.JID`
:param current_jid: The current JID to lock the conversation to (se... | [
"def",
"get_conversation",
"(",
"self",
",",
"peer_jid",
",",
"*",
",",
"current_jid",
"=",
"None",
")",
":",
"try",
":",
"return",
"self",
".",
"_conversationmap",
"[",
"peer_jid",
"]",
"except",
"KeyError",
":",
"pass",
"return",
"self",
".",
"_make_conv... | Get or create a new one-to-one conversation with a peer.
:param peer_jid: The JID of the peer to converse with.
:type peer_jid: :class:`aioxmpp.JID`
:param current_jid: The current JID to lock the conversation to (see
:rfc:`6121`).
:type current_jid: :class:`... | [
"Get",
"or",
"create",
"a",
"new",
"one",
"-",
"to",
"-",
"one",
"conversation",
"with",
"a",
"peer",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/im/p2p.py#L204-L228 |
horazont/aioxmpp | aioxmpp/network.py | reconfigure_resolver | def reconfigure_resolver():
"""
Reset the resolver configured for this thread to a fresh instance. This
essentially re-reads the system-wide resolver configuration.
If a custom resolver has been set using :func:`set_resolver`, the flag
indicating that no automatic re-configuration shall take place ... | python | def reconfigure_resolver():
"""
Reset the resolver configured for this thread to a fresh instance. This
essentially re-reads the system-wide resolver configuration.
If a custom resolver has been set using :func:`set_resolver`, the flag
indicating that no automatic re-configuration shall take place ... | [
"def",
"reconfigure_resolver",
"(",
")",
":",
"global",
"_state",
"_state",
".",
"resolver",
"=",
"dns",
".",
"resolver",
".",
"Resolver",
"(",
")",
"_state",
".",
"overridden_resolver",
"=",
"False"
] | Reset the resolver configured for this thread to a fresh instance. This
essentially re-reads the system-wide resolver configuration.
If a custom resolver has been set using :func:`set_resolver`, the flag
indicating that no automatic re-configuration shall take place is cleared. | [
"Reset",
"the",
"resolver",
"configured",
"for",
"this",
"thread",
"to",
"a",
"fresh",
"instance",
".",
"This",
"essentially",
"re",
"-",
"reads",
"the",
"system",
"-",
"wide",
"resolver",
"configuration",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/network.py#L116-L127 |
horazont/aioxmpp | aioxmpp/network.py | repeated_query | def repeated_query(qname, rdtype,
nattempts=None,
resolver=None,
require_ad=False,
executor=None):
"""
Repeatedly fire a DNS query until either the number of allowed attempts
(`nattempts`) is excedeed or a non-error result is return... | python | def repeated_query(qname, rdtype,
nattempts=None,
resolver=None,
require_ad=False,
executor=None):
"""
Repeatedly fire a DNS query until either the number of allowed attempts
(`nattempts`) is excedeed or a non-error result is return... | [
"def",
"repeated_query",
"(",
"qname",
",",
"rdtype",
",",
"nattempts",
"=",
"None",
",",
"resolver",
"=",
"None",
",",
"require_ad",
"=",
"False",
",",
"executor",
"=",
"None",
")",
":",
"global",
"_state",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
... | Repeatedly fire a DNS query until either the number of allowed attempts
(`nattempts`) is excedeed or a non-error result is returned (NXDOMAIN is
a non-error result).
If `nattempts` is :data:`None`, it is set to 3 if `resolver` is
:data:`None` and to 2 otherwise. This way, no query is made without a
... | [
"Repeatedly",
"fire",
"a",
"DNS",
"query",
"until",
"either",
"the",
"number",
"of",
"allowed",
"attempts",
"(",
"nattempts",
")",
"is",
"excedeed",
"or",
"a",
"non",
"-",
"error",
"result",
"is",
"returned",
"(",
"NXDOMAIN",
"is",
"a",
"non",
"-",
"erro... | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/network.py#L146-L291 |
horazont/aioxmpp | aioxmpp/network.py | lookup_srv | def lookup_srv(
domain: bytes,
service: str,
transport: str = "tcp",
**kwargs):
"""
Query the DNS for SRV records describing how the given `service` over the
given `transport` is implemented for the given `domain`. `domain` must be
an IDNA-encoded :class:`bytes` object; `... | python | def lookup_srv(
domain: bytes,
service: str,
transport: str = "tcp",
**kwargs):
"""
Query the DNS for SRV records describing how the given `service` over the
given `transport` is implemented for the given `domain`. `domain` must be
an IDNA-encoded :class:`bytes` object; `... | [
"def",
"lookup_srv",
"(",
"domain",
":",
"bytes",
",",
"service",
":",
"str",
",",
"transport",
":",
"str",
"=",
"\"tcp\"",
",",
"*",
"*",
"kwargs",
")",
":",
"record",
"=",
"b\".\"",
".",
"join",
"(",
"[",
"b\"_\"",
"+",
"service",
".",
"encode",
... | Query the DNS for SRV records describing how the given `service` over the
given `transport` is implemented for the given `domain`. `domain` must be
an IDNA-encoded :class:`bytes` object; `service` must be a normal
:class:`str`.
Keyword arguments are passed to :func:`repeated_query`.
Return a list ... | [
"Query",
"the",
"DNS",
"for",
"SRV",
"records",
"describing",
"how",
"the",
"given",
"service",
"over",
"the",
"given",
"transport",
"is",
"implemented",
"for",
"the",
"given",
"domain",
".",
"domain",
"must",
"be",
"an",
"IDNA",
"-",
"encoded",
":",
"clas... | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/network.py#L295-L351 |
horazont/aioxmpp | aioxmpp/network.py | lookup_tlsa | def lookup_tlsa(hostname, port, transport="tcp", require_ad=True, **kwargs):
"""
Query the DNS for TLSA records describing the certificates and/or keys to
expect when contacting `hostname` at the given `port` over the given
`transport`. `hostname` must be an IDNA-encoded :class:`bytes` object.
The ... | python | def lookup_tlsa(hostname, port, transport="tcp", require_ad=True, **kwargs):
"""
Query the DNS for TLSA records describing the certificates and/or keys to
expect when contacting `hostname` at the given `port` over the given
`transport`. `hostname` must be an IDNA-encoded :class:`bytes` object.
The ... | [
"def",
"lookup_tlsa",
"(",
"hostname",
",",
"port",
",",
"transport",
"=",
"\"tcp\"",
",",
"require_ad",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"record",
"=",
"b\".\"",
".",
"join",
"(",
"[",
"b\"_\"",
"+",
"str",
"(",
"port",
")",
".",
"e... | Query the DNS for TLSA records describing the certificates and/or keys to
expect when contacting `hostname` at the given `port` over the given
`transport`. `hostname` must be an IDNA-encoded :class:`bytes` object.
The keyword arguments are passed to :func:`repeated_query`; `require_ad`
defaults to :dat... | [
"Query",
"the",
"DNS",
"for",
"TLSA",
"records",
"describing",
"the",
"certificates",
"and",
"/",
"or",
"keys",
"to",
"expect",
"when",
"contacting",
"hostname",
"at",
"the",
"given",
"port",
"over",
"the",
"given",
"transport",
".",
"hostname",
"must",
"be"... | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/network.py#L355-L389 |
horazont/aioxmpp | aioxmpp/network.py | group_and_order_srv_records | def group_and_order_srv_records(all_records, rng=None):
"""
Order a list of SRV record information (as returned by :func:`lookup_srv`)
and group and order them as specified by the RFC.
Return an iterable, yielding each ``(hostname, port)`` tuple inside the
SRV records in the order specified by the ... | python | def group_and_order_srv_records(all_records, rng=None):
"""
Order a list of SRV record information (as returned by :func:`lookup_srv`)
and group and order them as specified by the RFC.
Return an iterable, yielding each ``(hostname, port)`` tuple inside the
SRV records in the order specified by the ... | [
"def",
"group_and_order_srv_records",
"(",
"all_records",
",",
"rng",
"=",
"None",
")",
":",
"rng",
"=",
"rng",
"or",
"random",
"all_records",
".",
"sort",
"(",
"key",
"=",
"lambda",
"x",
":",
"x",
"[",
":",
"2",
"]",
")",
"for",
"priority",
",",
"re... | Order a list of SRV record information (as returned by :func:`lookup_srv`)
and group and order them as specified by the RFC.
Return an iterable, yielding each ``(hostname, port)`` tuple inside the
SRV records in the order specified by the RFC. For hosts with the same
priority, the given `rng` implement... | [
"Order",
"a",
"list",
"of",
"SRV",
"record",
"information",
"(",
"as",
"returned",
"by",
":",
"func",
":",
"lookup_srv",
")",
"and",
"group",
"and",
"order",
"them",
"as",
"specified",
"by",
"the",
"RFC",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/network.py#L392-L428 |
horazont/aioxmpp | aioxmpp/service.py | add_handler_spec | def add_handler_spec(f, handler_spec, *, kwargs=None):
"""
Attach a handler specification (see :class:`HandlerSpec`) to a function.
:param f: Function to attach the handler specification to.
:param handler_spec: Handler specification to attach to the function.
:type handler_spec: :class:`HandlerSpe... | python | def add_handler_spec(f, handler_spec, *, kwargs=None):
"""
Attach a handler specification (see :class:`HandlerSpec`) to a function.
:param f: Function to attach the handler specification to.
:param handler_spec: Handler specification to attach to the function.
:type handler_spec: :class:`HandlerSpe... | [
"def",
"add_handler_spec",
"(",
"f",
",",
"handler_spec",
",",
"*",
",",
"kwargs",
"=",
"None",
")",
":",
"handler_dict",
"=",
"automake_magic_attr",
"(",
"f",
")",
"if",
"kwargs",
"is",
"None",
":",
"kwargs",
"=",
"{",
"}",
"if",
"kwargs",
"!=",
"hand... | Attach a handler specification (see :class:`HandlerSpec`) to a function.
:param f: Function to attach the handler specification to.
:param handler_spec: Handler specification to attach to the function.
:type handler_spec: :class:`HandlerSpec`
:param kwargs: additional keyword arguments passed to the fu... | [
"Attach",
"a",
"handler",
"specification",
"(",
"see",
":",
"class",
":",
"HandlerSpec",
")",
"to",
"a",
"function",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L880-L910 |
horazont/aioxmpp | aioxmpp/service.py | iq_handler | def iq_handler(type_, payload_cls, *, with_send_reply=False):
"""
Register the decorated function or coroutine function as IQ request
handler.
:param type_: IQ type to listen for
:type type_: :class:`~.IQType`
:param payload_cls: Payload XSO class to listen for
:type payload_cls: :class:`~.... | python | def iq_handler(type_, payload_cls, *, with_send_reply=False):
"""
Register the decorated function or coroutine function as IQ request
handler.
:param type_: IQ type to listen for
:type type_: :class:`~.IQType`
:param payload_cls: Payload XSO class to listen for
:type payload_cls: :class:`~.... | [
"def",
"iq_handler",
"(",
"type_",
",",
"payload_cls",
",",
"*",
",",
"with_send_reply",
"=",
"False",
")",
":",
"if",
"(",
"not",
"hasattr",
"(",
"payload_cls",
",",
"\"TAG\"",
")",
"or",
"(",
"aioxmpp",
".",
"IQ",
".",
"CHILD_MAP",
".",
"get",
"(",
... | Register the decorated function or coroutine function as IQ request
handler.
:param type_: IQ type to listen for
:type type_: :class:`~.IQType`
:param payload_cls: Payload XSO class to listen for
:type payload_cls: :class:`~.XSO` subclass
:param with_send_reply: Whether to pass a function to se... | [
"Register",
"the",
"decorated",
"function",
"or",
"coroutine",
"function",
"as",
"IQ",
"request",
"handler",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L1001-L1060 |
horazont/aioxmpp | aioxmpp/service.py | message_handler | def message_handler(type_, from_):
"""
Deprecated alias of :func:`.dispatcher.message_handler`.
.. deprecated:: 0.9
"""
import aioxmpp.dispatcher
return aioxmpp.dispatcher.message_handler(type_, from_) | python | def message_handler(type_, from_):
"""
Deprecated alias of :func:`.dispatcher.message_handler`.
.. deprecated:: 0.9
"""
import aioxmpp.dispatcher
return aioxmpp.dispatcher.message_handler(type_, from_) | [
"def",
"message_handler",
"(",
"type_",
",",
"from_",
")",
":",
"import",
"aioxmpp",
".",
"dispatcher",
"return",
"aioxmpp",
".",
"dispatcher",
".",
"message_handler",
"(",
"type_",
",",
"from_",
")"
] | Deprecated alias of :func:`.dispatcher.message_handler`.
.. deprecated:: 0.9 | [
"Deprecated",
"alias",
"of",
":",
"func",
":",
".",
"dispatcher",
".",
"message_handler",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L1063-L1070 |
horazont/aioxmpp | aioxmpp/service.py | presence_handler | def presence_handler(type_, from_):
"""
Deprecated alias of :func:`.dispatcher.presence_handler`.
.. deprecated:: 0.9
"""
import aioxmpp.dispatcher
return aioxmpp.dispatcher.presence_handler(type_, from_) | python | def presence_handler(type_, from_):
"""
Deprecated alias of :func:`.dispatcher.presence_handler`.
.. deprecated:: 0.9
"""
import aioxmpp.dispatcher
return aioxmpp.dispatcher.presence_handler(type_, from_) | [
"def",
"presence_handler",
"(",
"type_",
",",
"from_",
")",
":",
"import",
"aioxmpp",
".",
"dispatcher",
"return",
"aioxmpp",
".",
"dispatcher",
".",
"presence_handler",
"(",
"type_",
",",
"from_",
")"
] | Deprecated alias of :func:`.dispatcher.presence_handler`.
.. deprecated:: 0.9 | [
"Deprecated",
"alias",
"of",
":",
"func",
":",
".",
"dispatcher",
".",
"presence_handler",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L1073-L1080 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.