repo
stringlengths
7
54
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
20
28.4k
docstring
stringlengths
1
46.3k
docstring_tokens
listlengths
1
1.66k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
summary
stringlengths
4
350
obf_code
stringlengths
7.85k
764k
zalando/patroni
patroni/utils.py
patch_config
def patch_config(config, data): """recursively 'patch' `config` with `data` :returns: `!True` if the `config` was changed""" is_changed = False for name, value in data.items(): if value is None: if config.pop(name, None) is not None: is_changed = True elif nam...
python
def patch_config(config, data): """recursively 'patch' `config` with `data` :returns: `!True` if the `config` was changed""" is_changed = False for name, value in data.items(): if value is None: if config.pop(name, None) is not None: is_changed = True elif nam...
[ "def", "patch_config", "(", "config", ",", "data", ")", ":", "is_changed", "=", "False", "for", "name", ",", "value", "in", "data", ".", "items", "(", ")", ":", "if", "value", "is", "None", ":", "if", "config", ".", "pop", "(", "name", ",", "None",...
recursively 'patch' `config` with `data` :returns: `!True` if the `config` was changed
[ "recursively", "patch", "config", "with", "data", ":", "returns", ":", "!True", "if", "the", "config", "was", "changed" ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/utils.py#L36-L58
train
recursively patch the config with data
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/utils.py
parse_bool
def parse_bool(value): """ >>> parse_bool(1) True >>> parse_bool('off') False >>> parse_bool('foo') """ value = str(value).lower() if value in ('on', 'true', 'yes', '1'): return True if value in ('off', 'false', 'no', '0'): return False
python
def parse_bool(value): """ >>> parse_bool(1) True >>> parse_bool('off') False >>> parse_bool('foo') """ value = str(value).lower() if value in ('on', 'true', 'yes', '1'): return True if value in ('off', 'false', 'no', '0'): return False
[ "def", "parse_bool", "(", "value", ")", ":", "value", "=", "str", "(", "value", ")", ".", "lower", "(", ")", "if", "value", "in", "(", "'on'", ",", "'true'", ",", "'yes'", ",", "'1'", ")", ":", "return", "True", "if", "value", "in", "(", "'off'",...
>>> parse_bool(1) True >>> parse_bool('off') False >>> parse_bool('foo')
[ ">>>", "parse_bool", "(", "1", ")", "True", ">>>", "parse_bool", "(", "off", ")", "False", ">>>", "parse_bool", "(", "foo", ")" ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/utils.py#L61-L73
train
parse_bool - Parse boolean value into a tuple of True False and False.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/utils.py
strtol
def strtol(value, strict=True): """As most as possible close equivalent of strtol(3) function (with base=0), used by postgres to parse parameter values. >>> strtol(0) == (0, '') True >>> strtol(1) == (1, '') True >>> strtol(9) == (9, '') True >>> strtol(' +0x400MB') == (1024, 'MB'...
python
def strtol(value, strict=True): """As most as possible close equivalent of strtol(3) function (with base=0), used by postgres to parse parameter values. >>> strtol(0) == (0, '') True >>> strtol(1) == (1, '') True >>> strtol(9) == (9, '') True >>> strtol(' +0x400MB') == (1024, 'MB'...
[ "def", "strtol", "(", "value", ",", "strict", "=", "True", ")", ":", "value", "=", "str", "(", "value", ")", ".", "strip", "(", ")", "ln", "=", "len", "(", "value", ")", "i", "=", "0", "# skip sign:", "if", "i", "<", "ln", "and", "value", "[", ...
As most as possible close equivalent of strtol(3) function (with base=0), used by postgres to parse parameter values. >>> strtol(0) == (0, '') True >>> strtol(1) == (1, '') True >>> strtol(9) == (9, '') True >>> strtol(' +0x400MB') == (1024, 'MB') True >>> strtol(' -070d') == ...
[ "As", "most", "as", "possible", "close", "equivalent", "of", "strtol", "(", "3", ")", "function", "(", "with", "base", "=", "0", ")", "used", "by", "postgres", "to", "parse", "parameter", "values", ".", ">>>", "strtol", "(", "0", ")", "==", "(", "0",...
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/utils.py#L76-L126
train
As most possible close equivalent of strtol.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/utils.py
parse_int
def parse_int(value, base_unit=None): """ >>> parse_int('1') == 1 True >>> parse_int(' 0x400 MB ', '16384kB') == 64 True >>> parse_int('1MB', 'kB') == 1024 True >>> parse_int('1000 ms', 's') == 1 True >>> parse_int('1GB', 'MB') is None True >>> parse_int(0) == 0 True ...
python
def parse_int(value, base_unit=None): """ >>> parse_int('1') == 1 True >>> parse_int(' 0x400 MB ', '16384kB') == 64 True >>> parse_int('1MB', 'kB') == 1024 True >>> parse_int('1000 ms', 's') == 1 True >>> parse_int('1GB', 'MB') is None True >>> parse_int(0) == 0 True ...
[ "def", "parse_int", "(", "value", ",", "base_unit", "=", "None", ")", ":", "convert", "=", "{", "'kB'", ":", "{", "'kB'", ":", "1", ",", "'MB'", ":", "1024", ",", "'GB'", ":", "1024", "*", "1024", ",", "'TB'", ":", "1024", "*", "1024", "*", "10...
>>> parse_int('1') == 1 True >>> parse_int(' 0x400 MB ', '16384kB') == 64 True >>> parse_int('1MB', 'kB') == 1024 True >>> parse_int('1000 ms', 's') == 1 True >>> parse_int('1GB', 'MB') is None True >>> parse_int(0) == 0 True
[ ">>>", "parse_int", "(", "1", ")", "==", "1", "True", ">>>", "parse_int", "(", "0x400", "MB", "16384kB", ")", "==", "64", "True", ">>>", "parse_int", "(", "1MB", "kB", ")", "==", "1024", "True", ">>>", "parse_int", "(", "1000", "ms", "s", ")", "=="...
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/utils.py#L129-L167
train
Parse an integer into a base_unit.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/utils.py
compare_values
def compare_values(vartype, unit, old_value, new_value): """ >>> compare_values('enum', None, 'remote_write', 'REMOTE_WRITE') True >>> compare_values('real', None, '1.23', 1.23) True """ # if the integer or bool new_value is not correct this function will return False if vartype == 'boo...
python
def compare_values(vartype, unit, old_value, new_value): """ >>> compare_values('enum', None, 'remote_write', 'REMOTE_WRITE') True >>> compare_values('real', None, '1.23', 1.23) True """ # if the integer or bool new_value is not correct this function will return False if vartype == 'boo...
[ "def", "compare_values", "(", "vartype", ",", "unit", ",", "old_value", ",", "new_value", ")", ":", "# if the integer or bool new_value is not correct this function will return False", "if", "vartype", "==", "'bool'", ":", "old_value", "=", "parse_bool", "(", "old_value",...
>>> compare_values('enum', None, 'remote_write', 'REMOTE_WRITE') True >>> compare_values('real', None, '1.23', 1.23) True
[ ">>>", "compare_values", "(", "enum", "None", "remote_write", "REMOTE_WRITE", ")", "True", ">>>", "compare_values", "(", "real", "None", "1", ".", "23", "1", ".", "23", ")", "True" ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/utils.py#L170-L189
train
Compare two values for a given vartype.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/utils.py
polling_loop
def polling_loop(timeout, interval=1): """Returns an iterator that returns values until timeout has passed. Timeout is measured from start of iteration.""" start_time = time.time() iteration = 0 end_time = start_time + timeout while time.time() < end_time: yield iteration iteration +...
python
def polling_loop(timeout, interval=1): """Returns an iterator that returns values until timeout has passed. Timeout is measured from start of iteration.""" start_time = time.time() iteration = 0 end_time = start_time + timeout while time.time() < end_time: yield iteration iteration +...
[ "def", "polling_loop", "(", "timeout", ",", "interval", "=", "1", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "iteration", "=", "0", "end_time", "=", "start_time", "+", "timeout", "while", "time", ".", "time", "(", ")", "<", "end_time",...
Returns an iterator that returns values until timeout has passed. Timeout is measured from start of iteration.
[ "Returns", "an", "iterator", "that", "returns", "values", "until", "timeout", "has", "passed", ".", "Timeout", "is", "measured", "from", "start", "of", "iteration", "." ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/utils.py#L269-L277
train
Returns an iterator that returns values until timeout has passed.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/utils.py
Retry.reset
def reset(self): """Reset the attempt counter""" self._attempts = 0 self._cur_delay = self.delay self._cur_stoptime = None
python
def reset(self): """Reset the attempt counter""" self._attempts = 0 self._cur_delay = self.delay self._cur_stoptime = None
[ "def", "reset", "(", "self", ")", ":", "self", ".", "_attempts", "=", "0", "self", ".", "_cur_delay", "=", "self", ".", "delay", "self", ".", "_cur_stoptime", "=", "None" ]
Reset the attempt counter
[ "Reset", "the", "attempt", "counter" ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/utils.py#L228-L232
train
Reset the attempt counter and the current delay and the current stoptime
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/utils.py
Retry.copy
def copy(self): """Return a clone of this retry manager""" return Retry(max_tries=self.max_tries, delay=self.delay, backoff=self.backoff, max_jitter=self.max_jitter / 100.0, max_delay=self.max_delay, sleep_func=self.sleep_func, deadline=self.deadline, retry_exce...
python
def copy(self): """Return a clone of this retry manager""" return Retry(max_tries=self.max_tries, delay=self.delay, backoff=self.backoff, max_jitter=self.max_jitter / 100.0, max_delay=self.max_delay, sleep_func=self.sleep_func, deadline=self.deadline, retry_exce...
[ "def", "copy", "(", "self", ")", ":", "return", "Retry", "(", "max_tries", "=", "self", ".", "max_tries", ",", "delay", "=", "self", ".", "delay", ",", "backoff", "=", "self", ".", "backoff", ",", "max_jitter", "=", "self", ".", "max_jitter", "/", "1...
Return a clone of this retry manager
[ "Return", "a", "clone", "of", "this", "retry", "manager" ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/utils.py#L234-L238
train
Return a copy of this retry manager
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/api.py
check_auth
def check_auth(func): """Decorator function to check authorization header. Usage example: @check_auth def do_PUT_foo(): pass """ def wrapper(handler, *args, **kwargs): if handler.check_auth_header(): return func(handler, *args, **kwargs) return wrapper
python
def check_auth(func): """Decorator function to check authorization header. Usage example: @check_auth def do_PUT_foo(): pass """ def wrapper(handler, *args, **kwargs): if handler.check_auth_header(): return func(handler, *args, **kwargs) return wrapper
[ "def", "check_auth", "(", "func", ")", ":", "def", "wrapper", "(", "handler", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "handler", ".", "check_auth_header", "(", ")", ":", "return", "func", "(", "handler", ",", "*", "args", ",", "*...
Decorator function to check authorization header. Usage example: @check_auth def do_PUT_foo(): pass
[ "Decorator", "function", "to", "check", "authorization", "header", "." ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/api.py#L21-L32
train
Decorator to check authorization header.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/api.py
RestApiHandler.do_GET
def do_GET(self, write_status_code_only=False): """Default method for processing all GET requests which can not be routed to other methods""" path = '/master' if self.path == '/' else self.path response = self.get_postgresql_status() patroni = self.server.patroni cluster = patr...
python
def do_GET(self, write_status_code_only=False): """Default method for processing all GET requests which can not be routed to other methods""" path = '/master' if self.path == '/' else self.path response = self.get_postgresql_status() patroni = self.server.patroni cluster = patr...
[ "def", "do_GET", "(", "self", ",", "write_status_code_only", "=", "False", ")", ":", "path", "=", "'/master'", "if", "self", ".", "path", "==", "'/'", "else", "self", ".", "path", "response", "=", "self", ".", "get_postgresql_status", "(", ")", "patroni", ...
Default method for processing all GET requests which can not be routed to other methods
[ "Default", "method", "for", "processing", "all", "GET", "requests", "which", "can", "not", "be", "routed", "to", "other", "methods" ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/api.py#L79-L116
train
Default method for processing all GET requests which can not be routed to other methods
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/api.py
RestApiHandler.parse_schedule
def parse_schedule(schedule, action): """ parses the given schedule and validates at """ error = None scheduled_at = None try: scheduled_at = dateutil.parser.parse(schedule) if scheduled_at.tzinfo is None: error = 'Timezone information is mandatory...
python
def parse_schedule(schedule, action): """ parses the given schedule and validates at """ error = None scheduled_at = None try: scheduled_at = dateutil.parser.parse(schedule) if scheduled_at.tzinfo is None: error = 'Timezone information is mandatory...
[ "def", "parse_schedule", "(", "schedule", ",", "action", ")", ":", "error", "=", "None", "scheduled_at", "=", "None", "try", ":", "scheduled_at", "=", "dateutil", ".", "parser", ".", "parse", "(", "schedule", ")", "if", "scheduled_at", ".", "tzinfo", "is",...
parses the given schedule and validates at
[ "parses", "the", "given", "schedule", "and", "validates", "at" ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/api.py#L186-L204
train
Parses the given schedule and validates at
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/api.py
RestApiHandler.parse_request
def parse_request(self): """Override parse_request method to enrich basic functionality of `BaseHTTPRequestHandler` class Original class can only invoke do_GET, do_POST, do_PUT, etc method implementations if they are defined. But we would like to have at least some simple routing mechanism, i.e...
python
def parse_request(self): """Override parse_request method to enrich basic functionality of `BaseHTTPRequestHandler` class Original class can only invoke do_GET, do_POST, do_PUT, etc method implementations if they are defined. But we would like to have at least some simple routing mechanism, i.e...
[ "def", "parse_request", "(", "self", ")", ":", "ret", "=", "BaseHTTPRequestHandler", ".", "parse_request", "(", "self", ")", "if", "ret", ":", "mname", "=", "self", ".", "path", ".", "lstrip", "(", "'/'", ")", ".", "split", "(", "'/'", ")", "[", "0",...
Override parse_request method to enrich basic functionality of `BaseHTTPRequestHandler` class Original class can only invoke do_GET, do_POST, do_PUT, etc method implementations if they are defined. But we would like to have at least some simple routing mechanism, i.e.: GET /uri1/part2 request s...
[ "Override", "parse_request", "method", "to", "enrich", "basic", "functionality", "of", "BaseHTTPRequestHandler", "class" ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/api.py#L387-L403
train
Override parse_request method to enrich basic functionality of BaseHTTPRequestHandler class.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/config.py
Config._load_config_file
def _load_config_file(self): """Loads config.yaml from filesystem and applies some values which were set via ENV""" with open(self._config_file) as f: config = yaml.safe_load(f) patch_config(config, self.__environment_configuration) return config
python
def _load_config_file(self): """Loads config.yaml from filesystem and applies some values which were set via ENV""" with open(self._config_file) as f: config = yaml.safe_load(f) patch_config(config, self.__environment_configuration) return config
[ "def", "_load_config_file", "(", "self", ")", ":", "with", "open", "(", "self", ".", "_config_file", ")", "as", "f", ":", "config", "=", "yaml", ".", "safe_load", "(", "f", ")", "patch_config", "(", "config", ",", "self", ".", "__environment_configuration"...
Loads config.yaml from filesystem and applies some values which were set via ENV
[ "Loads", "config", ".", "yaml", "from", "filesystem", "and", "applies", "some", "values", "which", "were", "set", "via", "ENV" ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/config.py#L105-L110
train
Loads config. yaml from filesystem and applies some values which were set via ENV
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/dcs/__init__.py
slot_name_from_member_name
def slot_name_from_member_name(member_name): """Translate member name to valid PostgreSQL slot name. PostgreSQL replication slot names must be valid PostgreSQL names. This function maps the wider space of member names to valid PostgreSQL names. Names are lowercased, dashes and periods common in hostnames ...
python
def slot_name_from_member_name(member_name): """Translate member name to valid PostgreSQL slot name. PostgreSQL replication slot names must be valid PostgreSQL names. This function maps the wider space of member names to valid PostgreSQL names. Names are lowercased, dashes and periods common in hostnames ...
[ "def", "slot_name_from_member_name", "(", "member_name", ")", ":", "def", "replace_char", "(", "match", ")", ":", "c", "=", "match", ".", "group", "(", "0", ")", "return", "'_'", "if", "c", "in", "'-.'", "else", "\"u{:04d}\"", ".", "format", "(", "ord", ...
Translate member name to valid PostgreSQL slot name. PostgreSQL replication slot names must be valid PostgreSQL names. This function maps the wider space of member names to valid PostgreSQL names. Names are lowercased, dashes and periods common in hostnames are replaced with underscores, other characters a...
[ "Translate", "member", "name", "to", "valid", "PostgreSQL", "slot", "name", "." ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/dcs/__init__.py#L26-L39
train
Translate member name to valid PostgreSQL replication slot name.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/dcs/__init__.py
parse_connection_string
def parse_connection_string(value): """Original Governor stores connection strings for each cluster members if a following format: postgres://{username}:{password}@{connect_address}/postgres Since each of our patroni instances provides own REST API endpoint it's good to store this information in DCS...
python
def parse_connection_string(value): """Original Governor stores connection strings for each cluster members if a following format: postgres://{username}:{password}@{connect_address}/postgres Since each of our patroni instances provides own REST API endpoint it's good to store this information in DCS...
[ "def", "parse_connection_string", "(", "value", ")", ":", "scheme", ",", "netloc", ",", "path", ",", "params", ",", "query", ",", "fragment", "=", "urlparse", "(", "value", ")", "conn_url", "=", "urlunparse", "(", "(", "scheme", ",", "netloc", ",", "path...
Original Governor stores connection strings for each cluster members if a following format: postgres://{username}:{password}@{connect_address}/postgres Since each of our patroni instances provides own REST API endpoint it's good to store this information in DCS among with postgresql connection string. I...
[ "Original", "Governor", "stores", "connection", "strings", "for", "each", "cluster", "members", "if", "a", "following", "format", ":", "postgres", ":", "//", "{", "username", "}", ":", "{", "password", "}", "@", "{", "connect_address", "}", "/", "postgres", ...
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/dcs/__init__.py#L42-L56
train
Parse connection string into two parts
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/dcs/__init__.py
dcs_modules
def dcs_modules(): """Get names of DCS modules, depending on execution environment. If being packaged with PyInstaller, modules aren't discoverable dynamically by scanning source directory because `FrozenImporter` doesn't implement `iter_modules` method. But it is still possible to find all potential DCS mo...
python
def dcs_modules(): """Get names of DCS modules, depending on execution environment. If being packaged with PyInstaller, modules aren't discoverable dynamically by scanning source directory because `FrozenImporter` doesn't implement `iter_modules` method. But it is still possible to find all potential DCS mo...
[ "def", "dcs_modules", "(", ")", ":", "dcs_dirname", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", "module_prefix", "=", "__package__", "+", "'.'", "if", "getattr", "(", "sys", ",", "'frozen'", ",", "False", ")", ":", "importer", "=", "p...
Get names of DCS modules, depending on execution environment. If being packaged with PyInstaller, modules aren't discoverable dynamically by scanning source directory because `FrozenImporter` doesn't implement `iter_modules` method. But it is still possible to find all potential DCS modules by iterating thr...
[ "Get", "names", "of", "DCS", "modules", "depending", "on", "execution", "environment", ".", "If", "being", "packaged", "with", "PyInstaller", "modules", "aren", "t", "discoverable", "dynamically", "by", "scanning", "source", "directory", "because", "FrozenImporter",...
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/dcs/__init__.py#L59-L72
train
Get names of DCS modules depending on execution environment.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/dcs/__init__.py
Member.from_node
def from_node(index, name, session, data): """ >>> Member.from_node(-1, '', '', '{"conn_url": "postgres://foo@bar/postgres"}') is not None True >>> Member.from_node(-1, '', '', '{') Member(index=-1, name='', session='', data={}) """ if data.startswith('postgres'):...
python
def from_node(index, name, session, data): """ >>> Member.from_node(-1, '', '', '{"conn_url": "postgres://foo@bar/postgres"}') is not None True >>> Member.from_node(-1, '', '', '{') Member(index=-1, name='', session='', data={}) """ if data.startswith('postgres'):...
[ "def", "from_node", "(", "index", ",", "name", ",", "session", ",", "data", ")", ":", "if", "data", ".", "startswith", "(", "'postgres'", ")", ":", "conn_url", ",", "api_url", "=", "parse_connection_string", "(", "data", ")", "data", "=", "{", "'conn_url...
>>> Member.from_node(-1, '', '', '{"conn_url": "postgres://foo@bar/postgres"}') is not None True >>> Member.from_node(-1, '', '', '{') Member(index=-1, name='', session='', data={})
[ ">>>", "Member", ".", "from_node", "(", "-", "1", "{", "conn_url", ":", "postgres", ":", "//", "foo" ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/dcs/__init__.py#L112-L127
train
Create a new Member instance from a node.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/dcs/__init__.py
ClusterConfig.from_node
def from_node(index, data, modify_index=None): """ >>> ClusterConfig.from_node(1, '{') is None False """ try: data = json.loads(data) except (TypeError, ValueError): data = None modify_index = 0 if not isinstance(data, dict): ...
python
def from_node(index, data, modify_index=None): """ >>> ClusterConfig.from_node(1, '{') is None False """ try: data = json.loads(data) except (TypeError, ValueError): data = None modify_index = 0 if not isinstance(data, dict): ...
[ "def", "from_node", "(", "index", ",", "data", ",", "modify_index", "=", "None", ")", ":", "try", ":", "data", "=", "json", ".", "loads", "(", "data", ")", "except", "(", "TypeError", ",", "ValueError", ")", ":", "data", "=", "None", "modify_index", ...
>>> ClusterConfig.from_node(1, '{') is None False
[ ">>>", "ClusterConfig", ".", "from_node", "(", "1", "{", ")", "is", "None", "False" ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/dcs/__init__.py#L293-L306
train
Create a ClusterConfig object from a node.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/dcs/__init__.py
SyncState.from_node
def from_node(index, value): """ >>> SyncState.from_node(1, None).leader is None True >>> SyncState.from_node(1, '{}').leader is None True >>> SyncState.from_node(1, '{').leader is None True >>> SyncState.from_node(1, '[]').leader is None True ...
python
def from_node(index, value): """ >>> SyncState.from_node(1, None).leader is None True >>> SyncState.from_node(1, '{}').leader is None True >>> SyncState.from_node(1, '{').leader is None True >>> SyncState.from_node(1, '[]').leader is None True ...
[ "def", "from_node", "(", "index", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "data", "=", "value", "elif", "value", ":", "try", ":", "data", "=", "json", ".", "loads", "(", "value", ")", "if", "not", "isinstanc...
>>> SyncState.from_node(1, None).leader is None True >>> SyncState.from_node(1, '{}').leader is None True >>> SyncState.from_node(1, '{').leader is None True >>> SyncState.from_node(1, '[]').leader is None True >>> SyncState.from_node(1, '{"leader": "leade...
[ ">>>", "SyncState", ".", "from_node", "(", "1", "None", ")", ".", "leader", "is", "None", "True", ">>>", "SyncState", ".", "from_node", "(", "1", "{}", ")", ".", "leader", "is", "None", "True", ">>>", "SyncState", ".", "from_node", "(", "1", "{", ")"...
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/dcs/__init__.py#L325-L351
train
Create a new SyncState object from a node.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/dcs/__init__.py
TimelineHistory.from_node
def from_node(index, value): """ >>> h = TimelineHistory.from_node(1, 2) >>> h.lines [] """ try: lines = json.loads(value) except (TypeError, ValueError): lines = None if not isinstance(lines, list): lines = [] r...
python
def from_node(index, value): """ >>> h = TimelineHistory.from_node(1, 2) >>> h.lines [] """ try: lines = json.loads(value) except (TypeError, ValueError): lines = None if not isinstance(lines, list): lines = [] r...
[ "def", "from_node", "(", "index", ",", "value", ")", ":", "try", ":", "lines", "=", "json", ".", "loads", "(", "value", ")", "except", "(", "TypeError", ",", "ValueError", ")", ":", "lines", "=", "None", "if", "not", "isinstance", "(", "lines", ",", ...
>>> h = TimelineHistory.from_node(1, 2) >>> h.lines []
[ ">>>", "h", "=", "TimelineHistory", ".", "from_node", "(", "1", "2", ")", ">>>", "h", ".", "lines", "[]" ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/dcs/__init__.py#L376-L388
train
Create a new TimelineHistory object from a node.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/dcs/__init__.py
Cluster.timeline
def timeline(self): """ >>> Cluster(0, 0, 0, 0, 0, 0, 0, 0).timeline 0 >>> Cluster(0, 0, 0, 0, 0, 0, 0, TimelineHistory.from_node(1, '[]')).timeline 1 >>> Cluster(0, 0, 0, 0, 0, 0, 0, TimelineHistory.from_node(1, '[["a"]]')).timeline 0 """ if self....
python
def timeline(self): """ >>> Cluster(0, 0, 0, 0, 0, 0, 0, 0).timeline 0 >>> Cluster(0, 0, 0, 0, 0, 0, 0, TimelineHistory.from_node(1, '[]')).timeline 1 >>> Cluster(0, 0, 0, 0, 0, 0, 0, TimelineHistory.from_node(1, '[["a"]]')).timeline 0 """ if self....
[ "def", "timeline", "(", "self", ")", ":", "if", "self", ".", "history", ":", "if", "self", ".", "history", ".", "lines", ":", "try", ":", "return", "int", "(", "self", ".", "history", ".", "lines", "[", "-", "1", "]", "[", "0", "]", ")", "+", ...
>>> Cluster(0, 0, 0, 0, 0, 0, 0, 0).timeline 0 >>> Cluster(0, 0, 0, 0, 0, 0, 0, TimelineHistory.from_node(1, '[]')).timeline 1 >>> Cluster(0, 0, 0, 0, 0, 0, 0, TimelineHistory.from_node(1, '[["a"]]')).timeline 0
[ ">>>", "Cluster", "(", "0", "0", "0", "0", "0", "0", "0", "0", ")", ".", "timeline", "0", ">>>", "Cluster", "(", "0", "0", "0", "0", "0", "0", "0", "TimelineHistory", ".", "from_node", "(", "1", "[]", "))", ".", "timeline", "1", ">>>", "Cluster...
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/dcs/__init__.py#L489-L506
train
Return the number of entries in the timeline.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/dcs/kubernetes.py
Kubernetes.subsets_changed
def subsets_changed(last_observed_subsets, subsets): """ >>> Kubernetes.subsets_changed([], []) False >>> Kubernetes.subsets_changed([], [k8s_client.V1EndpointSubset()]) True >>> s1 = [k8s_client.V1EndpointSubset(addresses=[k8s_client.V1EndpointAddress(ip='1.2.3.4')])] ...
python
def subsets_changed(last_observed_subsets, subsets): """ >>> Kubernetes.subsets_changed([], []) False >>> Kubernetes.subsets_changed([], [k8s_client.V1EndpointSubset()]) True >>> s1 = [k8s_client.V1EndpointSubset(addresses=[k8s_client.V1EndpointAddress(ip='1.2.3.4')])] ...
[ "def", "subsets_changed", "(", "last_observed_subsets", ",", "subsets", ")", ":", "if", "len", "(", "last_observed_subsets", ")", "!=", "len", "(", "subsets", ")", ":", "return", "True", "if", "subsets", "==", "[", "]", ":", "return", "False", "if", "len",...
>>> Kubernetes.subsets_changed([], []) False >>> Kubernetes.subsets_changed([], [k8s_client.V1EndpointSubset()]) True >>> s1 = [k8s_client.V1EndpointSubset(addresses=[k8s_client.V1EndpointAddress(ip='1.2.3.4')])] >>> s2 = [k8s_client.V1EndpointSubset(addresses=[k8s_client.V1Endpo...
[ ">>>", "Kubernetes", ".", "subsets_changed", "(", "[]", "[]", ")", "False", ">>>", "Kubernetes", ".", "subsets_changed", "(", "[]", "[", "k8s_client", ".", "V1EndpointSubset", "()", "]", ")", "True", ">>>", "s1", "=", "[", "k8s_client", ".", "V1EndpointSubse...
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/dcs/kubernetes.py#L220-L260
train
Called when the last observed subsets of a namespace has changed.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
features/environment.py
after_feature
def after_feature(context, feature): """ stop all Patronis, remove their data directory and cleanup the keys in etcd """ context.pctl.stop_all() shutil.rmtree(os.path.join(context.pctl.patroni_path, 'data')) context.dcs_ctl.cleanup_service_tree() if feature.status == 'failed': shutil.copytre...
python
def after_feature(context, feature): """ stop all Patronis, remove their data directory and cleanup the keys in etcd """ context.pctl.stop_all() shutil.rmtree(os.path.join(context.pctl.patroni_path, 'data')) context.dcs_ctl.cleanup_service_tree() if feature.status == 'failed': shutil.copytre...
[ "def", "after_feature", "(", "context", ",", "feature", ")", ":", "context", ".", "pctl", ".", "stop_all", "(", ")", "shutil", ".", "rmtree", "(", "os", ".", "path", ".", "join", "(", "context", ".", "pctl", ".", "patroni_path", ",", "'data'", ")", "...
stop all Patronis, remove their data directory and cleanup the keys in etcd
[ "stop", "all", "Patronis", "remove", "their", "data", "directory", "and", "cleanup", "the", "keys", "in", "etcd" ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/features/environment.py#L823-L829
train
Stop all Patronis and remove all data directory and cleanup the keys in etcd
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
features/environment.py
AbstractDcsController.stop
def stop(self, kill=False, timeout=15): """ terminate process and wipe out the temp work directory, but only if we actually started it""" super(AbstractDcsController, self).stop(kill=kill, timeout=timeout) if self._work_directory: shutil.rmtree(self._work_directory)
python
def stop(self, kill=False, timeout=15): """ terminate process and wipe out the temp work directory, but only if we actually started it""" super(AbstractDcsController, self).stop(kill=kill, timeout=timeout) if self._work_directory: shutil.rmtree(self._work_directory)
[ "def", "stop", "(", "self", ",", "kill", "=", "False", ",", "timeout", "=", "15", ")", ":", "super", "(", "AbstractDcsController", ",", "self", ")", ".", "stop", "(", "kill", "=", "kill", ",", "timeout", "=", "timeout", ")", "if", "self", ".", "_wo...
terminate process and wipe out the temp work directory, but only if we actually started it
[ "terminate", "process", "and", "wipe", "out", "the", "temp", "work", "directory", "but", "only", "if", "we", "actually", "started", "it" ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/features/environment.py#L343-L347
train
terminate process and wipe out the temp work directory
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
zalando/patroni
patroni/watchdog/linux.py
LinuxWatchdogDevice._ioctl
def _ioctl(self, func, arg): """Runs the specified ioctl on the underlying fd. Raises WatchdogError if the device is closed. Raises OSError or IOError (Python 2) when the ioctl fails.""" if self._fd is None: raise WatchdogError("Watchdog device is closed") if os.name...
python
def _ioctl(self, func, arg): """Runs the specified ioctl on the underlying fd. Raises WatchdogError if the device is closed. Raises OSError or IOError (Python 2) when the ioctl fails.""" if self._fd is None: raise WatchdogError("Watchdog device is closed") if os.name...
[ "def", "_ioctl", "(", "self", ",", "func", ",", "arg", ")", ":", "if", "self", ".", "_fd", "is", "None", ":", "raise", "WatchdogError", "(", "\"Watchdog device is closed\"", ")", "if", "os", ".", "name", "!=", "'nt'", ":", "import", "fcntl", "fcntl", "...
Runs the specified ioctl on the underlying fd. Raises WatchdogError if the device is closed. Raises OSError or IOError (Python 2) when the ioctl fails.
[ "Runs", "the", "specified", "ioctl", "on", "the", "underlying", "fd", "." ]
f6d29081c90af52064b981cdd877a07338d86038
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/watchdog/linux.py#L157-L166
train
Runs the specified ioctl on the underlying fd.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/helpers.py
json_safe
def json_safe(string, content_type='application/octet-stream'): """Returns JSON-safe version of `string`. If `string` is a Unicode string or a valid UTF-8, it is returned unmodified, as it can safely be encoded to JSON string. If `string` contains raw/binary data, it is Base64-encoded, formatted and ...
python
def json_safe(string, content_type='application/octet-stream'): """Returns JSON-safe version of `string`. If `string` is a Unicode string or a valid UTF-8, it is returned unmodified, as it can safely be encoded to JSON string. If `string` contains raw/binary data, it is Base64-encoded, formatted and ...
[ "def", "json_safe", "(", "string", ",", "content_type", "=", "'application/octet-stream'", ")", ":", "try", ":", "string", "=", "string", ".", "decode", "(", "'utf-8'", ")", "json", ".", "dumps", "(", "string", ")", "return", "string", "except", "(", "Valu...
Returns JSON-safe version of `string`. If `string` is a Unicode string or a valid UTF-8, it is returned unmodified, as it can safely be encoded to JSON string. If `string` contains raw/binary data, it is Base64-encoded, formatted and returned according to "data" URL scheme (RFC2397). Since JSON is not...
[ "Returns", "JSON", "-", "safe", "version", "of", "string", "." ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L85-L106
train
Returns JSON - safe version of string.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/helpers.py
get_files
def get_files(): """Returns files dict from request context.""" files = dict() for k, v in request.files.items(): content_type = request.files[k].content_type or 'application/octet-stream' val = json_safe(v.read(), content_type) if files.get(k): if not isinstance(files[...
python
def get_files(): """Returns files dict from request context.""" files = dict() for k, v in request.files.items(): content_type = request.files[k].content_type or 'application/octet-stream' val = json_safe(v.read(), content_type) if files.get(k): if not isinstance(files[...
[ "def", "get_files", "(", ")", ":", "files", "=", "dict", "(", ")", "for", "k", ",", "v", "in", "request", ".", "files", ".", "items", "(", ")", ":", "content_type", "=", "request", ".", "files", "[", "k", "]", ".", "content_type", "or", "'applicati...
Returns files dict from request context.
[ "Returns", "files", "dict", "from", "request", "context", "." ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L109-L124
train
Returns a dict of all the files in the current context.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/helpers.py
get_headers
def get_headers(hide_env=True): """Returns headers dict from request context.""" headers = dict(request.headers.items()) if hide_env and ('show_env' not in request.args): for key in ENV_HEADERS: try: del headers[key] except KeyError: pass ...
python
def get_headers(hide_env=True): """Returns headers dict from request context.""" headers = dict(request.headers.items()) if hide_env and ('show_env' not in request.args): for key in ENV_HEADERS: try: del headers[key] except KeyError: pass ...
[ "def", "get_headers", "(", "hide_env", "=", "True", ")", ":", "headers", "=", "dict", "(", "request", ".", "headers", ".", "items", "(", ")", ")", "if", "hide_env", "and", "(", "'show_env'", "not", "in", "request", ".", "args", ")", ":", "for", "key"...
Returns headers dict from request context.
[ "Returns", "headers", "dict", "from", "request", "context", "." ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L127-L139
train
Returns headers dict from request context.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/helpers.py
semiflatten
def semiflatten(multi): """Convert a MutiDict into a regular dict. If there are more than one value for a key, the result will have a list of values for the key. Otherwise it will have the plain value.""" if multi: result = multi.to_dict(flat=False) for k, v in result.items(): ...
python
def semiflatten(multi): """Convert a MutiDict into a regular dict. If there are more than one value for a key, the result will have a list of values for the key. Otherwise it will have the plain value.""" if multi: result = multi.to_dict(flat=False) for k, v in result.items(): ...
[ "def", "semiflatten", "(", "multi", ")", ":", "if", "multi", ":", "result", "=", "multi", ".", "to_dict", "(", "flat", "=", "False", ")", "for", "k", ",", "v", "in", "result", ".", "items", "(", ")", ":", "if", "len", "(", "v", ")", "==", "1", ...
Convert a MutiDict into a regular dict. If there are more than one value for a key, the result will have a list of values for the key. Otherwise it will have the plain value.
[ "Convert", "a", "MutiDict", "into", "a", "regular", "dict", ".", "If", "there", "are", "more", "than", "one", "value", "for", "a", "key", "the", "result", "will", "have", "a", "list", "of", "values", "for", "the", "key", ".", "Otherwise", "it", "will",...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L142-L153
train
Convert a MutiDict into a regular dict.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/helpers.py
get_url
def get_url(request): """ Since we might be hosted behind a proxy, we need to check the X-Forwarded-Proto, X-Forwarded-Protocol, or X-Forwarded-SSL headers to find out what protocol was used to access us. """ protocol = request.headers.get('X-Forwarded-Proto') or request.headers.get('X-Forwarded...
python
def get_url(request): """ Since we might be hosted behind a proxy, we need to check the X-Forwarded-Proto, X-Forwarded-Protocol, or X-Forwarded-SSL headers to find out what protocol was used to access us. """ protocol = request.headers.get('X-Forwarded-Proto') or request.headers.get('X-Forwarded...
[ "def", "get_url", "(", "request", ")", ":", "protocol", "=", "request", ".", "headers", ".", "get", "(", "'X-Forwarded-Proto'", ")", "or", "request", ".", "headers", ".", "get", "(", "'X-Forwarded-Protocol'", ")", "if", "protocol", "is", "None", "and", "re...
Since we might be hosted behind a proxy, we need to check the X-Forwarded-Proto, X-Forwarded-Protocol, or X-Forwarded-SSL headers to find out what protocol was used to access us.
[ "Since", "we", "might", "be", "hosted", "behind", "a", "proxy", "we", "need", "to", "check", "the", "X", "-", "Forwarded", "-", "Proto", "X", "-", "Forwarded", "-", "Protocol", "or", "X", "-", "Forwarded", "-", "SSL", "headers", "to", "find", "out", ...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L155-L168
train
Get the URL of the request.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/helpers.py
get_dict
def get_dict(*keys, **extras): """Returns request dict of given keys.""" _keys = ('url', 'args', 'form', 'data', 'origin', 'headers', 'files', 'json', 'method') assert all(map(_keys.__contains__, keys)) data = request.data form = semiflatten(request.form) try: _json = json.loads(data....
python
def get_dict(*keys, **extras): """Returns request dict of given keys.""" _keys = ('url', 'args', 'form', 'data', 'origin', 'headers', 'files', 'json', 'method') assert all(map(_keys.__contains__, keys)) data = request.data form = semiflatten(request.form) try: _json = json.loads(data....
[ "def", "get_dict", "(", "*", "keys", ",", "*", "*", "extras", ")", ":", "_keys", "=", "(", "'url'", ",", "'args'", ",", "'form'", ",", "'data'", ",", "'origin'", ",", "'headers'", ",", "'files'", ",", "'json'", ",", "'method'", ")", "assert", "all", ...
Returns request dict of given keys.
[ "Returns", "request", "dict", "of", "given", "keys", "." ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L171-L204
train
Returns request dict of given keys.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/helpers.py
status_code
def status_code(code): """Returns response object of given status code.""" redirect = dict(headers=dict(location=REDIRECT_LOCATION)) code_map = { 301: redirect, 302: redirect, 303: redirect, 304: dict(data=''), 305: redirect, 307: redirect, 401: dict...
python
def status_code(code): """Returns response object of given status code.""" redirect = dict(headers=dict(location=REDIRECT_LOCATION)) code_map = { 301: redirect, 302: redirect, 303: redirect, 304: dict(data=''), 305: redirect, 307: redirect, 401: dict...
[ "def", "status_code", "(", "code", ")", ":", "redirect", "=", "dict", "(", "headers", "=", "dict", "(", "location", "=", "REDIRECT_LOCATION", ")", ")", "code_map", "=", "{", "301", ":", "redirect", ",", "302", ":", "redirect", ",", "303", ":", "redirec...
Returns response object of given status code.
[ "Returns", "response", "object", "of", "given", "status", "code", "." ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L207-L255
train
Returns response object of given status code.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/helpers.py
check_basic_auth
def check_basic_auth(user, passwd): """Checks user authentication using HTTP Basic Auth.""" auth = request.authorization return auth and auth.username == user and auth.password == passwd
python
def check_basic_auth(user, passwd): """Checks user authentication using HTTP Basic Auth.""" auth = request.authorization return auth and auth.username == user and auth.password == passwd
[ "def", "check_basic_auth", "(", "user", ",", "passwd", ")", ":", "auth", "=", "request", ".", "authorization", "return", "auth", "and", "auth", ".", "username", "==", "user", "and", "auth", ".", "password", "==", "passwd" ]
Checks user authentication using HTTP Basic Auth.
[ "Checks", "user", "authentication", "using", "HTTP", "Basic", "Auth", "." ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L258-L262
train
Checks user authentication using HTTP Basic Auth.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/helpers.py
HA1
def HA1(realm, username, password, algorithm): """Create HA1 hash by realm, username, password HA1 = md5(A1) = MD5(username:realm:password) """ if not realm: realm = u'' return H(b":".join([username.encode('utf-8'), realm.encode('utf-8'), ...
python
def HA1(realm, username, password, algorithm): """Create HA1 hash by realm, username, password HA1 = md5(A1) = MD5(username:realm:password) """ if not realm: realm = u'' return H(b":".join([username.encode('utf-8'), realm.encode('utf-8'), ...
[ "def", "HA1", "(", "realm", ",", "username", ",", "password", ",", "algorithm", ")", ":", "if", "not", "realm", ":", "realm", "=", "u''", "return", "H", "(", "b\":\"", ".", "join", "(", "[", "username", ".", "encode", "(", "'utf-8'", ")", ",", "rea...
Create HA1 hash by realm, username, password HA1 = md5(A1) = MD5(username:realm:password)
[ "Create", "HA1", "hash", "by", "realm", "username", "password" ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L278-L287
train
Create HA1 hash by realm username password and algorithm
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/helpers.py
HA2
def HA2(credentials, request, algorithm): """Create HA2 md5 hash If the qop directive's value is "auth" or is unspecified, then HA2: HA2 = md5(A2) = MD5(method:digestURI) If the qop directive's value is "auth-int" , then HA2 is HA2 = md5(A2) = MD5(method:digestURI:MD5(entityBody)) """ ...
python
def HA2(credentials, request, algorithm): """Create HA2 md5 hash If the qop directive's value is "auth" or is unspecified, then HA2: HA2 = md5(A2) = MD5(method:digestURI) If the qop directive's value is "auth-int" , then HA2 is HA2 = md5(A2) = MD5(method:digestURI:MD5(entityBody)) """ ...
[ "def", "HA2", "(", "credentials", ",", "request", ",", "algorithm", ")", ":", "if", "credentials", ".", "get", "(", "\"qop\"", ")", "==", "\"auth\"", "or", "credentials", ".", "get", "(", "'qop'", ")", "is", "None", ":", "return", "H", "(", "b\":\"", ...
Create HA2 md5 hash If the qop directive's value is "auth" or is unspecified, then HA2: HA2 = md5(A2) = MD5(method:digestURI) If the qop directive's value is "auth-int" , then HA2 is HA2 = md5(A2) = MD5(method:digestURI:MD5(entityBody))
[ "Create", "HA2", "md5", "hash" ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L290-L308
train
Create HA2 md5 hash of the entity body.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/helpers.py
response
def response(credentials, password, request): """Compile digest auth response If the qop directive's value is "auth" or "auth-int" , then compute the response as follows: RESPONSE = MD5(HA1:nonce:nonceCount:clienNonce:qop:HA2) Else if the qop directive is unspecified, then compute the response as fo...
python
def response(credentials, password, request): """Compile digest auth response If the qop directive's value is "auth" or "auth-int" , then compute the response as follows: RESPONSE = MD5(HA1:nonce:nonceCount:clienNonce:qop:HA2) Else if the qop directive is unspecified, then compute the response as fo...
[ "def", "response", "(", "credentials", ",", "password", ",", "request", ")", ":", "response", "=", "None", "algorithm", "=", "credentials", ".", "get", "(", "'algorithm'", ")", "HA1_value", "=", "HA1", "(", "credentials", ".", "get", "(", "'realm'", ")", ...
Compile digest auth response If the qop directive's value is "auth" or "auth-int" , then compute the response as follows: RESPONSE = MD5(HA1:nonce:nonceCount:clienNonce:qop:HA2) Else if the qop directive is unspecified, then compute the response as follows: RESPONSE = MD5(HA1:nonce:HA2) Argu...
[ "Compile", "digest", "auth", "response" ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L311-L352
train
Compile digest auth response
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/helpers.py
check_digest_auth
def check_digest_auth(user, passwd): """Check user authentication using HTTP Digest auth""" if request.headers.get('Authorization'): credentials = parse_authorization_header(request.headers.get('Authorization')) if not credentials: return request_uri = request.script_root + ...
python
def check_digest_auth(user, passwd): """Check user authentication using HTTP Digest auth""" if request.headers.get('Authorization'): credentials = parse_authorization_header(request.headers.get('Authorization')) if not credentials: return request_uri = request.script_root + ...
[ "def", "check_digest_auth", "(", "user", ",", "passwd", ")", ":", "if", "request", ".", "headers", ".", "get", "(", "'Authorization'", ")", ":", "credentials", "=", "parse_authorization_header", "(", "request", ".", "headers", ".", "get", "(", "'Authorization'...
Check user authentication using HTTP Digest auth
[ "Check", "user", "authentication", "using", "HTTP", "Digest", "auth" ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L355-L370
train
Check user authentication using HTTP Digest auth
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/helpers.py
__parse_request_range
def __parse_request_range(range_header_text): """ Return a tuple describing the byte range requested in a GET request If the range is open ended on the left or right side, then a value of None will be set. RFC7233: http://svn.tools.ietf.org/svn/wg/httpbis/specs/rfc7233.html#header.range Examples: ...
python
def __parse_request_range(range_header_text): """ Return a tuple describing the byte range requested in a GET request If the range is open ended on the left or right side, then a value of None will be set. RFC7233: http://svn.tools.ietf.org/svn/wg/httpbis/specs/rfc7233.html#header.range Examples: ...
[ "def", "__parse_request_range", "(", "range_header_text", ")", ":", "left", "=", "None", "right", "=", "None", "if", "not", "range_header_text", ":", "return", "left", ",", "right", "range_header_text", "=", "range_header_text", ".", "strip", "(", ")", "if", "...
Return a tuple describing the byte range requested in a GET request If the range is open ended on the left or right side, then a value of None will be set. RFC7233: http://svn.tools.ietf.org/svn/wg/httpbis/specs/rfc7233.html#header.range Examples: Range : bytes=1024- Range : bytes=10-20 ...
[ "Return", "a", "tuple", "describing", "the", "byte", "range", "requested", "in", "a", "GET", "request", "If", "the", "range", "is", "open", "ended", "on", "the", "left", "or", "right", "side", "then", "a", "value", "of", "None", "will", "be", "set", "....
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L376-L413
train
Parse the range header text from a GET request.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/helpers.py
parse_multi_value_header
def parse_multi_value_header(header_str): """Break apart an HTTP header string that is potentially a quoted, comma separated list as used in entity headers in RFC2616.""" parsed_parts = [] if header_str: parts = header_str.split(',') for part in parts: match = re.search('\s*(W/)?...
python
def parse_multi_value_header(header_str): """Break apart an HTTP header string that is potentially a quoted, comma separated list as used in entity headers in RFC2616.""" parsed_parts = [] if header_str: parts = header_str.split(',') for part in parts: match = re.search('\s*(W/)?...
[ "def", "parse_multi_value_header", "(", "header_str", ")", ":", "parsed_parts", "=", "[", "]", "if", "header_str", ":", "parts", "=", "header_str", ".", "split", "(", "','", ")", "for", "part", "in", "parts", ":", "match", "=", "re", ".", "search", "(", ...
Break apart an HTTP header string that is potentially a quoted, comma separated list as used in entity headers in RFC2616.
[ "Break", "apart", "an", "HTTP", "header", "string", "that", "is", "potentially", "a", "quoted", "comma", "separated", "list", "as", "used", "in", "entity", "headers", "in", "RFC2616", "." ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/helpers.py#L432-L441
train
Break apart an HTTP header string that is potentially a quoted comma separated list as used in entity headers in RFC2616.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
redirect_n_times
def redirect_n_times(n): """302 Redirects n times. --- tags: - Redirects parameters: - in: path name: n type: int produces: - text/html responses: 302: description: A redirection. """ assert n > 0 absolute = request.args.get("absolute"...
python
def redirect_n_times(n): """302 Redirects n times. --- tags: - Redirects parameters: - in: path name: n type: int produces: - text/html responses: 302: description: A redirection. """ assert n > 0 absolute = request.args.get("absolute"...
[ "def", "redirect_n_times", "(", "n", ")", ":", "assert", "n", ">", "0", "absolute", "=", "request", ".", "args", ".", "get", "(", "\"absolute\"", ",", "\"false\"", ")", ".", "lower", "(", ")", "==", "\"true\"", "if", "n", "==", "1", ":", "return", ...
302 Redirects n times. --- tags: - Redirects parameters: - in: path name: n type: int produces: - text/html responses: 302: description: A redirection.
[ "302", "Redirects", "n", "times", ".", "---", "tags", ":", "-", "Redirects", "parameters", ":", "-", "in", ":", "path", "name", ":", "n", "type", ":", "int", "produces", ":", "-", "text", "/", "html", "responses", ":", "302", ":", "description", ":",...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L538-L563
train
A redirection for n times.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
redirect_to
def redirect_to(): """302/3XX Redirects to the given URL. --- tags: - Redirects produces: - text/html get: parameters: - in: query name: url type: string required: true - in: query name: status_code type: int pos...
python
def redirect_to(): """302/3XX Redirects to the given URL. --- tags: - Redirects produces: - text/html get: parameters: - in: query name: url type: string required: true - in: query name: status_code type: int pos...
[ "def", "redirect_to", "(", ")", ":", "args_dict", "=", "request", ".", "args", ".", "items", "(", ")", "args", "=", "CaseInsensitiveDict", "(", "args_dict", ")", "# We need to build the response manually and convert to UTF-8 to prevent", "# werkzeug from \"fixing\" the URL....
302/3XX Redirects to the given URL. --- tags: - Redirects produces: - text/html get: parameters: - in: query name: url type: string required: true - in: query name: status_code type: int post: consumes: ...
[ "302", "/", "3XX", "Redirects", "to", "the", "given", "URL", ".", "---", "tags", ":", "-", "Redirects", "produces", ":", "-", "text", "/", "html", "get", ":", "parameters", ":", "-", "in", ":", "query", "name", ":", "url", "type", ":", "string", "r...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L573-L644
train
A redirection to the given URL.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
relative_redirect_n_times
def relative_redirect_n_times(n): """Relatively 302 Redirects n times. --- tags: - Redirects parameters: - in: path name: n type: int produces: - text/html responses: 302: description: A redirection. """ assert n > 0 response = app.ma...
python
def relative_redirect_n_times(n): """Relatively 302 Redirects n times. --- tags: - Redirects parameters: - in: path name: n type: int produces: - text/html responses: 302: description: A redirection. """ assert n > 0 response = app.ma...
[ "def", "relative_redirect_n_times", "(", "n", ")", ":", "assert", "n", ">", "0", "response", "=", "app", ".", "make_response", "(", "\"\"", ")", "response", ".", "status_code", "=", "302", "if", "n", "==", "1", ":", "response", ".", "headers", "[", "\"...
Relatively 302 Redirects n times. --- tags: - Redirects parameters: - in: path name: n type: int produces: - text/html responses: 302: description: A redirection.
[ "Relatively", "302", "Redirects", "n", "times", ".", "---", "tags", ":", "-", "Redirects", "parameters", ":", "-", "in", ":", "path", "name", ":", "n", "type", ":", "int", "produces", ":", "-", "text", "/", "html", "responses", ":", "302", ":", "desc...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L648-L674
train
Relatively 302 Redirects n times.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
absolute_redirect_n_times
def absolute_redirect_n_times(n): """Absolutely 302 Redirects n times. --- tags: - Redirects parameters: - in: path name: n type: int produces: - text/html responses: 302: description: A redirection. """ assert n > 0 if n == 1: ...
python
def absolute_redirect_n_times(n): """Absolutely 302 Redirects n times. --- tags: - Redirects parameters: - in: path name: n type: int produces: - text/html responses: 302: description: A redirection. """ assert n > 0 if n == 1: ...
[ "def", "absolute_redirect_n_times", "(", "n", ")", ":", "assert", "n", ">", "0", "if", "n", "==", "1", ":", "return", "redirect", "(", "url_for", "(", "\"view_get\"", ",", "_external", "=", "True", ")", ")", "return", "_redirect", "(", "\"absolute\"", ",...
Absolutely 302 Redirects n times. --- tags: - Redirects parameters: - in: path name: n type: int produces: - text/html responses: 302: description: A redirection.
[ "Absolutely", "302", "Redirects", "n", "times", ".", "---", "tags", ":", "-", "Redirects", "parameters", ":", "-", "in", ":", "path", "name", ":", "n", "type", ":", "int", "produces", ":", "-", "text", "/", "html", "responses", ":", "302", ":", "desc...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L678-L699
train
Absolute redirection n times.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
stream_n_messages
def stream_n_messages(n): """Stream n JSON responses --- tags: - Dynamic data parameters: - in: path name: n type: int produces: - application/json responses: 200: description: Streamed JSON responses. """ response = get_dict("url", "args",...
python
def stream_n_messages(n): """Stream n JSON responses --- tags: - Dynamic data parameters: - in: path name: n type: int produces: - application/json responses: 200: description: Streamed JSON responses. """ response = get_dict("url", "args",...
[ "def", "stream_n_messages", "(", "n", ")", ":", "response", "=", "get_dict", "(", "\"url\"", ",", "\"args\"", ",", "\"headers\"", ",", "\"origin\"", ")", "n", "=", "min", "(", "n", ",", "100", ")", "def", "generate_stream", "(", ")", ":", "for", "i", ...
Stream n JSON responses --- tags: - Dynamic data parameters: - in: path name: n type: int produces: - application/json responses: 200: description: Streamed JSON responses.
[ "Stream", "n", "JSON", "responses", "---", "tags", ":", "-", "Dynamic", "data", "parameters", ":", "-", "in", ":", "path", "name", ":", "n", "type", ":", "int", "produces", ":", "-", "application", "/", "json", "responses", ":", "200", ":", "descriptio...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L703-L726
train
Stream n JSON responses.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
view_status_code
def view_status_code(codes): """Return status code or random status code if more than one are given --- tags: - Status codes parameters: - in: path name: codes produces: - text/plain responses: 100: description: Informational responses 200: d...
python
def view_status_code(codes): """Return status code or random status code if more than one are given --- tags: - Status codes parameters: - in: path name: codes produces: - text/plain responses: 100: description: Informational responses 200: d...
[ "def", "view_status_code", "(", "codes", ")", ":", "if", "\",\"", "not", "in", "codes", ":", "try", ":", "code", "=", "int", "(", "codes", ")", "except", "ValueError", ":", "return", "Response", "(", "\"Invalid status code\"", ",", "status", "=", "400", ...
Return status code or random status code if more than one are given --- tags: - Status codes parameters: - in: path name: codes produces: - text/plain responses: 100: description: Informational responses 200: description: Success 300: ...
[ "Return", "status", "code", "or", "random", "status", "code", "if", "more", "than", "one", "are", "given", "---", "tags", ":", "-", "Status", "codes", "parameters", ":", "-", "in", ":", "path", "name", ":", "codes", "produces", ":", "-", "text", "/", ...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L732-L777
train
View status code of a list of codes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
response_headers
def response_headers(): """Returns a set of response headers from the query string. --- tags: - Response inspection parameters: - in: query name: freeform explode: true allowEmptyValue: true schema: type: object additionalProperties: ...
python
def response_headers(): """Returns a set of response headers from the query string. --- tags: - Response inspection parameters: - in: query name: freeform explode: true allowEmptyValue: true schema: type: object additionalProperties: ...
[ "def", "response_headers", "(", ")", ":", "# Pending swaggerUI update", "# https://github.com/swagger-api/swagger-ui/issues/3850", "headers", "=", "MultiDict", "(", "request", ".", "args", ".", "items", "(", "multi", "=", "True", ")", ")", "response", "=", "jsonify", ...
Returns a set of response headers from the query string. --- tags: - Response inspection parameters: - in: query name: freeform explode: true allowEmptyValue: true schema: type: object additionalProperties: type: string styl...
[ "Returns", "a", "set", "of", "response", "headers", "from", "the", "query", "string", ".", "---", "tags", ":", "-", "Response", "inspection", "parameters", ":", "-", "in", ":", "query", "name", ":", "freeform", "explode", ":", "true", "allowEmptyValue", ":...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L781-L821
train
Returns a set of response headers from the query string.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
view_cookies
def view_cookies(hide_env=True): """Returns cookie data. --- tags: - Cookies produces: - application/json responses: 200: description: Set cookies. """ cookies = dict(request.cookies.items()) if hide_env and ("show_env" not in request.args): for key in...
python
def view_cookies(hide_env=True): """Returns cookie data. --- tags: - Cookies produces: - application/json responses: 200: description: Set cookies. """ cookies = dict(request.cookies.items()) if hide_env and ("show_env" not in request.args): for key in...
[ "def", "view_cookies", "(", "hide_env", "=", "True", ")", ":", "cookies", "=", "dict", "(", "request", ".", "cookies", ".", "items", "(", ")", ")", "if", "hide_env", "and", "(", "\"show_env\"", "not", "in", "request", ".", "args", ")", ":", "for", "k...
Returns cookie data. --- tags: - Cookies produces: - application/json responses: 200: description: Set cookies.
[ "Returns", "cookie", "data", ".", "---", "tags", ":", "-", "Cookies", "produces", ":", "-", "application", "/", "json", "responses", ":", "200", ":", "description", ":", "Set", "cookies", "." ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L825-L846
train
Returns a JSON response with cookies.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
set_cookie
def set_cookie(name, value): """Sets a cookie and redirects to cookie list. --- tags: - Cookies parameters: - in: path name: name type: string - in: path name: value type: string produces: - text/plain responses: 200: descript...
python
def set_cookie(name, value): """Sets a cookie and redirects to cookie list. --- tags: - Cookies parameters: - in: path name: name type: string - in: path name: value type: string produces: - text/plain responses: 200: descript...
[ "def", "set_cookie", "(", "name", ",", "value", ")", ":", "r", "=", "app", ".", "make_response", "(", "redirect", "(", "url_for", "(", "\"view_cookies\"", ")", ")", ")", "r", ".", "set_cookie", "(", "key", "=", "name", ",", "value", "=", "value", ","...
Sets a cookie and redirects to cookie list. --- tags: - Cookies parameters: - in: path name: name type: string - in: path name: value type: string produces: - text/plain responses: 200: description: Set cookies and redirects to co...
[ "Sets", "a", "cookie", "and", "redirects", "to", "cookie", "list", ".", "---", "tags", ":", "-", "Cookies", "parameters", ":", "-", "in", ":", "path", "name", ":", "name", "type", ":", "string", "-", "in", ":", "path", "name", ":", "value", "type", ...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L857-L879
train
Sets a cookie and redirects to cookie list.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
set_cookies
def set_cookies(): """Sets cookie(s) as provided by the query string and redirects to cookie list. --- tags: - Cookies parameters: - in: query name: freeform explode: true allowEmptyValue: true schema: type: object additionalProperties: ...
python
def set_cookies(): """Sets cookie(s) as provided by the query string and redirects to cookie list. --- tags: - Cookies parameters: - in: query name: freeform explode: true allowEmptyValue: true schema: type: object additionalProperties: ...
[ "def", "set_cookies", "(", ")", ":", "cookies", "=", "dict", "(", "request", ".", "args", ".", "items", "(", ")", ")", "r", "=", "app", ".", "make_response", "(", "redirect", "(", "url_for", "(", "\"view_cookies\"", ")", ")", ")", "for", "key", ",", ...
Sets cookie(s) as provided by the query string and redirects to cookie list. --- tags: - Cookies parameters: - in: query name: freeform explode: true allowEmptyValue: true schema: type: object additionalProperties: type: string ...
[ "Sets", "cookie", "(", "s", ")", "as", "provided", "by", "the", "query", "string", "and", "redirects", "to", "cookie", "list", ".", "---", "tags", ":", "-", "Cookies", "parameters", ":", "-", "in", ":", "query", "name", ":", "freeform", "explode", ":",...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L883-L910
train
Sets the cookies in the freeform_cookie list to the values provided by the query string and redirects to cookie list.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
delete_cookies
def delete_cookies(): """Deletes cookie(s) as provided by the query string and redirects to cookie list. --- tags: - Cookies parameters: - in: query name: freeform explode: true allowEmptyValue: true schema: type: object additionalPropertie...
python
def delete_cookies(): """Deletes cookie(s) as provided by the query string and redirects to cookie list. --- tags: - Cookies parameters: - in: query name: freeform explode: true allowEmptyValue: true schema: type: object additionalPropertie...
[ "def", "delete_cookies", "(", ")", ":", "cookies", "=", "dict", "(", "request", ".", "args", ".", "items", "(", ")", ")", "r", "=", "app", ".", "make_response", "(", "redirect", "(", "url_for", "(", "\"view_cookies\"", ")", ")", ")", "for", "key", ",...
Deletes cookie(s) as provided by the query string and redirects to cookie list. --- tags: - Cookies parameters: - in: query name: freeform explode: true allowEmptyValue: true schema: type: object additionalProperties: type: string ...
[ "Deletes", "cookie", "(", "s", ")", "as", "provided", "by", "the", "query", "string", "and", "redirects", "to", "cookie", "list", ".", "---", "tags", ":", "-", "Cookies", "parameters", ":", "-", "in", ":", "query", "name", ":", "freeform", "explode", "...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L914-L941
train
Deletes cookies as provided by the query string and redirects to cookie list.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
basic_auth
def basic_auth(user="user", passwd="passwd"): """Prompts the user for authorization using HTTP Basic Auth. --- tags: - Auth parameters: - in: path name: user type: string - in: path name: passwd type: string produces: - application/json res...
python
def basic_auth(user="user", passwd="passwd"): """Prompts the user for authorization using HTTP Basic Auth. --- tags: - Auth parameters: - in: path name: user type: string - in: path name: passwd type: string produces: - application/json res...
[ "def", "basic_auth", "(", "user", "=", "\"user\"", ",", "passwd", "=", "\"passwd\"", ")", ":", "if", "not", "check_basic_auth", "(", "user", ",", "passwd", ")", ":", "return", "status_code", "(", "401", ")", "return", "jsonify", "(", "authenticated", "=", ...
Prompts the user for authorization using HTTP Basic Auth. --- tags: - Auth parameters: - in: path name: user type: string - in: path name: passwd type: string produces: - application/json responses: 200: description: Sucessful aut...
[ "Prompts", "the", "user", "for", "authorization", "using", "HTTP", "Basic", "Auth", ".", "---", "tags", ":", "-", "Auth", "parameters", ":", "-", "in", ":", "path", "name", ":", "user", "type", ":", "string", "-", "in", ":", "path", "name", ":", "pas...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L945-L969
train
Prompts the user for authorization using HTTP Basic Auth.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
hidden_basic_auth
def hidden_basic_auth(user="user", passwd="passwd"): """Prompts the user for authorization using HTTP Basic Auth. --- tags: - Auth parameters: - in: path name: user type: string - in: path name: passwd type: string produces: - application/json ...
python
def hidden_basic_auth(user="user", passwd="passwd"): """Prompts the user for authorization using HTTP Basic Auth. --- tags: - Auth parameters: - in: path name: user type: string - in: path name: passwd type: string produces: - application/json ...
[ "def", "hidden_basic_auth", "(", "user", "=", "\"user\"", ",", "passwd", "=", "\"passwd\"", ")", ":", "if", "not", "check_basic_auth", "(", "user", ",", "passwd", ")", ":", "return", "status_code", "(", "404", ")", "return", "jsonify", "(", "authenticated", ...
Prompts the user for authorization using HTTP Basic Auth. --- tags: - Auth parameters: - in: path name: user type: string - in: path name: passwd type: string produces: - application/json responses: 200: description: Sucessful aut...
[ "Prompts", "the", "user", "for", "authorization", "using", "HTTP", "Basic", "Auth", ".", "---", "tags", ":", "-", "Auth", "parameters", ":", "-", "in", ":", "path", "name", ":", "user", "type", ":", "string", "-", "in", ":", "path", "name", ":", "pas...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L973-L996
train
Prompts the user for authorization using HTTP Basic Auth.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
bearer_auth
def bearer_auth(): """Prompts the user for authorization using bearer authentication. --- tags: - Auth parameters: - in: header name: Authorization schema: type: string produces: - application/json responses: 200: description: Sucessful a...
python
def bearer_auth(): """Prompts the user for authorization using bearer authentication. --- tags: - Auth parameters: - in: header name: Authorization schema: type: string produces: - application/json responses: 200: description: Sucessful a...
[ "def", "bearer_auth", "(", ")", ":", "authorization", "=", "request", ".", "headers", ".", "get", "(", "\"Authorization\"", ")", "if", "not", "(", "authorization", "and", "authorization", ".", "startswith", "(", "\"Bearer \"", ")", ")", ":", "response", "=",...
Prompts the user for authorization using bearer authentication. --- tags: - Auth parameters: - in: header name: Authorization schema: type: string produces: - application/json responses: 200: description: Sucessful authentication. 401: ...
[ "Prompts", "the", "user", "for", "authorization", "using", "bearer", "authentication", ".", "---", "tags", ":", "-", "Auth", "parameters", ":", "-", "in", ":", "header", "name", ":", "Authorization", "schema", ":", "type", ":", "string", "produces", ":", "...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L1000-L1027
train
Prompts the user for authorization using bearer authentication.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
digest_auth_nostale
def digest_auth_nostale(qop=None, user="user", passwd="passwd", algorithm="MD5"): """Prompts the user for authorization using Digest Auth + Algorithm. --- tags: - Auth parameters: - in: path name: qop type: string description: auth or auth-int - in: path ...
python
def digest_auth_nostale(qop=None, user="user", passwd="passwd", algorithm="MD5"): """Prompts the user for authorization using Digest Auth + Algorithm. --- tags: - Auth parameters: - in: path name: qop type: string description: auth or auth-int - in: path ...
[ "def", "digest_auth_nostale", "(", "qop", "=", "None", ",", "user", "=", "\"user\"", ",", "passwd", "=", "\"passwd\"", ",", "algorithm", "=", "\"MD5\"", ")", ":", "return", "digest_auth", "(", "qop", ",", "user", ",", "passwd", ",", "algorithm", ",", "\"...
Prompts the user for authorization using Digest Auth + Algorithm. --- tags: - Auth parameters: - in: path name: qop type: string description: auth or auth-int - in: path name: user type: string - in: path name: passwd type: stri...
[ "Prompts", "the", "user", "for", "authorization", "using", "Digest", "Auth", "+", "Algorithm", ".", "---", "tags", ":", "-", "Auth", "parameters", ":", "-", "in", ":", "path", "name", ":", "qop", "type", ":", "string", "description", ":", "auth", "or", ...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L1059-L1088
train
Prompts the user for authorization using Digest Auth + Algorithm.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
digest_auth
def digest_auth( qop=None, user="user", passwd="passwd", algorithm="MD5", stale_after="never" ): """Prompts the user for authorization using Digest Auth + Algorithm. allow settings the stale_after argument. --- tags: - Auth parameters: - in: path name: qop type: strin...
python
def digest_auth( qop=None, user="user", passwd="passwd", algorithm="MD5", stale_after="never" ): """Prompts the user for authorization using Digest Auth + Algorithm. allow settings the stale_after argument. --- tags: - Auth parameters: - in: path name: qop type: strin...
[ "def", "digest_auth", "(", "qop", "=", "None", ",", "user", "=", "\"user\"", ",", "passwd", "=", "\"passwd\"", ",", "algorithm", "=", "\"MD5\"", ",", "stale_after", "=", "\"never\"", ")", ":", "require_cookie_handling", "=", "request", ".", "args", ".", "g...
Prompts the user for authorization using Digest Auth + Algorithm. allow settings the stale_after argument. --- tags: - Auth parameters: - in: path name: qop type: string description: auth or auth-int - in: path name: user type: string - in:...
[ "Prompts", "the", "user", "for", "authorization", "using", "Digest", "Auth", "+", "Algorithm", ".", "allow", "settings", "the", "stale_after", "argument", ".", "---", "tags", ":", "-", "Auth", "parameters", ":", "-", "in", ":", "path", "name", ":", "qop", ...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L1092-L1192
train
Prompts the user for authorization using Digest Auth + Algorithm.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
delay_response
def delay_response(delay): """Returns a delayed response (max of 10 seconds). --- tags: - Dynamic data parameters: - in: path name: delay type: int produces: - application/json responses: 200: description: A delayed response. """ delay = mi...
python
def delay_response(delay): """Returns a delayed response (max of 10 seconds). --- tags: - Dynamic data parameters: - in: path name: delay type: int produces: - application/json responses: 200: description: A delayed response. """ delay = mi...
[ "def", "delay_response", "(", "delay", ")", ":", "delay", "=", "min", "(", "float", "(", "delay", ")", ",", "10", ")", "time", ".", "sleep", "(", "delay", ")", "return", "jsonify", "(", "get_dict", "(", "\"url\"", ",", "\"args\"", ",", "\"form\"", ",...
Returns a delayed response (max of 10 seconds). --- tags: - Dynamic data parameters: - in: path name: delay type: int produces: - application/json responses: 200: description: A delayed response.
[ "Returns", "a", "delayed", "response", "(", "max", "of", "10", "seconds", ")", ".", "---", "tags", ":", "-", "Dynamic", "data", "parameters", ":", "-", "in", ":", "path", "name", ":", "delay", "type", ":", "int", "produces", ":", "-", "application", ...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L1196-L1217
train
Returns a delayed response.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
drip
def drip(): """Drips data over a duration after an optional initial delay. --- tags: - Dynamic data parameters: - in: query name: duration type: number description: The amount of time (in seconds) over which to drip each byte default: 2 required: false...
python
def drip(): """Drips data over a duration after an optional initial delay. --- tags: - Dynamic data parameters: - in: query name: duration type: number description: The amount of time (in seconds) over which to drip each byte default: 2 required: false...
[ "def", "drip", "(", ")", ":", "args", "=", "CaseInsensitiveDict", "(", "request", ".", "args", ".", "items", "(", ")", ")", "duration", "=", "float", "(", "args", ".", "get", "(", "\"duration\"", ",", "2", ")", ")", "numbytes", "=", "min", "(", "in...
Drips data over a duration after an optional initial delay. --- tags: - Dynamic data parameters: - in: query name: duration type: number description: The amount of time (in seconds) over which to drip each byte default: 2 required: false - in: query ...
[ "Drips", "data", "over", "a", "duration", "after", "an", "optional", "initial", "delay", ".", "---", "tags", ":", "-", "Dynamic", "data", "parameters", ":", "-", "in", ":", "query", "name", ":", "duration", "type", ":", "number", "description", ":", "The...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L1221-L1287
train
Drips data over a duration after an optional initial delay.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
cache
def cache(): """Returns a 304 if an If-Modified-Since header or If-None-Match is present. Returns the same as a GET otherwise. --- tags: - Response inspection parameters: - in: header name: If-Modified-Since - in: header name: If-None-Match produces: - applica...
python
def cache(): """Returns a 304 if an If-Modified-Since header or If-None-Match is present. Returns the same as a GET otherwise. --- tags: - Response inspection parameters: - in: header name: If-Modified-Since - in: header name: If-None-Match produces: - applica...
[ "def", "cache", "(", ")", ":", "is_conditional", "=", "request", ".", "headers", ".", "get", "(", "\"If-Modified-Since\"", ")", "or", "request", ".", "headers", ".", "get", "(", "\"If-None-Match\"", ")", "if", "is_conditional", "is", "None", ":", "response",...
Returns a 304 if an If-Modified-Since header or If-None-Match is present. Returns the same as a GET otherwise. --- tags: - Response inspection parameters: - in: header name: If-Modified-Since - in: header name: If-None-Match produces: - application/json respon...
[ "Returns", "a", "304", "if", "an", "If", "-", "Modified", "-", "Since", "header", "or", "If", "-", "None", "-", "Match", "is", "present", ".", "Returns", "the", "same", "as", "a", "GET", "otherwise", ".", "---", "tags", ":", "-", "Response", "inspect...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L1315-L1344
train
Returns a 304 if an If - Modified - Since header or If - None - Match is present. Returns a GET otherwise.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
etag
def etag(etag): """Assumes the resource has the given etag and responds to If-None-Match and If-Match headers appropriately. --- tags: - Response inspection parameters: - in: header name: If-None-Match - in: header name: If-Match produces: - application/json ...
python
def etag(etag): """Assumes the resource has the given etag and responds to If-None-Match and If-Match headers appropriately. --- tags: - Response inspection parameters: - in: header name: If-None-Match - in: header name: If-Match produces: - application/json ...
[ "def", "etag", "(", "etag", ")", ":", "if_none_match", "=", "parse_multi_value_header", "(", "request", ".", "headers", ".", "get", "(", "\"If-None-Match\"", ")", ")", "if_match", "=", "parse_multi_value_header", "(", "request", ".", "headers", ".", "get", "("...
Assumes the resource has the given etag and responds to If-None-Match and If-Match headers appropriately. --- tags: - Response inspection parameters: - in: header name: If-None-Match - in: header name: If-Match produces: - application/json responses: 200...
[ "Assumes", "the", "resource", "has", "the", "given", "etag", "and", "responds", "to", "If", "-", "None", "-", "Match", "and", "If", "-", "Match", "headers", "appropriately", ".", "---", "tags", ":", "-", "Response", "inspection", "parameters", ":", "-", ...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L1348-L1382
train
Assumes the resource has the given etag and responds to If - None - Match and If - Match headers appropriately.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
random_bytes
def random_bytes(n): """Returns n random bytes generated with given seed --- tags: - Dynamic data parameters: - in: path name: n type: int produces: - application/octet-stream responses: 200: description: Bytes. """ n = min(n, 100 * 1024) ...
python
def random_bytes(n): """Returns n random bytes generated with given seed --- tags: - Dynamic data parameters: - in: path name: n type: int produces: - application/octet-stream responses: 200: description: Bytes. """ n = min(n, 100 * 1024) ...
[ "def", "random_bytes", "(", "n", ")", ":", "n", "=", "min", "(", "n", ",", "100", "*", "1024", ")", "# set 100KB limit", "params", "=", "CaseInsensitiveDict", "(", "request", ".", "args", ".", "items", "(", ")", ")", "if", "\"seed\"", "in", "params", ...
Returns n random bytes generated with given seed --- tags: - Dynamic data parameters: - in: path name: n type: int produces: - application/octet-stream responses: 200: description: Bytes.
[ "Returns", "n", "random", "bytes", "generated", "with", "given", "seed", "---", "tags", ":", "-", "Dynamic", "data", "parameters", ":", "-", "in", ":", "path", "name", ":", "n", "type", ":", "int", "produces", ":", "-", "application", "/", "octet", "-"...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L1423-L1450
train
Returns n random bytes generated with given seed
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
stream_random_bytes
def stream_random_bytes(n): """Streams n random bytes generated with given seed, at given chunk size per packet. --- tags: - Dynamic data parameters: - in: path name: n type: int produces: - application/octet-stream responses: 200: description: Byt...
python
def stream_random_bytes(n): """Streams n random bytes generated with given seed, at given chunk size per packet. --- tags: - Dynamic data parameters: - in: path name: n type: int produces: - application/octet-stream responses: 200: description: Byt...
[ "def", "stream_random_bytes", "(", "n", ")", ":", "n", "=", "min", "(", "n", ",", "100", "*", "1024", ")", "# set 100KB limit", "params", "=", "CaseInsensitiveDict", "(", "request", ".", "args", ".", "items", "(", ")", ")", "if", "\"seed\"", "in", "par...
Streams n random bytes generated with given seed, at given chunk size per packet. --- tags: - Dynamic data parameters: - in: path name: n type: int produces: - application/octet-stream responses: 200: description: Bytes.
[ "Streams", "n", "random", "bytes", "generated", "with", "given", "seed", "at", "given", "chunk", "size", "per", "packet", ".", "---", "tags", ":", "-", "Dynamic", "data", "parameters", ":", "-", "in", ":", "path", "name", ":", "n", "type", ":", "int", ...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L1454-L1494
train
Streams n random bytes generated with given seed at given chunk size per packet.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
range_request
def range_request(numbytes): """Streams n random bytes generated with given seed, at given chunk size per packet. --- tags: - Dynamic data parameters: - in: path name: numbytes type: int produces: - application/octet-stream responses: 200: descript...
python
def range_request(numbytes): """Streams n random bytes generated with given seed, at given chunk size per packet. --- tags: - Dynamic data parameters: - in: path name: numbytes type: int produces: - application/octet-stream responses: 200: descript...
[ "def", "range_request", "(", "numbytes", ")", ":", "if", "numbytes", "<=", "0", "or", "numbytes", ">", "(", "100", "*", "1024", ")", ":", "response", "=", "Response", "(", "headers", "=", "{", "\"ETag\"", ":", "\"range%d\"", "%", "numbytes", ",", "\"Ac...
Streams n random bytes generated with given seed, at given chunk size per packet. --- tags: - Dynamic data parameters: - in: path name: numbytes type: int produces: - application/octet-stream responses: 200: description: Bytes.
[ "Streams", "n", "random", "bytes", "generated", "with", "given", "seed", "at", "given", "chunk", "size", "per", "packet", ".", "---", "tags", ":", "-", "Dynamic", "data", "parameters", ":", "-", "in", ":", "path", "name", ":", "numbytes", "type", ":", ...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L1498-L1584
train
Streams n random bytes from given seed at given chunk size per packet.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
link_page
def link_page(n, offset): """Generate a page containing n links to other pages which do the same. --- tags: - Dynamic data parameters: - in: path name: n type: int - in: path name: offset type: int produces: - text/html responses: 200...
python
def link_page(n, offset): """Generate a page containing n links to other pages which do the same. --- tags: - Dynamic data parameters: - in: path name: n type: int - in: path name: offset type: int produces: - text/html responses: 200...
[ "def", "link_page", "(", "n", ",", "offset", ")", ":", "n", "=", "min", "(", "max", "(", "1", ",", "n", ")", ",", "200", ")", "# limit to between 1 and 200 links", "link", "=", "\"<a href='{0}'>{1}</a> \"", "html", "=", "[", "\"<html><head><title>Links</title>...
Generate a page containing n links to other pages which do the same. --- tags: - Dynamic data parameters: - in: path name: n type: int - in: path name: offset type: int produces: - text/html responses: 200: description: HTML links...
[ "Generate", "a", "page", "containing", "n", "links", "to", "other", "pages", "which", "do", "the", "same", ".", "---", "tags", ":", "-", "Dynamic", "data", "parameters", ":", "-", "in", ":", "path", "name", ":", "n", "type", ":", "int", "-", "in", ...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L1588-L1618
train
Generate a page containing n links to other pages which do the same.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/core.py
image
def image(): """Returns a simple image of the type suggest by the Accept header. --- tags: - Images produces: - image/webp - image/svg+xml - image/jpeg - image/png - image/* responses: 200: description: An image. """ headers = get_headers() ...
python
def image(): """Returns a simple image of the type suggest by the Accept header. --- tags: - Images produces: - image/webp - image/svg+xml - image/jpeg - image/png - image/* responses: 200: description: An image. """ headers = get_headers() ...
[ "def", "image", "(", ")", ":", "headers", "=", "get_headers", "(", ")", "if", "\"accept\"", "not", "in", "headers", ":", "return", "image_png", "(", ")", "# Default media type to png", "accept", "=", "headers", "[", "\"accept\"", "]", ".", "lower", "(", ")...
Returns a simple image of the type suggest by the Accept header. --- tags: - Images produces: - image/webp - image/svg+xml - image/jpeg - image/png - image/* responses: 200: description: An image.
[ "Returns", "a", "simple", "image", "of", "the", "type", "suggest", "by", "the", "Accept", "header", ".", "---", "tags", ":", "-", "Images", "produces", ":", "-", "image", "/", "webp", "-", "image", "/", "svg", "+", "xml", "-", "image", "/", "jpeg", ...
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/core.py#L1628-L1659
train
Returns a simple image of the type suggest by the Accept header.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/utils.py
weighted_choice
def weighted_choice(choices): """Returns a value from choices chosen by weighted random selection choices should be a list of (value, weight) tuples. eg. weighted_choice([('val1', 5), ('val2', 0.3), ('val3', 1)]) """ values, weights = zip(*choices) total = 0 cum_weights = [] for w in ...
python
def weighted_choice(choices): """Returns a value from choices chosen by weighted random selection choices should be a list of (value, weight) tuples. eg. weighted_choice([('val1', 5), ('val2', 0.3), ('val3', 1)]) """ values, weights = zip(*choices) total = 0 cum_weights = [] for w in ...
[ "def", "weighted_choice", "(", "choices", ")", ":", "values", ",", "weights", "=", "zip", "(", "*", "choices", ")", "total", "=", "0", "cum_weights", "=", "[", "]", "for", "w", "in", "weights", ":", "total", "+=", "w", "cum_weights", ".", "append", "...
Returns a value from choices chosen by weighted random selection choices should be a list of (value, weight) tuples. eg. weighted_choice([('val1', 5), ('val2', 0.3), ('val3', 1)])
[ "Returns", "a", "value", "from", "choices", "chosen", "by", "weighted", "random", "selection" ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/utils.py#L14-L30
train
Returns a value from choices chosen by weighted random selection choices should be a list of tuples.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/filters.py
x_runtime
def x_runtime(f, *args, **kwargs): """X-Runtime Flask Response Decorator.""" _t0 = now() r = f(*args, **kwargs) _t1 = now() r.headers['X-Runtime'] = '{0}s'.format(Decimal(str(_t1 - _t0))) return r
python
def x_runtime(f, *args, **kwargs): """X-Runtime Flask Response Decorator.""" _t0 = now() r = f(*args, **kwargs) _t1 = now() r.headers['X-Runtime'] = '{0}s'.format(Decimal(str(_t1 - _t0))) return r
[ "def", "x_runtime", "(", "f", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "_t0", "=", "now", "(", ")", "r", "=", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "_t1", "=", "now", "(", ")", "r", ".", "headers", "[", "'X-Runtim...
X-Runtime Flask Response Decorator.
[ "X", "-", "Runtime", "Flask", "Response", "Decorator", "." ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/filters.py#L27-L35
train
X - Runtime Flask Response Decorator.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/filters.py
gzip
def gzip(f, *args, **kwargs): """GZip Flask Response Decorator.""" data = f(*args, **kwargs) if isinstance(data, Response): content = data.data else: content = data gzip_buffer = BytesIO() gzip_file = gzip2.GzipFile( mode='wb', compresslevel=4, fileobj=...
python
def gzip(f, *args, **kwargs): """GZip Flask Response Decorator.""" data = f(*args, **kwargs) if isinstance(data, Response): content = data.data else: content = data gzip_buffer = BytesIO() gzip_file = gzip2.GzipFile( mode='wb', compresslevel=4, fileobj=...
[ "def", "gzip", "(", "f", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "data", "=", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "isinstance", "(", "data", ",", "Response", ")", ":", "content", "=", "data", ".", "data", "...
GZip Flask Response Decorator.
[ "GZip", "Flask", "Response", "Decorator", "." ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/filters.py#L39-L67
train
GZip Flask Response Decorator.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/filters.py
deflate
def deflate(f, *args, **kwargs): """Deflate Flask Response Decorator.""" data = f(*args, **kwargs) if isinstance(data, Response): content = data.data else: content = data deflater = zlib.compressobj() deflated_data = deflater.compress(content) deflated_data += deflater.flu...
python
def deflate(f, *args, **kwargs): """Deflate Flask Response Decorator.""" data = f(*args, **kwargs) if isinstance(data, Response): content = data.data else: content = data deflater = zlib.compressobj() deflated_data = deflater.compress(content) deflated_data += deflater.flu...
[ "def", "deflate", "(", "f", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "data", "=", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "isinstance", "(", "data", ",", "Response", ")", ":", "content", "=", "data", ".", "data", ...
Deflate Flask Response Decorator.
[ "Deflate", "Flask", "Response", "Decorator", "." ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/filters.py#L71-L92
train
Deflate Flask Response Decorator.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
postmanlabs/httpbin
httpbin/filters.py
brotli
def brotli(f, *args, **kwargs): """Brotli Flask Response Decorator""" data = f(*args, **kwargs) if isinstance(data, Response): content = data.data else: content = data deflated_data = _brotli.compress(content) if isinstance(data, Response): data.data = deflated_data ...
python
def brotli(f, *args, **kwargs): """Brotli Flask Response Decorator""" data = f(*args, **kwargs) if isinstance(data, Response): content = data.data else: content = data deflated_data = _brotli.compress(content) if isinstance(data, Response): data.data = deflated_data ...
[ "def", "brotli", "(", "f", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "data", "=", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "isinstance", "(", "data", ",", "Response", ")", ":", "content", "=", "data", ".", "data", ...
Brotli Flask Response Decorator
[ "Brotli", "Flask", "Response", "Decorator" ]
f8ec666b4d1b654e4ff6aedd356f510dcac09f83
https://github.com/postmanlabs/httpbin/blob/f8ec666b4d1b654e4ff6aedd356f510dcac09f83/httpbin/filters.py#L96-L115
train
Brotli Flask Response Decorator
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
google/jsonnet
setup.py
get_version
def get_version(): """ Parses the version out of libjsonnet.h """ with open(os.path.join(DIR, 'include/libjsonnet.h')) as f: for line in f: if '#define' in line and 'LIB_JSONNET_VERSION' in line: v_code = line.partition('LIB_JSONNET_VERSION')[2].strip('\n "') ...
python
def get_version(): """ Parses the version out of libjsonnet.h """ with open(os.path.join(DIR, 'include/libjsonnet.h')) as f: for line in f: if '#define' in line and 'LIB_JSONNET_VERSION' in line: v_code = line.partition('LIB_JSONNET_VERSION')[2].strip('\n "') ...
[ "def", "get_version", "(", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "DIR", ",", "'include/libjsonnet.h'", ")", ")", "as", "f", ":", "for", "line", "in", "f", ":", "if", "'#define'", "in", "line", "and", "'LIB_JSONNET_VERSION'...
Parses the version out of libjsonnet.h
[ "Parses", "the", "version", "out", "of", "libjsonnet", ".", "h" ]
c323f5ce5b8aa663585d23dc0fb94d4b166c6f16
https://github.com/google/jsonnet/blob/c323f5ce5b8aa663585d23dc0fb94d4b166c6f16/setup.py#L37-L47
train
Parses the version out of libjsonnet. h
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
google/jsonnet
case_studies/micromanage/micromanage.py
preprocess
def preprocess(config): """Return a copy of the config with ${-} handled.""" def aux(ctx, service_name, service): compiler, _ = get_compiler(config, service) r2 = compiler.preprocess(ctx, service_name, service) ctx = ctx + [service_name] for child_name, child in compiler.childre...
python
def preprocess(config): """Return a copy of the config with ${-} handled.""" def aux(ctx, service_name, service): compiler, _ = get_compiler(config, service) r2 = compiler.preprocess(ctx, service_name, service) ctx = ctx + [service_name] for child_name, child in compiler.childre...
[ "def", "preprocess", "(", "config", ")", ":", "def", "aux", "(", "ctx", ",", "service_name", ",", "service", ")", ":", "compiler", ",", "_", "=", "get_compiler", "(", "config", ",", "service", ")", "r2", "=", "compiler", ".", "preprocess", "(", "ctx", ...
Return a copy of the config with ${-} handled.
[ "Return", "a", "copy", "of", "the", "config", "with", "$", "{", "-", "}", "handled", "." ]
c323f5ce5b8aa663585d23dc0fb94d4b166c6f16
https://github.com/google/jsonnet/blob/c323f5ce5b8aa663585d23dc0fb94d4b166c6f16/case_studies/micromanage/micromanage.py#L152-L170
train
Return a copy of the config with ${ - handled.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
google/jsonnet
case_studies/micromanage/micromanage.py
get_build_artefacts
def get_build_artefacts(config): """Create all required build artefacts, modify config to refer to them.""" def aux(ctx, service_name, service): compiler, environment = get_compiler(config, service) new_service, service_barts = compiler.getBuildArtefacts(environment, ctx, service) ctx =...
python
def get_build_artefacts(config): """Create all required build artefacts, modify config to refer to them.""" def aux(ctx, service_name, service): compiler, environment = get_compiler(config, service) new_service, service_barts = compiler.getBuildArtefacts(environment, ctx, service) ctx =...
[ "def", "get_build_artefacts", "(", "config", ")", ":", "def", "aux", "(", "ctx", ",", "service_name", ",", "service", ")", ":", "compiler", ",", "environment", "=", "get_compiler", "(", "config", ",", "service", ")", "new_service", ",", "service_barts", "=",...
Create all required build artefacts, modify config to refer to them.
[ "Create", "all", "required", "build", "artefacts", "modify", "config", "to", "refer", "to", "them", "." ]
c323f5ce5b8aa663585d23dc0fb94d4b166c6f16
https://github.com/google/jsonnet/blob/c323f5ce5b8aa663585d23dc0fb94d4b166c6f16/case_studies/micromanage/micromanage.py#L173-L194
train
Create all required build artefacts modify config to refer to them.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/word2vec.py
KeyedVectors.load_word2vec_format
def load_word2vec_format( cls, fname, fvocab=None, binary=False, encoding='utf8', unicode_errors='strict', limit=None, datatype=REAL): """ Load the input-hidden weight matrix from the original C word2vec-tool...
python
def load_word2vec_format( cls, fname, fvocab=None, binary=False, encoding='utf8', unicode_errors='strict', limit=None, datatype=REAL): """ Load the input-hidden weight matrix from the original C word2vec-tool...
[ "def", "load_word2vec_format", "(", "cls", ",", "fname", ",", "fvocab", "=", "None", ",", "binary", "=", "False", ",", "encoding", "=", "'utf8'", ",", "unicode_errors", "=", "'strict'", ",", "limit", "=", "None", ",", "datatype", "=", "REAL", ")", ":", ...
Load the input-hidden weight matrix from the original C word2vec-tool format. Note that the information stored in the file is incomplete (the binary tree is missing), so while you can query for word similarity etc., you cannot continue training with a model loaded this way. `binary` is a...
[ "Load", "the", "input", "-", "hidden", "weight", "matrix", "from", "the", "original", "C", "word2vec", "-", "tool", "format", ".", "Note", "that", "the", "information", "stored", "in", "the", "file", "is", "incomplete", "(", "the", "binary", "tree", "is", ...
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/word2vec.py#L88-L214
train
Load the input - hidden weight matrix from the original word2vec - tool format.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/word2vec.py
KeyedVectors.word_vec
def word_vec(self, word, use_norm=False): """ Accept a single word as input. Returns the word's representations in vector space, as a 1D numpy array. If `use_norm` is True, returns the normalized word vector. Example:: >>> trained_model['office'] array([ -1.40...
python
def word_vec(self, word, use_norm=False): """ Accept a single word as input. Returns the word's representations in vector space, as a 1D numpy array. If `use_norm` is True, returns the normalized word vector. Example:: >>> trained_model['office'] array([ -1.40...
[ "def", "word_vec", "(", "self", ",", "word", ",", "use_norm", "=", "False", ")", ":", "if", "word", "in", "self", ".", "vocab", ":", "if", "use_norm", ":", "result", "=", "self", ".", "syn0norm", "[", "self", ".", "vocab", "[", "word", "]", ".", ...
Accept a single word as input. Returns the word's representations in vector space, as a 1D numpy array. If `use_norm` is True, returns the normalized word vector. Example:: >>> trained_model['office'] array([ -1.40128313e-02, ...])
[ "Accept", "a", "single", "word", "as", "input", ".", "Returns", "the", "word", "s", "representations", "in", "vector", "space", "as", "a", "1D", "numpy", "array", ".", "If", "use_norm", "is", "True", "returns", "the", "normalized", "word", "vector", ".", ...
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/word2vec.py#L216-L234
train
Accept a single word as input. Returns a 1D numpy array.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/word2vec.py
KeyedVectors.neighbours
def neighbours(self, word, size = 10): """ Get nearest words with KDTree, ranking by cosine distance """ word = word.strip() v = self.word_vec(word) [distances], [points] = self.kdt.query(array([v]), k = size, return_distance = True) assert len(distances) == len(p...
python
def neighbours(self, word, size = 10): """ Get nearest words with KDTree, ranking by cosine distance """ word = word.strip() v = self.word_vec(word) [distances], [points] = self.kdt.query(array([v]), k = size, return_distance = True) assert len(distances) == len(p...
[ "def", "neighbours", "(", "self", ",", "word", ",", "size", "=", "10", ")", ":", "word", "=", "word", ".", "strip", "(", ")", "v", "=", "self", ".", "word_vec", "(", "word", ")", "[", "distances", "]", ",", "[", "points", "]", "=", "self", ".",...
Get nearest words with KDTree, ranking by cosine distance
[ "Get", "nearest", "words", "with", "KDTree", "ranking", "by", "cosine", "distance" ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/word2vec.py#L236-L253
train
Get nearest words with KDTree ranking by cosine distance.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/utils.py
get_random_state
def get_random_state(seed): """ Turn seed into a np.random.RandomState instance. Method originally from maciejkula/glove-python, and written by @joshloyal. """ if seed is None or seed is np.random: return np.random.mtrand._rand if isinstance(seed, (numbers.Integral, np.integer)): ...
python
def get_random_state(seed): """ Turn seed into a np.random.RandomState instance. Method originally from maciejkula/glove-python, and written by @joshloyal. """ if seed is None or seed is np.random: return np.random.mtrand._rand if isinstance(seed, (numbers.Integral, np.integer)): ...
[ "def", "get_random_state", "(", "seed", ")", ":", "if", "seed", "is", "None", "or", "seed", "is", "np", ".", "random", ":", "return", "np", ".", "random", ".", "mtrand", ".", "_rand", "if", "isinstance", "(", "seed", ",", "(", "numbers", ".", "Integr...
Turn seed into a np.random.RandomState instance. Method originally from maciejkula/glove-python, and written by @joshloyal.
[ "Turn", "seed", "into", "a", "np", ".", "random", ".", "RandomState", "instance", ".", "Method", "originally", "from", "maciejkula", "/", "glove", "-", "python", "and", "written", "by" ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/utils.py#L91-L104
train
Turn seed into a np. random. RandomState instance.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/utils.py
file_or_filename
def file_or_filename(input): """ Return a file-like object ready to be read from the beginning. `input` is either a filename (gz/bz2 also supported) or a file-like object supporting seek. """ if isinstance(input, string_types): # input was a filename: open as file yield smart_open(i...
python
def file_or_filename(input): """ Return a file-like object ready to be read from the beginning. `input` is either a filename (gz/bz2 also supported) or a file-like object supporting seek. """ if isinstance(input, string_types): # input was a filename: open as file yield smart_open(i...
[ "def", "file_or_filename", "(", "input", ")", ":", "if", "isinstance", "(", "input", ",", "string_types", ")", ":", "# input was a filename: open as file", "yield", "smart_open", "(", "input", ")", "else", ":", "# input already a file-like object; just reset to the beginn...
Return a file-like object ready to be read from the beginning. `input` is either a filename (gz/bz2 also supported) or a file-like object supporting seek.
[ "Return", "a", "file", "-", "like", "object", "ready", "to", "be", "read", "from", "the", "beginning", ".", "input", "is", "either", "a", "filename", "(", "gz", "/", "bz2", "also", "supported", ")", "or", "a", "file", "-", "like", "object", "supporting...
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/utils.py#L125-L137
train
Yields a file - like object ready to be read from the beginning of the file.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/utils.py
deaccent
def deaccent(text): """ Remove accentuation from the given string. Input text is either a unicode string or utf8 encoded bytestring. Return input string with accents removed, as unicode. >>> deaccent("Šéf chomutovských komunistů dostal poštou bílý prášek") u'Sef chomutovskych komunistu dostal post...
python
def deaccent(text): """ Remove accentuation from the given string. Input text is either a unicode string or utf8 encoded bytestring. Return input string with accents removed, as unicode. >>> deaccent("Šéf chomutovských komunistů dostal poštou bílý prášek") u'Sef chomutovskych komunistu dostal post...
[ "def", "deaccent", "(", "text", ")", ":", "if", "not", "isinstance", "(", "text", ",", "unicode", ")", ":", "# assume utf8 for byte strings, use default (strict) error handling", "text", "=", "text", ".", "decode", "(", "'utf8'", ")", "norm", "=", "unicodedata", ...
Remove accentuation from the given string. Input text is either a unicode string or utf8 encoded bytestring. Return input string with accents removed, as unicode. >>> deaccent("Šéf chomutovských komunistů dostal poštou bílý prášek") u'Sef chomutovskych komunistu dostal postou bily prasek'
[ "Remove", "accentuation", "from", "the", "given", "string", ".", "Input", "text", "is", "either", "a", "unicode", "string", "or", "utf8", "encoded", "bytestring", "." ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/utils.py#L140-L155
train
Remove accentuation from the given string. Input text is either a unicode string or utf8 encoded bytestring. Returns input string with accents removed as unicode.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/utils.py
copytree_hardlink
def copytree_hardlink(source, dest): """ Recursively copy a directory ala shutils.copytree, but hardlink files instead of copying. Available on UNIX systems only. """ copy2 = shutil.copy2 try: shutil.copy2 = os.link shutil.copytree(source, dest) finally: shutil.copy2 ...
python
def copytree_hardlink(source, dest): """ Recursively copy a directory ala shutils.copytree, but hardlink files instead of copying. Available on UNIX systems only. """ copy2 = shutil.copy2 try: shutil.copy2 = os.link shutil.copytree(source, dest) finally: shutil.copy2 ...
[ "def", "copytree_hardlink", "(", "source", ",", "dest", ")", ":", "copy2", "=", "shutil", ".", "copy2", "try", ":", "shutil", ".", "copy2", "=", "os", ".", "link", "shutil", ".", "copytree", "(", "source", ",", "dest", ")", "finally", ":", "shutil", ...
Recursively copy a directory ala shutils.copytree, but hardlink files instead of copying. Available on UNIX systems only.
[ "Recursively", "copy", "a", "directory", "ala", "shutils", ".", "copytree", "but", "hardlink", "files", "instead", "of", "copying", ".", "Available", "on", "UNIX", "systems", "only", "." ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/utils.py#L158-L168
train
Recursively copy a directory ala shutils. copytree but hardlink files there.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/utils.py
tokenize
def tokenize( text, lowercase=False, deacc=False, encoding='utf8', errors="strict", to_lower=False, lower=False): """ Iteratively yield tokens as unicode strings, removing accent marks and optionally lowercasing the unidoce string by assigning True ...
python
def tokenize( text, lowercase=False, deacc=False, encoding='utf8', errors="strict", to_lower=False, lower=False): """ Iteratively yield tokens as unicode strings, removing accent marks and optionally lowercasing the unidoce string by assigning True ...
[ "def", "tokenize", "(", "text", ",", "lowercase", "=", "False", ",", "deacc", "=", "False", ",", "encoding", "=", "'utf8'", ",", "errors", "=", "\"strict\"", ",", "to_lower", "=", "False", ",", "lower", "=", "False", ")", ":", "lowercase", "=", "lowerc...
Iteratively yield tokens as unicode strings, removing accent marks and optionally lowercasing the unidoce string by assigning True to one of the parameters, lowercase, to_lower, or lower. Input text may be either unicode or utf8-encoded byte string. The tokens on output are maximal contiguous sequence...
[ "Iteratively", "yield", "tokens", "as", "unicode", "strings", "removing", "accent", "marks", "and", "optionally", "lowercasing", "the", "unidoce", "string", "by", "assigning", "True", "to", "one", "of", "the", "parameters", "lowercase", "to_lower", "or", "lower", ...
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/utils.py#L171-L199
train
Tokenize a string into a list of tokens.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/utils.py
simple_preprocess
def simple_preprocess(doc, deacc=False, min_len=2, max_len=15): """ Convert a document into a list of tokens. This lowercases, tokenizes, de-accents (optional). -- the output are final tokens = unicode strings, that won't be processed any further. """ tokens = [ token for token in toke...
python
def simple_preprocess(doc, deacc=False, min_len=2, max_len=15): """ Convert a document into a list of tokens. This lowercases, tokenizes, de-accents (optional). -- the output are final tokens = unicode strings, that won't be processed any further. """ tokens = [ token for token in toke...
[ "def", "simple_preprocess", "(", "doc", ",", "deacc", "=", "False", ",", "min_len", "=", "2", ",", "max_len", "=", "15", ")", ":", "tokens", "=", "[", "token", "for", "token", "in", "tokenize", "(", "doc", ",", "lower", "=", "True", ",", "deacc", "...
Convert a document into a list of tokens. This lowercases, tokenizes, de-accents (optional). -- the output are final tokens = unicode strings, that won't be processed any further.
[ "Convert", "a", "document", "into", "a", "list", "of", "tokens", "." ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/utils.py#L207-L219
train
Simple preprocessing function for the base class.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/utils.py
any2utf8
def any2utf8(text, errors='strict', encoding='utf8'): """Convert a string (unicode or bytestring in `encoding`), to bytestring in utf8.""" if isinstance(text, unicode): return text.encode('utf8') # do bytestring -> unicode -> utf8 full circle, to ensure valid utf8 return unicode(text, encoding, ...
python
def any2utf8(text, errors='strict', encoding='utf8'): """Convert a string (unicode or bytestring in `encoding`), to bytestring in utf8.""" if isinstance(text, unicode): return text.encode('utf8') # do bytestring -> unicode -> utf8 full circle, to ensure valid utf8 return unicode(text, encoding, ...
[ "def", "any2utf8", "(", "text", ",", "errors", "=", "'strict'", ",", "encoding", "=", "'utf8'", ")", ":", "if", "isinstance", "(", "text", ",", "unicode", ")", ":", "return", "text", ".", "encode", "(", "'utf8'", ")", "# do bytestring -> unicode -> utf8 full...
Convert a string (unicode or bytestring in `encoding`), to bytestring in utf8.
[ "Convert", "a", "string", "(", "unicode", "or", "bytestring", "in", "encoding", ")", "to", "bytestring", "in", "utf8", "." ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/utils.py#L222-L227
train
Convert a string to bytestring in utf8.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/utils.py
any2unicode
def any2unicode(text, encoding='utf8', errors='strict'): """Convert a string (bytestring in `encoding` or unicode), to unicode.""" if isinstance(text, unicode): return text return unicode(text, encoding, errors=errors)
python
def any2unicode(text, encoding='utf8', errors='strict'): """Convert a string (bytestring in `encoding` or unicode), to unicode.""" if isinstance(text, unicode): return text return unicode(text, encoding, errors=errors)
[ "def", "any2unicode", "(", "text", ",", "encoding", "=", "'utf8'", ",", "errors", "=", "'strict'", ")", ":", "if", "isinstance", "(", "text", ",", "unicode", ")", ":", "return", "text", "return", "unicode", "(", "text", ",", "encoding", ",", "errors", ...
Convert a string (bytestring in `encoding` or unicode), to unicode.
[ "Convert", "a", "string", "(", "bytestring", "in", "encoding", "or", "unicode", ")", "to", "unicode", "." ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/utils.py#L233-L237
train
Convert a string in encoding or unicode to unicode.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/utils.py
is_digit
def is_digit(obj): ''' Check if an object is Number ''' return isinstance(obj, (numbers.Integral, numbers.Complex, numbers.Real))
python
def is_digit(obj): ''' Check if an object is Number ''' return isinstance(obj, (numbers.Integral, numbers.Complex, numbers.Real))
[ "def", "is_digit", "(", "obj", ")", ":", "return", "isinstance", "(", "obj", ",", "(", "numbers", ".", "Integral", ",", "numbers", ".", "Complex", ",", "numbers", ".", "Real", ")", ")" ]
Check if an object is Number
[ "Check", "if", "an", "object", "is", "Number" ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/utils.py#L255-L259
train
Check if an object is a digit
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/utils.py
is_zh
def is_zh(ch): """return True if ch is Chinese character. full-width puncts/latins are not counted in. """ x = ord(ch) # CJK Radicals Supplement and Kangxi radicals if 0x2e80 <= x <= 0x2fef: return True # CJK Unified Ideographs Extension A elif 0x3400 <= x <= 0x4dbf: retu...
python
def is_zh(ch): """return True if ch is Chinese character. full-width puncts/latins are not counted in. """ x = ord(ch) # CJK Radicals Supplement and Kangxi radicals if 0x2e80 <= x <= 0x2fef: return True # CJK Unified Ideographs Extension A elif 0x3400 <= x <= 0x4dbf: retu...
[ "def", "is_zh", "(", "ch", ")", ":", "x", "=", "ord", "(", "ch", ")", "# CJK Radicals Supplement and Kangxi radicals", "if", "0x2e80", "<=", "x", "<=", "0x2fef", ":", "return", "True", "# CJK Unified Ideographs Extension A", "elif", "0x3400", "<=", "x", "<=", ...
return True if ch is Chinese character. full-width puncts/latins are not counted in.
[ "return", "True", "if", "ch", "is", "Chinese", "character", ".", "full", "-", "width", "puncts", "/", "latins", "are", "not", "counted", "in", "." ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/utils.py#L270-L291
train
Return True if ch is Chinese character.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/synonyms.py
_segment_words
def _segment_words(sen): ''' segment words with jieba ''' words, tags = [], [] m = _tokenizer.cut(sen, HMM=True) # HMM更好的识别新词 for x in m: words.append(x.word) tags.append(x.flag) return words, tags
python
def _segment_words(sen): ''' segment words with jieba ''' words, tags = [], [] m = _tokenizer.cut(sen, HMM=True) # HMM更好的识别新词 for x in m: words.append(x.word) tags.append(x.flag) return words, tags
[ "def", "_segment_words", "(", "sen", ")", ":", "words", ",", "tags", "=", "[", "]", ",", "[", "]", "m", "=", "_tokenizer", ".", "cut", "(", "sen", ",", "HMM", "=", "True", ")", "# HMM更好的识别新词", "for", "x", "in", "m", ":", "words", ".", "append", ...
segment words with jieba
[ "segment", "words", "with", "jieba" ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/synonyms.py#L107-L116
train
segment words with jieba
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/synonyms.py
_load_w2v
def _load_w2v(model_file=_f_model, binary=True): ''' load word2vec model ''' if not os.path.exists(model_file): print("os.path : ", os.path) raise Exception("Model file [%s] does not exist." % model_file) return KeyedVectors.load_word2vec_format( model_file, binary=binary, un...
python
def _load_w2v(model_file=_f_model, binary=True): ''' load word2vec model ''' if not os.path.exists(model_file): print("os.path : ", os.path) raise Exception("Model file [%s] does not exist." % model_file) return KeyedVectors.load_word2vec_format( model_file, binary=binary, un...
[ "def", "_load_w2v", "(", "model_file", "=", "_f_model", ",", "binary", "=", "True", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "model_file", ")", ":", "print", "(", "\"os.path : \"", ",", "os", ".", "path", ")", "raise", "Exception",...
load word2vec model
[ "load", "word2vec", "model" ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/synonyms.py#L125-L133
train
Load a word2vec model
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/synonyms.py
_get_wv
def _get_wv(sentence, ignore=False): ''' get word2vec data by sentence sentence is segmented string. ''' global _vectors vectors = [] for y in sentence: y_ = any2unicode(y).strip() if y_ not in _stopwords: syns = nearby(y_)[0] # print("sentence %s word...
python
def _get_wv(sentence, ignore=False): ''' get word2vec data by sentence sentence is segmented string. ''' global _vectors vectors = [] for y in sentence: y_ = any2unicode(y).strip() if y_ not in _stopwords: syns = nearby(y_)[0] # print("sentence %s word...
[ "def", "_get_wv", "(", "sentence", ",", "ignore", "=", "False", ")", ":", "global", "_vectors", "vectors", "=", "[", "]", "for", "y", "in", "sentence", ":", "y_", "=", "any2unicode", "(", "y", ")", ".", "strip", "(", ")", "if", "y_", "not", "in", ...
get word2vec data by sentence sentence is segmented string.
[ "get", "word2vec", "data", "by", "sentence", "sentence", "is", "segmented", "string", "." ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/synonyms.py#L137-L172
train
get word2vec data by sentence
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/synonyms.py
_levenshtein_distance
def _levenshtein_distance(sentence1, sentence2): ''' Return the Levenshtein distance between two strings. Based on: http://rosettacode.org/wiki/Levenshtein_distance#Python ''' first = any2utf8(sentence1).decode('utf-8', 'ignore') second = any2utf8(sentence2).decode('utf-8', 'ignore') ...
python
def _levenshtein_distance(sentence1, sentence2): ''' Return the Levenshtein distance between two strings. Based on: http://rosettacode.org/wiki/Levenshtein_distance#Python ''' first = any2utf8(sentence1).decode('utf-8', 'ignore') second = any2utf8(sentence2).decode('utf-8', 'ignore') ...
[ "def", "_levenshtein_distance", "(", "sentence1", ",", "sentence2", ")", ":", "first", "=", "any2utf8", "(", "sentence1", ")", ".", "decode", "(", "'utf-8'", ",", "'ignore'", ")", "second", "=", "any2utf8", "(", "sentence2", ")", ".", "decode", "(", "'utf-...
Return the Levenshtein distance between two strings. Based on: http://rosettacode.org/wiki/Levenshtein_distance#Python
[ "Return", "the", "Levenshtein", "distance", "between", "two", "strings", ".", "Based", "on", ":", "http", ":", "//", "rosettacode", ".", "org", "/", "wiki", "/", "Levenshtein_distance#Python" ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/synonyms.py#L178-L207
train
Return the Levenshtein distance between two strings.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/synonyms.py
_nearby_levenshtein_distance
def _nearby_levenshtein_distance(s1, s2): ''' 使用空间距离近的词汇优化编辑距离计算 ''' s1_len, s2_len = len(s1), len(s2) maxlen = s1_len if s1_len == s2_len: first, second = sorted([s1, s2]) elif s1_len < s2_len: first = s1 second = s2 maxlen = s2_len else: first = ...
python
def _nearby_levenshtein_distance(s1, s2): ''' 使用空间距离近的词汇优化编辑距离计算 ''' s1_len, s2_len = len(s1), len(s2) maxlen = s1_len if s1_len == s2_len: first, second = sorted([s1, s2]) elif s1_len < s2_len: first = s1 second = s2 maxlen = s2_len else: first = ...
[ "def", "_nearby_levenshtein_distance", "(", "s1", ",", "s2", ")", ":", "s1_len", ",", "s2_len", "=", "len", "(", "s1", ")", ",", "len", "(", "s2", ")", "maxlen", "=", "s1_len", "if", "s1_len", "==", "s2_len", ":", "first", ",", "second", "=", "sorted...
使用空间距离近的词汇优化编辑距离计算
[ "使用空间距离近的词汇优化编辑距离计算" ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/synonyms.py#L225-L254
train
Returns the Levenshtein distance between two words.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/synonyms.py
_similarity_distance
def _similarity_distance(s1, s2, ignore): ''' compute similarity with distance measurement ''' g = 0.0 try: g_ = cosine(_flat_sum_array(_get_wv(s1, ignore)), _flat_sum_array(_get_wv(s2, ignore))) if is_digit(g_): g = g_ except: pass u = _nearby_levenshtein_distance(s1, s2) ...
python
def _similarity_distance(s1, s2, ignore): ''' compute similarity with distance measurement ''' g = 0.0 try: g_ = cosine(_flat_sum_array(_get_wv(s1, ignore)), _flat_sum_array(_get_wv(s2, ignore))) if is_digit(g_): g = g_ except: pass u = _nearby_levenshtein_distance(s1, s2) ...
[ "def", "_similarity_distance", "(", "s1", ",", "s2", ",", "ignore", ")", ":", "g", "=", "0.0", "try", ":", "g_", "=", "cosine", "(", "_flat_sum_array", "(", "_get_wv", "(", "s1", ",", "ignore", ")", ")", ",", "_flat_sum_array", "(", "_get_wv", "(", "...
compute similarity with distance measurement
[ "compute", "similarity", "with", "distance", "measurement" ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/synonyms.py#L256-L283
train
compute similarity with distance measurement
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/synonyms.py
nearby
def nearby(word): ''' Nearby word ''' w = any2unicode(word) # read from cache if w in _cache_nearby: return _cache_nearby[w] words, scores = [], [] try: for x in _vectors.neighbours(w): words.append(x[0]) scores.append(x[1]) except: pass # ignore key ...
python
def nearby(word): ''' Nearby word ''' w = any2unicode(word) # read from cache if w in _cache_nearby: return _cache_nearby[w] words, scores = [], [] try: for x in _vectors.neighbours(w): words.append(x[0]) scores.append(x[1]) except: pass # ignore key ...
[ "def", "nearby", "(", "word", ")", ":", "w", "=", "any2unicode", "(", "word", ")", "# read from cache", "if", "w", "in", "_cache_nearby", ":", "return", "_cache_nearby", "[", "w", "]", "words", ",", "scores", "=", "[", "]", ",", "[", "]", "try", ":",...
Nearby word
[ "Nearby", "word" ]
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/synonyms.py#L290-L306
train
Return a list of words and scores for a given word.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
huyingxi/Synonyms
synonyms/synonyms.py
compare
def compare(s1, s2, seg=True, ignore=False, stopwords=False): ''' compare similarity s1 : sentence1 s2 : sentence2 seg : True : The original sentences need jieba.cut Flase : The original sentences have been cut. ignore: True: ignore OOV words False: get vector randomly for ...
python
def compare(s1, s2, seg=True, ignore=False, stopwords=False): ''' compare similarity s1 : sentence1 s2 : sentence2 seg : True : The original sentences need jieba.cut Flase : The original sentences have been cut. ignore: True: ignore OOV words False: get vector randomly for ...
[ "def", "compare", "(", "s1", ",", "s2", ",", "seg", "=", "True", ",", "ignore", "=", "False", ",", "stopwords", "=", "False", ")", ":", "if", "s1", "==", "s2", ":", "return", "1.0", "s1_words", "=", "[", "]", "s2_words", "=", "[", "]", "if", "s...
compare similarity s1 : sentence1 s2 : sentence2 seg : True : The original sentences need jieba.cut Flase : The original sentences have been cut. ignore: True: ignore OOV words False: get vector randomly for OOV words
[ "compare", "similarity", "s1", ":", "sentence1", "s2", ":", "sentence2", "seg", ":", "True", ":", "The", "original", "sentences", "need", "jieba", ".", "cut", "Flase", ":", "The", "original", "sentences", "have", "been", "cut", ".", "ignore", ":", "True", ...
fe7450d51d9ad825fdba86b9377da9dc76ae26a4
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/synonyms.py#L308-L344
train
compare two sentences
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/metrics_core.py
Metric.add_sample
def add_sample(self, name, labels, value, timestamp=None, exemplar=None): """Add a sample to the metric. Internal-only, do not use.""" self.samples.append(Sample(name, labels, value, timestamp, exemplar))
python
def add_sample(self, name, labels, value, timestamp=None, exemplar=None): """Add a sample to the metric. Internal-only, do not use.""" self.samples.append(Sample(name, labels, value, timestamp, exemplar))
[ "def", "add_sample", "(", "self", ",", "name", ",", "labels", ",", "value", ",", "timestamp", "=", "None", ",", "exemplar", "=", "None", ")", ":", "self", ".", "samples", ".", "append", "(", "Sample", "(", "name", ",", "labels", ",", "value", ",", ...
Add a sample to the metric. Internal-only, do not use.
[ "Add", "a", "sample", "to", "the", "metric", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/metrics_core.py#L38-L42
train
Add a sample to the metric.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/metrics_core.py
CounterMetricFamily.add_metric
def add_metric(self, labels, value, created=None, timestamp=None): """Add a metric to the metric family. Args: labels: A list of label values value: The value of the metric created: Optional unix timestamp the child was created at. """ self.samples.append(S...
python
def add_metric(self, labels, value, created=None, timestamp=None): """Add a metric to the metric family. Args: labels: A list of label values value: The value of the metric created: Optional unix timestamp the child was created at. """ self.samples.append(S...
[ "def", "add_metric", "(", "self", ",", "labels", ",", "value", ",", "created", "=", "None", ",", "timestamp", "=", "None", ")", ":", "self", ".", "samples", ".", "append", "(", "Sample", "(", "self", ".", "name", "+", "'_total'", ",", "dict", "(", ...
Add a metric to the metric family. Args: labels: A list of label values value: The value of the metric created: Optional unix timestamp the child was created at.
[ "Add", "a", "metric", "to", "the", "metric", "family", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/metrics_core.py#L109-L119
train
Adds a metric to the metric family.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/metrics_core.py
SummaryMetricFamily.add_metric
def add_metric(self, labels, count_value, sum_value, timestamp=None): """Add a metric to the metric family. Args: labels: A list of label values count_value: The count value of the metric. sum_value: The sum value of the metric. """ self.samples.append(Samp...
python
def add_metric(self, labels, count_value, sum_value, timestamp=None): """Add a metric to the metric family. Args: labels: A list of label values count_value: The count value of the metric. sum_value: The sum value of the metric. """ self.samples.append(Samp...
[ "def", "add_metric", "(", "self", ",", "labels", ",", "count_value", ",", "sum_value", ",", "timestamp", "=", "None", ")", ":", "self", ".", "samples", ".", "append", "(", "Sample", "(", "self", ".", "name", "+", "'_count'", ",", "dict", "(", "zip", ...
Add a metric to the metric family. Args: labels: A list of label values count_value: The count value of the metric. sum_value: The sum value of the metric.
[ "Add", "a", "metric", "to", "the", "metric", "family", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/metrics_core.py#L166-L175
train
Adds a metric to the metric family.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/metrics_core.py
HistogramMetricFamily.add_metric
def add_metric(self, labels, buckets, sum_value, timestamp=None): """Add a metric to the metric family. Args: labels: A list of label values buckets: A list of lists. Each inner list can be a pair of bucket name and value, or a triple of bucket name, valu...
python
def add_metric(self, labels, buckets, sum_value, timestamp=None): """Add a metric to the metric family. Args: labels: A list of label values buckets: A list of lists. Each inner list can be a pair of bucket name and value, or a triple of bucket name, valu...
[ "def", "add_metric", "(", "self", ",", "labels", ",", "buckets", ",", "sum_value", ",", "timestamp", "=", "None", ")", ":", "for", "b", "in", "buckets", ":", "bucket", ",", "value", "=", "b", "[", ":", "2", "]", "exemplar", "=", "None", "if", "len"...
Add a metric to the metric family. Args: labels: A list of label values buckets: A list of lists. Each inner list can be a pair of bucket name and value, or a triple of bucket name, value, and exemplar. The buckets must be sorted, and +Inf present. ...
[ "Add", "a", "metric", "to", "the", "metric", "family", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/metrics_core.py#L196-L223
train
Adds a metric to the metric family.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/metrics_core.py
GaugeHistogramMetricFamily.add_metric
def add_metric(self, labels, buckets, gsum_value, timestamp=None): """Add a metric to the metric family. Args: labels: A list of label values buckets: A list of pairs of bucket names and values. The buckets must be sorted, and +Inf present. gsum_value: The su...
python
def add_metric(self, labels, buckets, gsum_value, timestamp=None): """Add a metric to the metric family. Args: labels: A list of label values buckets: A list of pairs of bucket names and values. The buckets must be sorted, and +Inf present. gsum_value: The su...
[ "def", "add_metric", "(", "self", ",", "labels", ",", "buckets", ",", "gsum_value", ",", "timestamp", "=", "None", ")", ":", "for", "bucket", ",", "value", "in", "buckets", ":", "self", ".", "samples", ".", "append", "(", "Sample", "(", "self", ".", ...
Add a metric to the metric family. Args: labels: A list of label values buckets: A list of pairs of bucket names and values. The buckets must be sorted, and +Inf present. gsum_value: The sum value of the metric.
[ "Add", "a", "metric", "to", "the", "metric", "family", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/metrics_core.py#L242-L260
train
Adds a metric to the metric family.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/metrics_core.py
InfoMetricFamily.add_metric
def add_metric(self, labels, value, timestamp=None): """Add a metric to the metric family. Args: labels: A list of label values value: A dict of labels """ self.samples.append(Sample( self.name + '_info', dict(dict(zip(self._labelnames, labels...
python
def add_metric(self, labels, value, timestamp=None): """Add a metric to the metric family. Args: labels: A list of label values value: A dict of labels """ self.samples.append(Sample( self.name + '_info', dict(dict(zip(self._labelnames, labels...
[ "def", "add_metric", "(", "self", ",", "labels", ",", "value", ",", "timestamp", "=", "None", ")", ":", "self", ".", "samples", ".", "append", "(", "Sample", "(", "self", ".", "name", "+", "'_info'", ",", "dict", "(", "dict", "(", "zip", "(", "self...
Add a metric to the metric family. Args: labels: A list of label values value: A dict of labels
[ "Add", "a", "metric", "to", "the", "metric", "family", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/metrics_core.py#L279-L291
train
Adds a metric to the metric family.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/metrics_core.py
StateSetMetricFamily.add_metric
def add_metric(self, labels, value, timestamp=None): """Add a metric to the metric family. Args: labels: A list of label values value: A dict of string state names to booleans """ labels = tuple(labels) for state, enabled in sorted(value.items()): ...
python
def add_metric(self, labels, value, timestamp=None): """Add a metric to the metric family. Args: labels: A list of label values value: A dict of string state names to booleans """ labels = tuple(labels) for state, enabled in sorted(value.items()): ...
[ "def", "add_metric", "(", "self", ",", "labels", ",", "value", ",", "timestamp", "=", "None", ")", ":", "labels", "=", "tuple", "(", "labels", ")", "for", "state", ",", "enabled", "in", "sorted", "(", "value", ".", "items", "(", ")", ")", ":", "v",...
Add a metric to the metric family. Args: labels: A list of label values value: A dict of string state names to booleans
[ "Add", "a", "metric", "to", "the", "metric", "family", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/metrics_core.py#L310-L325
train
Adds a metric to the metric family.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...