id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
51
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
600
locationlabs/mockredis
mockredis/client.py
MockRedis._hincrby
def _hincrby(self, hashkey, attribute, command, type_, increment): """Shared hincrby and hincrbyfloat routine""" redis_hash = self._get_hash(hashkey, command, create=True) attribute = self._encode(attribute) previous_value = type_(redis_hash.get(attribute, '0')) redis_hash[attrib...
python
def _hincrby(self, hashkey, attribute, command, type_, increment): redis_hash = self._get_hash(hashkey, command, create=True) attribute = self._encode(attribute) previous_value = type_(redis_hash.get(attribute, '0')) redis_hash[attribute] = self._encode(previous_value + increment) ...
[ "def", "_hincrby", "(", "self", ",", "hashkey", ",", "attribute", ",", "command", ",", "type_", ",", "increment", ")", ":", "redis_hash", "=", "self", ".", "_get_hash", "(", "hashkey", ",", "command", ",", "create", "=", "True", ")", "attribute", "=", ...
Shared hincrby and hincrbyfloat routine
[ "Shared", "hincrby", "and", "hincrbyfloat", "routine" ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L589-L595
601
locationlabs/mockredis
mockredis/client.py
MockRedis.lrange
def lrange(self, key, start, stop): """Emulate lrange.""" redis_list = self._get_list(key, 'LRANGE') start, stop = self._translate_range(len(redis_list), start, stop) return redis_list[start:stop + 1]
python
def lrange(self, key, start, stop): redis_list = self._get_list(key, 'LRANGE') start, stop = self._translate_range(len(redis_list), start, stop) return redis_list[start:stop + 1]
[ "def", "lrange", "(", "self", ",", "key", ",", "start", ",", "stop", ")", ":", "redis_list", "=", "self", ".", "_get_list", "(", "key", ",", "'LRANGE'", ")", "start", ",", "stop", "=", "self", ".", "_translate_range", "(", "len", "(", "redis_list", "...
Emulate lrange.
[ "Emulate", "lrange", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L611-L615
602
locationlabs/mockredis
mockredis/client.py
MockRedis.lindex
def lindex(self, key, index): """Emulate lindex.""" redis_list = self._get_list(key, 'LINDEX') if self._encode(key) not in self.redis: return None try: return redis_list[index] except (IndexError): # Redis returns nil if the index doesn't ex...
python
def lindex(self, key, index): redis_list = self._get_list(key, 'LINDEX') if self._encode(key) not in self.redis: return None try: return redis_list[index] except (IndexError): # Redis returns nil if the index doesn't exist return None
[ "def", "lindex", "(", "self", ",", "key", ",", "index", ")", ":", "redis_list", "=", "self", ".", "_get_list", "(", "key", ",", "'LINDEX'", ")", "if", "self", ".", "_encode", "(", "key", ")", "not", "in", "self", ".", "redis", ":", "return", "None"...
Emulate lindex.
[ "Emulate", "lindex", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L617-L629
603
locationlabs/mockredis
mockredis/client.py
MockRedis._blocking_pop
def _blocking_pop(self, pop_func, keys, timeout): """Emulate blocking pop functionality""" if not isinstance(timeout, (int, long)): raise RuntimeError('timeout is not an integer or out of range') if timeout is None or timeout == 0: timeout = self.blocking_timeout ...
python
def _blocking_pop(self, pop_func, keys, timeout): if not isinstance(timeout, (int, long)): raise RuntimeError('timeout is not an integer or out of range') if timeout is None or timeout == 0: timeout = self.blocking_timeout if isinstance(keys, basestring): ke...
[ "def", "_blocking_pop", "(", "self", ",", "pop_func", ",", "keys", ",", "timeout", ")", ":", "if", "not", "isinstance", "(", "timeout", ",", "(", "int", ",", "long", ")", ")", ":", "raise", "RuntimeError", "(", "'timeout is not an integer or out of range'", ...
Emulate blocking pop functionality
[ "Emulate", "blocking", "pop", "functionality" ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L638-L660
604
locationlabs/mockredis
mockredis/client.py
MockRedis.lpush
def lpush(self, key, *args): """Emulate lpush.""" redis_list = self._get_list(key, 'LPUSH', create=True) # Creates the list at this key if it doesn't exist, and appends args to its beginning args_reversed = [self._encode(arg) for arg in args] args_reversed.reverse() upda...
python
def lpush(self, key, *args): redis_list = self._get_list(key, 'LPUSH', create=True) # Creates the list at this key if it doesn't exist, and appends args to its beginning args_reversed = [self._encode(arg) for arg in args] args_reversed.reverse() updated_list = args_reversed + re...
[ "def", "lpush", "(", "self", ",", "key", ",", "*", "args", ")", ":", "redis_list", "=", "self", ".", "_get_list", "(", "key", ",", "'LPUSH'", ",", "create", "=", "True", ")", "# Creates the list at this key if it doesn't exist, and appends args to its beginning", ...
Emulate lpush.
[ "Emulate", "lpush", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L693-L704
605
locationlabs/mockredis
mockredis/client.py
MockRedis.rpop
def rpop(self, key): """Emulate lpop.""" redis_list = self._get_list(key, 'RPOP') if self._encode(key) not in self.redis: return None try: value = redis_list.pop() if len(redis_list) == 0: self.delete(key) return value ...
python
def rpop(self, key): redis_list = self._get_list(key, 'RPOP') if self._encode(key) not in self.redis: return None try: value = redis_list.pop() if len(redis_list) == 0: self.delete(key) return value except (IndexError): ...
[ "def", "rpop", "(", "self", ",", "key", ")", ":", "redis_list", "=", "self", ".", "_get_list", "(", "key", ",", "'RPOP'", ")", "if", "self", ".", "_encode", "(", "key", ")", "not", "in", "self", ".", "redis", ":", "return", "None", "try", ":", "v...
Emulate lpop.
[ "Emulate", "lpop", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L706-L720
606
locationlabs/mockredis
mockredis/client.py
MockRedis.rpush
def rpush(self, key, *args): """Emulate rpush.""" redis_list = self._get_list(key, 'RPUSH', create=True) # Creates the list at this key if it doesn't exist, and appends args to it redis_list.extend(map(self._encode, args)) # Return the length of the list after the push operatio...
python
def rpush(self, key, *args): redis_list = self._get_list(key, 'RPUSH', create=True) # Creates the list at this key if it doesn't exist, and appends args to it redis_list.extend(map(self._encode, args)) # Return the length of the list after the push operation return len(redis_li...
[ "def", "rpush", "(", "self", ",", "key", ",", "*", "args", ")", ":", "redis_list", "=", "self", ".", "_get_list", "(", "key", ",", "'RPUSH'", ",", "create", "=", "True", ")", "# Creates the list at this key if it doesn't exist, and appends args to it", "redis_list...
Emulate rpush.
[ "Emulate", "rpush", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L722-L730
607
locationlabs/mockredis
mockredis/client.py
MockRedis.lrem
def lrem(self, key, value, count=0): """Emulate lrem.""" value = self._encode(value) redis_list = self._get_list(key, 'LREM') removed_count = 0 if self._encode(key) in self.redis: if count == 0: # Remove all ocurrences while redis_list....
python
def lrem(self, key, value, count=0): value = self._encode(value) redis_list = self._get_list(key, 'LREM') removed_count = 0 if self._encode(key) in self.redis: if count == 0: # Remove all ocurrences while redis_list.count(value): ...
[ "def", "lrem", "(", "self", ",", "key", ",", "value", ",", "count", "=", "0", ")", ":", "value", "=", "self", ".", "_encode", "(", "value", ")", "redis_list", "=", "self", ".", "_get_list", "(", "key", ",", "'LREM'", ")", "removed_count", "=", "0",...
Emulate lrem.
[ "Emulate", "lrem", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L732-L765
608
locationlabs/mockredis
mockredis/client.py
MockRedis.ltrim
def ltrim(self, key, start, stop): """Emulate ltrim.""" redis_list = self._get_list(key, 'LTRIM') if redis_list: start, stop = self._translate_range(len(redis_list), start, stop) self.redis[self._encode(key)] = redis_list[start:stop + 1] return True
python
def ltrim(self, key, start, stop): redis_list = self._get_list(key, 'LTRIM') if redis_list: start, stop = self._translate_range(len(redis_list), start, stop) self.redis[self._encode(key)] = redis_list[start:stop + 1] return True
[ "def", "ltrim", "(", "self", ",", "key", ",", "start", ",", "stop", ")", ":", "redis_list", "=", "self", ".", "_get_list", "(", "key", ",", "'LTRIM'", ")", "if", "redis_list", ":", "start", ",", "stop", "=", "self", ".", "_translate_range", "(", "len...
Emulate ltrim.
[ "Emulate", "ltrim", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L767-L773
609
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): 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 out of range")
[ "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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L792-L800
610
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): if count is None: count = 10 cursor = int(cursor) count = int(count) if not count: raise ValueError('if specified, count must be > 0: %s' % count) values = values_functio...
[ "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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L882-L910
611
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): 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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L912-L916
612
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): 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=match, count=count)
[ "def", "sscan", "(", "self", ",", "name", ",", "cursor", "=", "'0'", ",", "match", "=", "None", ",", "count", "=", "10", ")", ":", "def", "value_function", "(", ")", ":", "members", "=", "list", "(", "self", ".", "smembers", "(", "name", ")", ")"...
Emulate sscan.
[ "Emulate", "sscan", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L926-L932
613
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): 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_function, cursor=cursor, match=m...
[ "def", "zscan", "(", "self", ",", "name", ",", "cursor", "=", "'0'", ",", "match", "=", "None", ",", "count", "=", "10", ")", ":", "def", "value_function", "(", ")", ":", "values", "=", "self", ".", "zrange", "(", "name", ",", "0", ",", "-", "1...
Emulate zscan.
[ "Emulate", "zscan", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L943-L949
614
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): 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 return values s...
[ "def", "hscan", "(", "self", ",", "name", ",", "cursor", "=", "'0'", ",", "match", "=", "None", ",", "count", "=", "10", ")", ":", "def", "value_function", "(", ")", ":", "values", "=", "self", ".", "hgetall", "(", "name", ")", "values", "=", "li...
Emulate hscan.
[ "Emulate", "hscan", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L960-L969
615
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): 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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L971-L978
616
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): 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)) after_count = len(redis...
[ "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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L982-L990
617
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): 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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L997-L1000
618
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): 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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1002-L1006
619
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): 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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1008-L1011
620
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): 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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1013-L1017
621
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): 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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1019-L1026
622
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): 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) self.redis[self._encode(src)], s...
[ "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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1032-L1044
623
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): 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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1046-L1055
624
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): 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: return sample(list(redis_set), min(numbe...
[ "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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1057-L1067
625
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): 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 before_count > 0 and len(redis...
[ "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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1069-L1080
626
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): 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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1082-L1085
627
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): 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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1087-L1091
628
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): command = self._normalize_command_name(command) args = self._normalize_command_args(command, *args) redis_function = getattr(self, command) value = redis_function(*args) return self._normalize_command_response(command, value)
[ "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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1344-L1356
629
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): if command == 'zadd' and not self.strict and len(args) >= 3: # Reorder score and name zadd_args = [x for tup in zip(args[2::2], args[1::2]) for x in tup] return [args[0]] + zadd_args if command in ('zrangebyscore', '...
[ "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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1369-L1404
630
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='*'): result = {} for name, value in self.redis_config.items(): if fnmatch.fnmatch(name, pattern): try: result[name] = int(value) except ValueError: result[name] = value return result
[ "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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1421-L1432
631
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): 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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1478-L1488
632
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): 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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1490-L1496
633
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): funcs = {"sum": add, "min": min, "max": max} func_name = aggregate.lower() if aggregate else 'sum' try: return funcs[func_name] except KeyError: raise TypeError("Unsupported aggregate: {}".format(aggregate))
[ "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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1507-L1516
634
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): 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) or set() for key in keys[1:]: right = s...
[ "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" ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1518-L1527
635
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): # 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, basestring): keys = [keys] except Type...
[ "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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1529-L1544
636
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" ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1551-L1563
637
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): if self.explicit_transaction: raise RedisError("Cannot issue a WATCH after a MULTI") self.watching = True for key in keys: self._watched_keys[key] = deepcopy(self.mock_redis.redis.get(self.mock_redis._encode(key)))
[ "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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/pipeline.py#L33-L42
638
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): 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 changed.") return [command() for command in self.commands] finally: ...
[ "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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/pipeline.py#L55-L65
639
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): 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", "." ]
fd4e3117066ff0c24e86ebca007853a8092e3254
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/pipeline.py#L67-L74
640
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): 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 Codes (e.g. "en") return lang + "$core" else: raise ValueErro...
[ "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", "." ]
e6a34192e35fd4fc287b4bc93c938fcd5c2d9024
https://github.com/FraBle/python-duckling/blob/e6a34192e35fd4fc287b4bc93c938fcd5c2d9024/duckling/language.py#L51-L60
641
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=[]): duckling_load = self.clojure.var("duckling.core", "load!") clojure_hashmap = self.clojure.var("clojure.core", "hash-map") clojure_list = self.clojure.var("clojure.core", "list") if languages: # Duckling's load function expects ISO 639-1 Language...
[ "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", "." ]
e6a34192e35fd4fc287b4bc93c938fcd5c2d9024
https://github.com/FraBle/python-duckling/blob/e6a34192e35fd4fc287b4bc93c938fcd5c2d9024/duckling/duckling.py#L81-L107
642
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=''): return self._parse(input_str, dim=Dim.TIME, reference_time=reference_time)
[ "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", "." ]
e6a34192e35fd4fc287b4bc93c938fcd5c2d9024
https://github.com/FraBle/python-duckling/blob/e6a34192e35fd4fc287b4bc93c938fcd5c2d9024/duckling/wrapper.py#L258-L287
643
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): disco = self.dependencies[aioxmpp.disco.DiscoClient] response = yield from disco.query_items( peer_jid, node=namespaces.xep0050_commands, ) return response.items
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/adhoc/service.py#L72-L92
644
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): disco = self.dependencies[aioxmpp.disco.DiscoClient] response = yield from disco.query_info( peer_jid, node=command_name, ) return response
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/adhoc/service.py#L95-L122
645
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): session = ClientSession( self.client.stream, peer_jid, command_name, ) yield from session.start() return session
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/adhoc/service.py#L147-L171
646
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}): info = CommandEntry( name, handler, is_allowed=is_allowed, features=features, ...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/adhoc/service.py#L299-L349
647
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): if self._response is not None: raise RuntimeError("command execution already started") request = aioxmpp.IQ( type_=aioxmpp.IQType.SET, to=self._peer_jid, payload=adhoc_xso.Command(self._command_name), ) self._response = y...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/adhoc/service.py#L480-L506
648
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): if self._response is None: raise RuntimeError("command execution not started yet") if action not in self.allowed_actions: raise ValueError("action {} not allowed in this stag...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/adhoc/service.py#L509-L572
649
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): if self.is_closing(): return self._write_buffer += data if len(self._write_buffer) >= self._output_buffer_limit_high: self._protocol.pause_writing() if self._write_buffer: self._can_write.set()
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/ibb/service.py#L232-L250
650
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): 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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/ibb/service.py#L265-L274
651
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): if block_size > MAX_BLOCK_SIZE: raise ValueError("block_size too large") if sid is None: sid = utils.to_nmtoken(rando...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/ibb/service.py#L419-L471
652
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): return { aioxmpp.im.conversation.ConversationFeature.BAN, aioxmpp.im.conversation.ConversationFeature.BAN_WITH_KICK, aioxmpp.im.conversation.ConversationFeature.KICK, aioxmpp.im.conversation.ConversationFeature.SEND_MESSAGE, aioxmpp...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1018-L1035
653
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): msg.type_ = aioxmpp.MessageType.GROUPCHAT msg.to = self._mucjid # see https://mail.jabber.org/pipermail/standards/2017-January/032048.html # NOQA # for a full discussion on the rationale for this. # TL;DR: we want to help entities to discover that a ...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1470-L1498
654
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): msg.type_ = aioxmpp.MessageType.GROUPCHAT msg.to = self._mucjid # see https://mail.jabber.org/pipermail/standards/2017-January/032048.html # NOQA # for a full discussion on the rationale for this. # TL;DR: we want to help entities to discover...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1508-L1610
655
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): stanza = aioxmpp.Presence( type_=aioxmpp.PresenceType.AVAILABLE, to=self._mucjid.replace(resource=new_nick), ) yield from self._service.client.send( stanza )
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1613-L1638
656
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): yield from self.muc_set_role( member.nick, "none", reason=reason )
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1641-L1662
657
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): if nick is None: raise ValueError("nick must not be None") if role is None: raise ValueError("role must not be None") iq = aioxmpp.stanza.IQ( type_=aioxmpp.structs.IQType.SET, to=self._mucjid ...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1665-L1708
658
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): if member.direct_jid is None: raise ValueError( "cannot ban members whose direct JID is not " "known") yield from self.muc_set_affiliation( member.direct_jid, "outcast", ...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1711-L1741
659
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): 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.PresenceType.UNAVAILABLE, to=self._mucjid ...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L1777-L1795
660
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): if mucjid is None or not mucjid.is_bare: raise ValueError("mucjid must be bare JID") if jid is None: raise ValueError("jid must not be None") if affiliation is None: raise ValueError("affil...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L2382-L2435
661
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): if mucjid is None or not mucjid.is_bare: raise ValueError("mucjid must be bare JID") iq = aioxmpp.stanza.IQ( type_=aioxmpp.structs.IQType.GET, to=mucjid, payload=muc_xso.OwnerQuery(), ) return (yield fro...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/muc/service.py#L2438-L2464
662
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): payload = Request(filename, size, content_type) return (yield from client.send(IQ( type_=IQType.GET, to=service, payload=payload ))...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/httpupload/__init__.py#L76-L109
663
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: return (yield from stream.send( aioxmpp.IQ( type_=aioxmpp.IQType.GET, to=target, payload=version_xso.Query(), ) ))
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/version/service.py#L185-L212
664
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): if not issubclass(xso_class, Bookmark): raise TypeError( "Classes registered as bookmark types must be Bookmark subclasses" ) Storage.register_child( Storage.bookmarks, xso_class ) return xso_class
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/bookmarks/xso.py#L241-L262
665
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): if LanguageRange.WILDCARD in ranges: yield from languages return found = set() for language_range in ranges: range_str = language_range.match_str for language in languages: if language in found: cont...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/structs.py#L1228-L1269
666
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): nodedomain, sep, resource = s.partition("/") if not sep: resource = None localpart, sep, domain = nodedomain.partition("@") if not sep: domain = localpart localpart = None return cls(localpart, domain, reso...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/structs.py#L792-L815
667
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): try: return self._conversationmap[peer_jid] except KeyError: pass return self._make_conversation(peer_jid, False)
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/im/p2p.py#L204-L228
668
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(): global _state _state.resolver = dns.resolver.Resolver() _state.overridden_resolver = False
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/network.py#L116-L127
669
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): if (not hasattr(payload_cls, "TAG") or (aioxmpp.IQ.CHILD_MAP.get(payload_cls.TAG) is not aioxmpp.IQ.payload.xq_descriptor) or payload_cls not in aioxmpp.IQ.payload._classes): raise ValueError( "{!r...
[ "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", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L1001-L1060
670
horazont/aioxmpp
aioxmpp/service.py
inbound_message_filter
def inbound_message_filter(f): """ Register the decorated function as a service-level inbound message filter. :raise TypeError: if the decorated object is a coroutine function .. seealso:: :class:`StanzaStream` for important remarks regarding the use of stanza filters. """ ...
python
def inbound_message_filter(f): if asyncio.iscoroutinefunction(f): raise TypeError( "inbound_message_filter must not be a coroutine function" ) add_handler_spec( f, HandlerSpec( (_apply_inbound_message_filter, ()) ), ) return f
[ "def", "inbound_message_filter", "(", "f", ")", ":", "if", "asyncio", ".", "iscoroutinefunction", "(", "f", ")", ":", "raise", "TypeError", "(", "\"inbound_message_filter must not be a coroutine function\"", ")", "add_handler_spec", "(", "f", ",", "HandlerSpec", "(", ...
Register the decorated function as a service-level inbound message filter. :raise TypeError: if the decorated object is a coroutine function .. seealso:: :class:`StanzaStream` for important remarks regarding the use of stanza filters.
[ "Register", "the", "decorated", "function", "as", "a", "service", "-", "level", "inbound", "message", "filter", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L1083-L1107
671
horazont/aioxmpp
aioxmpp/service.py
inbound_presence_filter
def inbound_presence_filter(f): """ Register the decorated function as a service-level inbound presence filter. :raise TypeError: if the decorated object is a coroutine function .. seealso:: :class:`StanzaStream` for important remarks regarding the use of stanza filters. """ ...
python
def inbound_presence_filter(f): if asyncio.iscoroutinefunction(f): raise TypeError( "inbound_presence_filter must not be a coroutine function" ) add_handler_spec( f, HandlerSpec( (_apply_inbound_presence_filter, ()) ), ) return f
[ "def", "inbound_presence_filter", "(", "f", ")", ":", "if", "asyncio", ".", "iscoroutinefunction", "(", "f", ")", ":", "raise", "TypeError", "(", "\"inbound_presence_filter must not be a coroutine function\"", ")", "add_handler_spec", "(", "f", ",", "HandlerSpec", "("...
Register the decorated function as a service-level inbound presence filter. :raise TypeError: if the decorated object is a coroutine function .. seealso:: :class:`StanzaStream` for important remarks regarding the use of stanza filters.
[ "Register", "the", "decorated", "function", "as", "a", "service", "-", "level", "inbound", "presence", "filter", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L1110-L1134
672
horazont/aioxmpp
aioxmpp/service.py
outbound_message_filter
def outbound_message_filter(f): """ Register the decorated function as a service-level outbound message filter. :raise TypeError: if the decorated object is a coroutine function .. seealso:: :class:`StanzaStream` for important remarks regarding the use of stanza filters. """ ...
python
def outbound_message_filter(f): if asyncio.iscoroutinefunction(f): raise TypeError( "outbound_message_filter must not be a coroutine function" ) add_handler_spec( f, HandlerSpec( (_apply_outbound_message_filter, ()) ), ) return f
[ "def", "outbound_message_filter", "(", "f", ")", ":", "if", "asyncio", ".", "iscoroutinefunction", "(", "f", ")", ":", "raise", "TypeError", "(", "\"outbound_message_filter must not be a coroutine function\"", ")", "add_handler_spec", "(", "f", ",", "HandlerSpec", "("...
Register the decorated function as a service-level outbound message filter. :raise TypeError: if the decorated object is a coroutine function .. seealso:: :class:`StanzaStream` for important remarks regarding the use of stanza filters.
[ "Register", "the", "decorated", "function", "as", "a", "service", "-", "level", "outbound", "message", "filter", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L1137-L1161
673
horazont/aioxmpp
aioxmpp/service.py
outbound_presence_filter
def outbound_presence_filter(f): """ Register the decorated function as a service-level outbound presence filter. :raise TypeError: if the decorated object is a coroutine function .. seealso:: :class:`StanzaStream` for important remarks regarding the use of stanza filters. "...
python
def outbound_presence_filter(f): if asyncio.iscoroutinefunction(f): raise TypeError( "outbound_presence_filter must not be a coroutine function" ) add_handler_spec( f, HandlerSpec( (_apply_outbound_presence_filter, ()) ), ) return f
[ "def", "outbound_presence_filter", "(", "f", ")", ":", "if", "asyncio", ".", "iscoroutinefunction", "(", "f", ")", ":", "raise", "TypeError", "(", "\"outbound_presence_filter must not be a coroutine function\"", ")", "add_handler_spec", "(", "f", ",", "HandlerSpec", "...
Register the decorated function as a service-level outbound presence filter. :raise TypeError: if the decorated object is a coroutine function .. seealso:: :class:`StanzaStream` for important remarks regarding the use of stanza filters.
[ "Register", "the", "decorated", "function", "as", "a", "service", "-", "level", "outbound", "presence", "filter", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L1164-L1189
674
horazont/aioxmpp
aioxmpp/service.py
depsignal
def depsignal(class_, signal_name, *, defer=False): """ Connect the decorated method or coroutine method to the addressed signal on a class on which the service depends. :param class_: A service class which is listed in the :attr:`~.Meta.ORDER_AFTER` relationship. :type class_: :...
python
def depsignal(class_, signal_name, *, defer=False): def decorator(f): add_handler_spec( f, _depsignal_spec(class_, signal_name, f, defer) ) return f return decorator
[ "def", "depsignal", "(", "class_", ",", "signal_name", ",", "*", ",", "defer", "=", "False", ")", ":", "def", "decorator", "(", "f", ")", ":", "add_handler_spec", "(", "f", ",", "_depsignal_spec", "(", "class_", ",", "signal_name", ",", "f", ",", "defe...
Connect the decorated method or coroutine method to the addressed signal on a class on which the service depends. :param class_: A service class which is listed in the :attr:`~.Meta.ORDER_AFTER` relationship. :type class_: :class:`Service` class or one of the special cases below :par...
[ "Connect", "the", "decorated", "method", "or", "coroutine", "method", "to", "the", "addressed", "signal", "on", "a", "class", "on", "which", "the", "service", "depends", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L1244-L1293
675
horazont/aioxmpp
aioxmpp/service.py
attrsignal
def attrsignal(descriptor, signal_name, *, defer=False): """ Connect the decorated method or coroutine method to the addressed signal on a descriptor. :param descriptor: The descriptor to connect to. :type descriptor: :class:`Descriptor` subclass. :param signal_name: Attribute name of the signa...
python
def attrsignal(descriptor, signal_name, *, defer=False): def decorator(f): add_handler_spec( f, _attrsignal_spec(descriptor, signal_name, f, defer) ) return f return decorator
[ "def", "attrsignal", "(", "descriptor", ",", "signal_name", ",", "*", ",", "defer", "=", "False", ")", ":", "def", "decorator", "(", "f", ")", ":", "add_handler_spec", "(", "f", ",", "_attrsignal_spec", "(", "descriptor", ",", "signal_name", ",", "f", ",...
Connect the decorated method or coroutine method to the addressed signal on a descriptor. :param descriptor: The descriptor to connect to. :type descriptor: :class:`Descriptor` subclass. :param signal_name: Attribute name of the signal to connect to :type signal_name: :class:`str` :param defer:...
[ "Connect", "the", "decorated", "method", "or", "coroutine", "method", "to", "the", "addressed", "signal", "on", "a", "descriptor", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L1314-L1355
676
horazont/aioxmpp
aioxmpp/service.py
Descriptor.add_to_stack
def add_to_stack(self, instance, stack): """ Get the context manager for the service `instance` and push it to the context manager `stack`. :param instance: The service to get the context manager for. :type instance: :class:`Service` :param stack: The context manager sta...
python
def add_to_stack(self, instance, stack): cm = self.init_cm(instance) obj = stack.enter_context(cm) self._data[instance] = cm, obj return obj
[ "def", "add_to_stack", "(", "self", ",", "instance", ",", "stack", ")", ":", "cm", "=", "self", ".", "init_cm", "(", "instance", ")", "obj", "=", "stack", ".", "enter_context", "(", "cm", ")", "self", ".", "_data", "[", "instance", "]", "=", "cm", ...
Get the context manager for the service `instance` and push it to the context manager `stack`. :param instance: The service to get the context manager for. :type instance: :class:`Service` :param stack: The context manager stack to push the CM onto. :type stack: :class:`contextl...
[ "Get", "the", "context", "manager", "for", "the", "service", "instance", "and", "push", "it", "to", "the", "context", "manager", "stack", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L284-L306
677
horazont/aioxmpp
aioxmpp/service.py
Meta.orders_after
def orders_after(self, other, *, visited=None): """ Return whether `self` depends on `other` and will be instanciated later. :param other: Another service. :type other: :class:`aioxmpp.service.Service` .. versionadded:: 0.11 """ return self.orders_after_...
python
def orders_after(self, other, *, visited=None): return self.orders_after_any(frozenset([other]), visited=visited)
[ "def", "orders_after", "(", "self", ",", "other", ",", "*", ",", "visited", "=", "None", ")", ":", "return", "self", ".", "orders_after_any", "(", "frozenset", "(", "[", "other", "]", ")", ",", "visited", "=", "visited", ")" ]
Return whether `self` depends on `other` and will be instanciated later. :param other: Another service. :type other: :class:`aioxmpp.service.Service` .. versionadded:: 0.11
[ "Return", "whether", "self", "depends", "on", "other", "and", "will", "be", "instanciated", "later", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L595-L605
678
horazont/aioxmpp
aioxmpp/service.py
Meta.orders_after_any
def orders_after_any(self, other, *, visited=None): """ Return whether `self` orders after any of the services in the set `other`. :param other: Another service. :type other: A :class:`set` of :class:`aioxmpp.service.Service` instances .. versionadded:: 0.11 ...
python
def orders_after_any(self, other, *, visited=None): if not other: return False if visited is None: visited = set() elif self in visited: return False visited.add(self) for item in self.PATCHED_ORDER_AFTER: if item in visited: ...
[ "def", "orders_after_any", "(", "self", ",", "other", ",", "*", ",", "visited", "=", "None", ")", ":", "if", "not", "other", ":", "return", "False", "if", "visited", "is", "None", ":", "visited", "=", "set", "(", ")", "elif", "self", "in", "visited",...
Return whether `self` orders after any of the services in the set `other`. :param other: Another service. :type other: A :class:`set` of :class:`aioxmpp.service.Service` instances .. versionadded:: 0.11
[ "Return", "whether", "self", "orders", "after", "any", "of", "the", "services", "in", "the", "set", "other", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/service.py#L607-L632
679
horazont/aioxmpp
aioxmpp/tasks.py
TaskPool.set_limit
def set_limit(self, group, new_limit): """ Set a new limit on the number of tasks in the `group`. :param group: Group key of the group to modify. :type group: hashable :param new_limit: New limit for the number of tasks running in `group`. :type new_limit: non-negative :...
python
def set_limit(self, group, new_limit): if new_limit is None: self._group_limits.pop(group, None) return self._group_limits[group] = new_limit
[ "def", "set_limit", "(", "self", ",", "group", ",", "new_limit", ")", ":", "if", "new_limit", "is", "None", ":", "self", ".", "_group_limits", ".", "pop", "(", "group", ",", "None", ")", "return", "self", ".", "_group_limits", "[", "group", "]", "=", ...
Set a new limit on the number of tasks in the `group`. :param group: Group key of the group to modify. :type group: hashable :param new_limit: New limit for the number of tasks running in `group`. :type new_limit: non-negative :class:`int` or :data:`None` :raise ValueError: if `...
[ "Set", "a", "new", "limit", "on", "the", "number", "of", "tasks", "in", "the", "group", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/tasks.py#L80-L107
680
horazont/aioxmpp
aioxmpp/tasks.py
TaskPool.spawn
def spawn(self, __groups, __coro_fun, *args, **kwargs): """ Start a new coroutine and add it to the pool atomically. :param groups: The groups the coroutine belongs to. :type groups: :class:`set` of group keys :param coro_fun: Coroutine function to run :param args: Posit...
python
def spawn(self, __groups, __coro_fun, *args, **kwargs): # ensure the implicit group is included __groups = set(__groups) | {()} return asyncio.ensure_future(__coro_fun(*args, **kwargs))
[ "def", "spawn", "(", "self", ",", "__groups", ",", "__coro_fun", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# ensure the implicit group is included", "__groups", "=", "set", "(", "__groups", ")", "|", "{", "(", ")", "}", "return", "asyncio", "...
Start a new coroutine and add it to the pool atomically. :param groups: The groups the coroutine belongs to. :type groups: :class:`set` of group keys :param coro_fun: Coroutine function to run :param args: Positional arguments to pass to `coro_fun` :param kwargs: Keyword argumen...
[ "Start", "a", "new", "coroutine", "and", "add", "it", "to", "the", "pool", "atomically", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/tasks.py#L165-L200
681
horazont/aioxmpp
aioxmpp/carbons/service.py
CarbonsClient.enable
def enable(self): """ Enable message carbons. :raises RuntimeError: if the server does not support message carbons. :raises aioxmpp.XMPPError: if the server responded with an error to the request. :raises: as specified in :meth:`aioxmpp.Client....
python
def enable(self): yield from self._check_for_feature() iq = aioxmpp.IQ( type_=aioxmpp.IQType.SET, payload=carbons_xso.Enable() ) yield from self.client.send(iq)
[ "def", "enable", "(", "self", ")", ":", "yield", "from", "self", ".", "_check_for_feature", "(", ")", "iq", "=", "aioxmpp", ".", "IQ", "(", "type_", "=", "aioxmpp", ".", "IQType", ".", "SET", ",", "payload", "=", "carbons_xso", ".", "Enable", "(", ")...
Enable message carbons. :raises RuntimeError: if the server does not support message carbons. :raises aioxmpp.XMPPError: if the server responded with an error to the request. :raises: as specified in :meth:`aioxmpp.Client.send`
[ "Enable", "message", "carbons", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/carbons/service.py#L74-L90
682
horazont/aioxmpp
aioxmpp/carbons/service.py
CarbonsClient.disable
def disable(self): """ Disable message carbons. :raises RuntimeError: if the server does not support message carbons. :raises aioxmpp.XMPPError: if the server responded with an error to the request. :raises: as specified in :meth:`aioxmpp.Clien...
python
def disable(self): yield from self._check_for_feature() iq = aioxmpp.IQ( type_=aioxmpp.IQType.SET, payload=carbons_xso.Disable() ) yield from self.client.send(iq)
[ "def", "disable", "(", "self", ")", ":", "yield", "from", "self", ".", "_check_for_feature", "(", ")", "iq", "=", "aioxmpp", ".", "IQ", "(", "type_", "=", "aioxmpp", ".", "IQType", ".", "SET", ",", "payload", "=", "carbons_xso", ".", "Disable", "(", ...
Disable message carbons. :raises RuntimeError: if the server does not support message carbons. :raises aioxmpp.XMPPError: if the server responded with an error to the request. :raises: as specified in :meth:`aioxmpp.Client.send`
[ "Disable", "message", "carbons", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/carbons/service.py#L93-L109
683
horazont/aioxmpp
aioxmpp/stream.py
StanzaStream._process_incoming_iq
def _process_incoming_iq(self, stanza_obj): """ Process an incoming IQ stanza `stanza_obj`. Calls the response handler, spawns a request handler coroutine or drops the stanza while logging a warning if no handler can be found. """ self._logger.debug("incoming iq: %r", sta...
python
def _process_incoming_iq(self, stanza_obj): self._logger.debug("incoming iq: %r", stanza_obj) if stanza_obj.type_.is_response: # iq response self._logger.debug("iq is response") keys = [(stanza_obj.from_, stanza_obj.id_)] if self._local_jid is not None: ...
[ "def", "_process_incoming_iq", "(", "self", ",", "stanza_obj", ")", ":", "self", ".", "_logger", ".", "debug", "(", "\"incoming iq: %r\"", ",", "stanza_obj", ")", "if", "stanza_obj", ".", "type_", ".", "is_response", ":", "# iq response", "self", ".", "_logger...
Process an incoming IQ stanza `stanza_obj`. Calls the response handler, spawns a request handler coroutine or drops the stanza while logging a warning if no handler can be found.
[ "Process", "an", "incoming", "IQ", "stanza", "stanza_obj", ".", "Calls", "the", "response", "handler", "spawns", "a", "request", "handler", "coroutine", "or", "drops", "the", "stanza", "while", "logging", "a", "warning", "if", "no", "handler", "can", "be", "...
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stream.py#L978-L1055
684
horazont/aioxmpp
aioxmpp/stream.py
StanzaStream._process_incoming_message
def _process_incoming_message(self, stanza_obj): """ Process an incoming message stanza `stanza_obj`. """ self._logger.debug("incoming message: %r", stanza_obj) stanza_obj = self.service_inbound_message_filter.filter(stanza_obj) if stanza_obj is None: self._l...
python
def _process_incoming_message(self, stanza_obj): self._logger.debug("incoming message: %r", stanza_obj) stanza_obj = self.service_inbound_message_filter.filter(stanza_obj) if stanza_obj is None: self._logger.debug("incoming message dropped by service " ...
[ "def", "_process_incoming_message", "(", "self", ",", "stanza_obj", ")", ":", "self", ".", "_logger", ".", "debug", "(", "\"incoming message: %r\"", ",", "stanza_obj", ")", "stanza_obj", "=", "self", ".", "service_inbound_message_filter", ".", "filter", "(", "stan...
Process an incoming message stanza `stanza_obj`.
[ "Process", "an", "incoming", "message", "stanza", "stanza_obj", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stream.py#L1057-L1075
685
horazont/aioxmpp
aioxmpp/stream.py
StanzaStream._process_incoming_presence
def _process_incoming_presence(self, stanza_obj): """ Process an incoming presence stanza `stanza_obj`. """ self._logger.debug("incoming presence: %r", stanza_obj) stanza_obj = self.service_inbound_presence_filter.filter(stanza_obj) if stanza_obj is None: sel...
python
def _process_incoming_presence(self, stanza_obj): self._logger.debug("incoming presence: %r", stanza_obj) stanza_obj = self.service_inbound_presence_filter.filter(stanza_obj) if stanza_obj is None: self._logger.debug("incoming presence dropped by service filter" ...
[ "def", "_process_incoming_presence", "(", "self", ",", "stanza_obj", ")", ":", "self", ".", "_logger", ".", "debug", "(", "\"incoming presence: %r\"", ",", "stanza_obj", ")", "stanza_obj", "=", "self", ".", "service_inbound_presence_filter", ".", "filter", "(", "s...
Process an incoming presence stanza `stanza_obj`.
[ "Process", "an", "incoming", "presence", "stanza", "stanza_obj", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stream.py#L1077-L1095
686
horazont/aioxmpp
aioxmpp/stream.py
StanzaStream._process_incoming
def _process_incoming(self, xmlstream, queue_entry): """ Dispatch to the different methods responsible for the different stanza types or handle a non-stanza stream-level element from `stanza_obj`, which has arrived over the given `xmlstream`. """ stanza_obj, exc = queue_...
python
def _process_incoming(self, xmlstream, queue_entry): stanza_obj, exc = queue_entry # first, handle SM stream objects if isinstance(stanza_obj, nonza.SMAcknowledgement): self._logger.debug("received SM ack: %r", stanza_obj) if not self._sm_enabled: self._l...
[ "def", "_process_incoming", "(", "self", ",", "xmlstream", ",", "queue_entry", ")", ":", "stanza_obj", ",", "exc", "=", "queue_entry", "# first, handle SM stream objects", "if", "isinstance", "(", "stanza_obj", ",", "nonza", ".", "SMAcknowledgement", ")", ":", "se...
Dispatch to the different methods responsible for the different stanza types or handle a non-stanza stream-level element from `stanza_obj`, which has arrived over the given `xmlstream`.
[ "Dispatch", "to", "the", "different", "methods", "responsible", "for", "the", "different", "stanza", "types", "or", "handle", "a", "non", "-", "stanza", "stream", "-", "level", "element", "from", "stanza_obj", "which", "has", "arrived", "over", "the", "given",...
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stream.py#L1145-L1193
687
horazont/aioxmpp
aioxmpp/stream.py
StanzaStream.flush_incoming
def flush_incoming(self): """ Flush all incoming queues to the respective processing methods. The handlers are called as usual, thus it may require at least one iteration through the asyncio event loop before effects can be seen. The incoming queues are empty after a call to thi...
python
def flush_incoming(self): while True: try: stanza_obj = self._incoming_queue.get_nowait() except asyncio.QueueEmpty: break self._process_incoming(None, stanza_obj)
[ "def", "flush_incoming", "(", "self", ")", ":", "while", "True", ":", "try", ":", "stanza_obj", "=", "self", ".", "_incoming_queue", ".", "get_nowait", "(", ")", "except", "asyncio", ".", "QueueEmpty", ":", "break", "self", ".", "_process_incoming", "(", "...
Flush all incoming queues to the respective processing methods. The handlers are called as usual, thus it may require at least one iteration through the asyncio event loop before effects can be seen. The incoming queues are empty after a call to this method. It is legal (but pretty use...
[ "Flush", "all", "incoming", "queues", "to", "the", "respective", "processing", "methods", ".", "The", "handlers", "are", "called", "as", "usual", "thus", "it", "may", "require", "at", "least", "one", "iteration", "through", "the", "asyncio", "event", "loop", ...
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stream.py#L1195-L1211
688
horazont/aioxmpp
aioxmpp/stream.py
StanzaStream._send_stanza
def _send_stanza(self, xmlstream, token): """ Send a stanza token `token` over the given `xmlstream`. Only sends if the `token` has not been aborted (see :meth:`StanzaToken.abort`). Sends the state of the token acoording to :attr:`sm_enabled`. """ if token.state ...
python
def _send_stanza(self, xmlstream, token): if token.state == StanzaState.ABORTED: return stanza_obj = token.stanza if isinstance(stanza_obj, stanza.Presence): stanza_obj = self.app_outbound_presence_filter.filter( stanza_obj ) if s...
[ "def", "_send_stanza", "(", "self", ",", "xmlstream", ",", "token", ")", ":", "if", "token", ".", "state", "==", "StanzaState", ".", "ABORTED", ":", "return", "stanza_obj", "=", "token", ".", "stanza", "if", "isinstance", "(", "stanza_obj", ",", "stanza", ...
Send a stanza token `token` over the given `xmlstream`. Only sends if the `token` has not been aborted (see :meth:`StanzaToken.abort`). Sends the state of the token acoording to :attr:`sm_enabled`.
[ "Send", "a", "stanza", "token", "token", "over", "the", "given", "xmlstream", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stream.py#L1213-L1263
689
horazont/aioxmpp
aioxmpp/stream.py
StanzaStream.register_iq_request_handler
def register_iq_request_handler(self, type_, payload_cls, cb, *, with_send_reply=False): """ Register a coroutine function or a function returning an awaitable to run when an IQ request is received. :param type_: IQ type to react to (must be a request...
python
def register_iq_request_handler(self, type_, payload_cls, cb, *, with_send_reply=False): type_ = self._coerce_enum(type_, structs.IQType) if not type_.is_request: raise ValueError( "{!r} is not a request IQType".format(type_) ) ...
[ "def", "register_iq_request_handler", "(", "self", ",", "type_", ",", "payload_cls", ",", "cb", ",", "*", ",", "with_send_reply", "=", "False", ")", ":", "type_", "=", "self", ".", "_coerce_enum", "(", "type_", ",", "structs", ".", "IQType", ")", "if", "...
Register a coroutine function or a function returning an awaitable to run when an IQ request is received. :param type_: IQ type to react to (must be a request type). :type type_: :class:`~aioxmpp.IQType` :param payload_cls: Payload class to react to (subclass of :class:`~xso...
[ "Register", "a", "coroutine", "function", "or", "a", "function", "returning", "an", "awaitable", "to", "run", "when", "an", "IQ", "request", "is", "received", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stream.py#L1394-L1511
690
horazont/aioxmpp
aioxmpp/stream.py
StanzaStream.register_message_callback
def register_message_callback(self, type_, from_, cb): """ Register a callback to be called when a message is received. :param type_: Message type to listen for, or :data:`None` for a wildcard match. :type type_: :class:`~.MessageType` or :data:`None` :para...
python
def register_message_callback(self, type_, from_, cb): if type_ is not None: type_ = self._coerce_enum(type_, structs.MessageType) warnings.warn( "register_message_callback is deprecated; use " "aioxmpp.dispatcher.SimpleMessageDispatcher instead", Deprecat...
[ "def", "register_message_callback", "(", "self", ",", "type_", ",", "from_", ",", "cb", ")", ":", "if", "type_", "is", "not", "None", ":", "type_", "=", "self", ".", "_coerce_enum", "(", "type_", ",", "structs", ".", "MessageType", ")", "warnings", ".", ...
Register a callback to be called when a message is received. :param type_: Message type to listen for, or :data:`None` for a wildcard match. :type type_: :class:`~.MessageType` or :data:`None` :param from_: Sender JID to listen for, or :data:`None` for a wildcard ...
[ "Register", "a", "callback", "to", "be", "called", "when", "a", "message", "is", "received", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stream.py#L1563-L1622
691
horazont/aioxmpp
aioxmpp/stream.py
StanzaStream.register_presence_callback
def register_presence_callback(self, type_, from_, cb): """ Register a callback to be called when a presence stanza is received. :param type_: Presence type to listen for. :type type_: :class:`~.PresenceType` :param from_: Sender JID to listen for, or :data:`None` for a wildcard...
python
def register_presence_callback(self, type_, from_, cb): type_ = self._coerce_enum(type_, structs.PresenceType) warnings.warn( "register_presence_callback is deprecated; use " "aioxmpp.dispatcher.SimplePresenceDispatcher or " "aioxmpp.PresenceClient instead", ...
[ "def", "register_presence_callback", "(", "self", ",", "type_", ",", "from_", ",", "cb", ")", ":", "type_", "=", "self", ".", "_coerce_enum", "(", "type_", ",", "structs", ".", "PresenceType", ")", "warnings", ".", "warn", "(", "\"register_presence_callback is...
Register a callback to be called when a presence stanza is received. :param type_: Presence type to listen for. :type type_: :class:`~.PresenceType` :param from_: Sender JID to listen for, or :data:`None` for a wildcard match. :type from_: :class:`~aioxmpp.JID` or ...
[ "Register", "a", "callback", "to", "be", "called", "when", "a", "presence", "stanza", "is", "received", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stream.py#L1680-L1736
692
horazont/aioxmpp
aioxmpp/stream.py
StanzaStream.wait_stop
def wait_stop(self): """ Stop the stream and wait for it to stop. See :meth:`stop` for the general stopping conditions. You can assume that :meth:`stop` is the first thing this coroutine calls. """ if not self.running: return self.stop() try: ...
python
def wait_stop(self): if not self.running: return self.stop() try: yield from self._task except asyncio.CancelledError: pass
[ "def", "wait_stop", "(", "self", ")", ":", "if", "not", "self", ".", "running", ":", "return", "self", ".", "stop", "(", ")", "try", ":", "yield", "from", "self", ".", "_task", "except", "asyncio", ".", "CancelledError", ":", "pass" ]
Stop the stream and wait for it to stop. See :meth:`stop` for the general stopping conditions. You can assume that :meth:`stop` is the first thing this coroutine calls.
[ "Stop", "the", "stream", "and", "wait", "for", "it", "to", "stop", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stream.py#L1912-L1925
693
horazont/aioxmpp
aioxmpp/stream.py
StanzaStream.resume_sm
def resume_sm(self, xmlstream): """ Resume an SM-enabled stream using the given `xmlstream`. If the server rejects the attempt to resume stream management, a :class:`.errors.StreamNegotiationFailure` is raised. The stream is then in stopped state and stream management has been s...
python
def resume_sm(self, xmlstream): if self.running: raise RuntimeError("Cannot resume Stream Management while" " StanzaStream is running") self._start_prepare(xmlstream, self.recv_stanza) try: response = yield from protocol.send_and_wait_for( ...
[ "def", "resume_sm", "(", "self", ",", "xmlstream", ")", ":", "if", "self", ".", "running", ":", "raise", "RuntimeError", "(", "\"Cannot resume Stream Management while\"", "\" StanzaStream is running\"", ")", "self", ".", "_start_prepare", "(", "xmlstream", ",", "sel...
Resume an SM-enabled stream using the given `xmlstream`. If the server rejects the attempt to resume stream management, a :class:`.errors.StreamNegotiationFailure` is raised. The stream is then in stopped state and stream management has been stopped. .. warning:: This metho...
[ "Resume", "an", "SM", "-", "enabled", "stream", "using", "the", "given", "xmlstream", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stream.py#L2359-L2434
694
horazont/aioxmpp
aioxmpp/stream.py
StanzaStream._send_immediately
def _send_immediately(self, stanza, *, timeout=None, cb=None): """ Send a stanza without waiting for the stream to be ready to send stanzas. This is only useful from within :class:`aioxmpp.node.Client` before the stream is fully established. """ stanza.autoset_id...
python
def _send_immediately(self, stanza, *, timeout=None, cb=None): stanza.autoset_id() self._logger.debug("sending %r and waiting for it to be sent", stanza) if not isinstance(stanza, stanza_.IQ) or stanza.type_.is_response: if cb is not None: ...
[ "def", "_send_immediately", "(", "self", ",", "stanza", ",", "*", ",", "timeout", "=", "None", ",", "cb", "=", "None", ")", ":", "stanza", ".", "autoset_id", "(", ")", "self", ".", "_logger", ".", "debug", "(", "\"sending %r and waiting for it to be sent\"",...
Send a stanza without waiting for the stream to be ready to send stanzas. This is only useful from within :class:`aioxmpp.node.Client` before the stream is fully established.
[ "Send", "a", "stanza", "without", "waiting", "for", "the", "stream", "to", "be", "ready", "to", "send", "stanzas", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/stream.py#L2561-L2673
695
horazont/aioxmpp
aioxmpp/entitycaps/caps390.py
_process_features
def _process_features(features): """ Generate the `Features String` from an iterable of features. :param features: The features to generate the features string from. :type features: :class:`~collections.abc.Iterable` of :class:`str` :return: The `Features String` :rtype: :class:`bytes` Gen...
python
def _process_features(features): parts = [ feature.encode("utf-8")+b"\x1f" for feature in features ] parts.sort() return b"".join(parts)+b"\x1c"
[ "def", "_process_features", "(", "features", ")", ":", "parts", "=", "[", "feature", ".", "encode", "(", "\"utf-8\"", ")", "+", "b\"\\x1f\"", "for", "feature", "in", "features", "]", "parts", ".", "sort", "(", ")", "return", "b\"\"", ".", "join", "(", ...
Generate the `Features String` from an iterable of features. :param features: The features to generate the features string from. :type features: :class:`~collections.abc.Iterable` of :class:`str` :return: The `Features String` :rtype: :class:`bytes` Generate the `Features String` from the given `f...
[ "Generate", "the", "Features", "String", "from", "an", "iterable", "of", "features", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/entitycaps/caps390.py#L33-L50
696
horazont/aioxmpp
aioxmpp/entitycaps/caps390.py
_process_identities
def _process_identities(identities): """ Generate the `Identities String` from an iterable of identities. :param identities: The identities to generate the features string from. :type identities: :class:`~collections.abc.Iterable` of :class:`~.disco.xso.Identity` :return: The `Identities St...
python
def _process_identities(identities): parts = [ _process_identity(identity) for identity in identities ] parts.sort() return b"".join(parts)+b"\x1c"
[ "def", "_process_identities", "(", "identities", ")", ":", "parts", "=", "[", "_process_identity", "(", "identity", ")", "for", "identity", "in", "identities", "]", "parts", ".", "sort", "(", ")", "return", "b\"\"", ".", "join", "(", "parts", ")", "+", "...
Generate the `Identities String` from an iterable of identities. :param identities: The identities to generate the features string from. :type identities: :class:`~collections.abc.Iterable` of :class:`~.disco.xso.Identity` :return: The `Identities String` :rtype: :class:`bytes` Generate th...
[ "Generate", "the", "Identities", "String", "from", "an", "iterable", "of", "identities", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/entitycaps/caps390.py#L62-L80
697
horazont/aioxmpp
aioxmpp/entitycaps/caps390.py
_process_extensions
def _process_extensions(exts): """ Generate the `Extensions String` from an iterable of data forms. :param exts: The data forms to generate the extensions string from. :type exts: :class:`~collections.abc.Iterable` of :class:`~.forms.xso.Data` :return: The `Extensions String` :rtype: :c...
python
def _process_extensions(exts): parts = [ _process_form(form) for form in exts ] parts.sort() return b"".join(parts)+b"\x1c"
[ "def", "_process_extensions", "(", "exts", ")", ":", "parts", "=", "[", "_process_form", "(", "form", ")", "for", "form", "in", "exts", "]", "parts", ".", "sort", "(", ")", "return", "b\"\"", ".", "join", "(", "parts", ")", "+", "b\"\\x1c\"" ]
Generate the `Extensions String` from an iterable of data forms. :param exts: The data forms to generate the extensions string from. :type exts: :class:`~collections.abc.Iterable` of :class:`~.forms.xso.Data` :return: The `Extensions String` :rtype: :class:`bytes` Generate the `Extensions ...
[ "Generate", "the", "Extensions", "String", "from", "an", "iterable", "of", "data", "forms", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/entitycaps/caps390.py#L103-L121
698
horazont/aioxmpp
aioxmpp/statemachine.py
OrderedStateMachine.wait_for
def wait_for(self, new_state): """ Wait for an exact state `new_state` to be reached by the state machine. If the state is skipped, that is, if a state which is greater than `new_state` is written to :attr:`state`, the coroutine raises :class:`OrderedStateSkipped` except...
python
def wait_for(self, new_state): if self._state == new_state: return if self._state > new_state: raise OrderedStateSkipped(new_state) fut = asyncio.Future(loop=self.loop) self._exact_waiters.append((new_state, fut)) yield from fut
[ "def", "wait_for", "(", "self", ",", "new_state", ")", ":", "if", "self", ".", "_state", "==", "new_state", ":", "return", "if", "self", ".", "_state", ">", "new_state", ":", "raise", "OrderedStateSkipped", "(", "new_state", ")", "fut", "=", "asyncio", "...
Wait for an exact state `new_state` to be reached by the state machine. If the state is skipped, that is, if a state which is greater than `new_state` is written to :attr:`state`, the coroutine raises :class:`OrderedStateSkipped` exception as it is not possible anymore that it c...
[ "Wait", "for", "an", "exact", "state", "new_state", "to", "be", "reached", "by", "the", "state", "machine", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/statemachine.py#L152-L170
699
horazont/aioxmpp
aioxmpp/statemachine.py
OrderedStateMachine.wait_for_at_least
def wait_for_at_least(self, new_state): """ Wait for a state to be entered which is greater than or equal to `new_state` and return. """ if not (self._state < new_state): return fut = asyncio.Future(loop=self.loop) self._least_waiters.append((new_stat...
python
def wait_for_at_least(self, new_state): if not (self._state < new_state): return fut = asyncio.Future(loop=self.loop) self._least_waiters.append((new_state, fut)) yield from fut
[ "def", "wait_for_at_least", "(", "self", ",", "new_state", ")", ":", "if", "not", "(", "self", ".", "_state", "<", "new_state", ")", ":", "return", "fut", "=", "asyncio", ".", "Future", "(", "loop", "=", "self", ".", "loop", ")", "self", ".", "_least...
Wait for a state to be entered which is greater than or equal to `new_state` and return.
[ "Wait", "for", "a", "state", "to", "be", "entered", "which", "is", "greater", "than", "or", "equal", "to", "new_state", "and", "return", "." ]
22a68e5e1d23f2a4dee470092adbd4672f9ef061
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/statemachine.py#L173-L183