repo
stringlengths
7
55
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
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
restran/mountains
mountains/encoding/converter.py
dec2str
def dec2str(n): """ decimal number to string. """ s = hex(int(n))[2:].rstrip('L') if len(s) % 2 != 0: s = '0' + s return hex2str(s)
python
def dec2str(n): """ decimal number to string. """ s = hex(int(n))[2:].rstrip('L') if len(s) % 2 != 0: s = '0' + s return hex2str(s)
[ "def", "dec2str", "(", "n", ")", ":", "s", "=", "hex", "(", "int", "(", "n", ")", ")", "[", "2", ":", "]", ".", "rstrip", "(", "'L'", ")", "if", "len", "(", "s", ")", "%", "2", "!=", "0", ":", "s", "=", "'0'", "+", "s", "return", "hex2s...
decimal number to string.
[ "decimal", "number", "to", "string", "." ]
a97fee568b112f4e10d878f815d0db3dd0a98d74
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/encoding/converter.py#L163-L170
train
Convert decimal number to string.
restran/mountains
mountains/encoding/converter.py
bin2str
def bin2str(b): """ Binary to string. """ ret = [] for pos in range(0, len(b), 8): ret.append(chr(int(b[pos:pos + 8], 2))) return ''.join(ret)
python
def bin2str(b): """ Binary to string. """ ret = [] for pos in range(0, len(b), 8): ret.append(chr(int(b[pos:pos + 8], 2))) return ''.join(ret)
[ "def", "bin2str", "(", "b", ")", ":", "ret", "=", "[", "]", "for", "pos", "in", "range", "(", "0", ",", "len", "(", "b", ")", ",", "8", ")", ":", "ret", ".", "append", "(", "chr", "(", "int", "(", "b", "[", "pos", ":", "pos", "+", "8", ...
Binary to string.
[ "Binary", "to", "string", "." ]
a97fee568b112f4e10d878f815d0db3dd0a98d74
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/encoding/converter.py#L183-L190
train
Binary to string.
restran/mountains
mountains/encoding/converter.py
to_digital
def to_digital(d, num): """ 进制转换,从10进制转到指定机制 :param d: :param num: :return: """ if not isinstance(num, int) or not 1 < num < 10: raise ValueError('digital num must between 1 and 10') d = int(d) result = [] x = d % num d = d - x result.append(str(x)) while d >...
python
def to_digital(d, num): """ 进制转换,从10进制转到指定机制 :param d: :param num: :return: """ if not isinstance(num, int) or not 1 < num < 10: raise ValueError('digital num must between 1 and 10') d = int(d) result = [] x = d % num d = d - x result.append(str(x)) while d >...
[ "def", "to_digital", "(", "d", ",", "num", ")", ":", "if", "not", "isinstance", "(", "num", ",", "int", ")", "or", "not", "1", "<", "num", "<", "10", ":", "raise", "ValueError", "(", "'digital num must between 1 and 10'", ")", "d", "=", "int", "(", "...
进制转换,从10进制转到指定机制 :param d: :param num: :return:
[ "进制转换,从10进制转到指定机制", ":", "param", "d", ":", ":", "param", "num", ":", ":", "return", ":" ]
a97fee568b112f4e10d878f815d0db3dd0a98d74
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/encoding/converter.py#L205-L225
train
Convert number to Digital
restran/mountains
mountains/encoding/converter.py
n2s
def n2s(n): """ Number to string. """ s = hex(n)[2:].rstrip("L") if len(s) % 2 != 0: s = "0" + s return s.decode("hex")
python
def n2s(n): """ Number to string. """ s = hex(n)[2:].rstrip("L") if len(s) % 2 != 0: s = "0" + s return s.decode("hex")
[ "def", "n2s", "(", "n", ")", ":", "s", "=", "hex", "(", "n", ")", "[", "2", ":", "]", ".", "rstrip", "(", "\"L\"", ")", "if", "len", "(", "s", ")", "%", "2", "!=", "0", ":", "s", "=", "\"0\"", "+", "s", "return", "s", ".", "decode", "("...
Number to string.
[ "Number", "to", "string", "." ]
a97fee568b112f4e10d878f815d0db3dd0a98d74
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/encoding/converter.py#L254-L261
train
Convert a number to a string.
restran/mountains
mountains/encoding/converter.py
s2b
def s2b(s): """ String to binary. """ ret = [] for c in s: ret.append(bin(ord(c))[2:].zfill(8)) return "".join(ret)
python
def s2b(s): """ String to binary. """ ret = [] for c in s: ret.append(bin(ord(c))[2:].zfill(8)) return "".join(ret)
[ "def", "s2b", "(", "s", ")", ":", "ret", "=", "[", "]", "for", "c", "in", "s", ":", "ret", ".", "append", "(", "bin", "(", "ord", "(", "c", ")", ")", "[", "2", ":", "]", ".", "zfill", "(", "8", ")", ")", "return", "\"\"", ".", "join", "...
String to binary.
[ "String", "to", "binary", "." ]
a97fee568b112f4e10d878f815d0db3dd0a98d74
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/encoding/converter.py#L264-L271
train
Convert a string to binary.
restran/mountains
mountains/encoding/converter.py
long_to_bytes
def long_to_bytes(n, blocksize=0): """Convert an integer to a byte string. In Python 3.2+, use the native method instead:: >>> n.to_bytes(blocksize, 'big') For instance:: >>> n = 80 >>> n.to_bytes(2, 'big') b'\x00P' If the optional :data:`blocksize` is provided and g...
python
def long_to_bytes(n, blocksize=0): """Convert an integer to a byte string. In Python 3.2+, use the native method instead:: >>> n.to_bytes(blocksize, 'big') For instance:: >>> n = 80 >>> n.to_bytes(2, 'big') b'\x00P' If the optional :data:`blocksize` is provided and g...
[ "def", "long_to_bytes", "(", "n", ",", "blocksize", "=", "0", ")", ":", "# after much testing, this algorithm was deemed to be the fastest", "s", "=", "b''", "n", "=", "int", "(", "n", ")", "pack", "=", "struct", ".", "pack", "while", "n", ">", "0", ":", "...
Convert an integer to a byte string. In Python 3.2+, use the native method instead:: >>> n.to_bytes(blocksize, 'big') For instance:: >>> n = 80 >>> n.to_bytes(2, 'big') b'\x00P' If the optional :data:`blocksize` is provided and greater than zero, the byte string is p...
[ "Convert", "an", "integer", "to", "a", "byte", "string", "." ]
a97fee568b112f4e10d878f815d0db3dd0a98d74
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/encoding/converter.py#L287-L327
train
Convert an integer to a byte string.
restran/mountains
mountains/encoding/converter.py
bytes_to_long
def bytes_to_long(s): """Convert a byte string to a long integer (big endian). In Python 3.2+, use the native method instead:: >>> int.from_bytes(s, 'big') For instance:: >>> int.from_bytes(b'\x00P', 'big') 80 This is (essentially) the inverse of :func:`long_to_bytes`. "...
python
def bytes_to_long(s): """Convert a byte string to a long integer (big endian). In Python 3.2+, use the native method instead:: >>> int.from_bytes(s, 'big') For instance:: >>> int.from_bytes(b'\x00P', 'big') 80 This is (essentially) the inverse of :func:`long_to_bytes`. "...
[ "def", "bytes_to_long", "(", "s", ")", ":", "acc", "=", "0", "unpack", "=", "struct", ".", "unpack", "length", "=", "len", "(", "s", ")", "if", "length", "%", "4", ":", "extra", "=", "(", "4", "-", "length", "%", "4", ")", "s", "=", "b'\\000'",...
Convert a byte string to a long integer (big endian). In Python 3.2+, use the native method instead:: >>> int.from_bytes(s, 'big') For instance:: >>> int.from_bytes(b'\x00P', 'big') 80 This is (essentially) the inverse of :func:`long_to_bytes`.
[ "Convert", "a", "byte", "string", "to", "a", "long", "integer", "(", "big", "endian", ")", "." ]
a97fee568b112f4e10d878f815d0db3dd0a98d74
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/encoding/converter.py#L330-L353
train
Convert a byte string to a long integer.
restran/mountains
mountains/ssh/__init__.py
SSHClient.run_expect_command
def run_expect_command(self, cmd, expect_end=None, timeout=3, wait_seconds=2): """ 执行 shell 命令并获取返回结果 :param timeout: :param wait_seconds: :param cmd: :param expect_end: :return: """ shell = self.ssh_session.invoke_shell() last_time = int(t...
python
def run_expect_command(self, cmd, expect_end=None, timeout=3, wait_seconds=2): """ 执行 shell 命令并获取返回结果 :param timeout: :param wait_seconds: :param cmd: :param expect_end: :return: """ shell = self.ssh_session.invoke_shell() last_time = int(t...
[ "def", "run_expect_command", "(", "self", ",", "cmd", ",", "expect_end", "=", "None", ",", "timeout", "=", "3", ",", "wait_seconds", "=", "2", ")", ":", "shell", "=", "self", ".", "ssh_session", ".", "invoke_shell", "(", ")", "last_time", "=", "int", "...
执行 shell 命令并获取返回结果 :param timeout: :param wait_seconds: :param cmd: :param expect_end: :return:
[ "执行", "shell", "命令并获取返回结果", ":", "param", "timeout", ":", ":", "param", "wait_seconds", ":", ":", "param", "cmd", ":", ":", "param", "expect_end", ":", ":", "return", ":" ]
a97fee568b112f4e10d878f815d0db3dd0a98d74
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/ssh/__init__.py#L86-L121
train
run command and return response
restran/mountains
mountains/ssh/__init__.py
SSHClient.run_nohup
def run_nohup(self, cmd, working_dir=None): """ :param cmd: :param working_dir: 当前的工作目录,如果没有 home 目录,会因为一些原因导致运行失败,比如没有无法创建 nohup.out :return: """ cmd = 'nohup %s &\n\n' % cmd if working_dir is not None: cmd = 'cd {}; {}'.format(working_dir, cmd) ...
python
def run_nohup(self, cmd, working_dir=None): """ :param cmd: :param working_dir: 当前的工作目录,如果没有 home 目录,会因为一些原因导致运行失败,比如没有无法创建 nohup.out :return: """ cmd = 'nohup %s &\n\n' % cmd if working_dir is not None: cmd = 'cd {}; {}'.format(working_dir, cmd) ...
[ "def", "run_nohup", "(", "self", ",", "cmd", ",", "working_dir", "=", "None", ")", ":", "cmd", "=", "'nohup %s &\\n\\n'", "%", "cmd", "if", "working_dir", "is", "not", "None", ":", "cmd", "=", "'cd {}; {}'", ".", "format", "(", "working_dir", ",", "cmd",...
:param cmd: :param working_dir: 当前的工作目录,如果没有 home 目录,会因为一些原因导致运行失败,比如没有无法创建 nohup.out :return:
[ ":", "param", "cmd", ":", ":", "param", "working_dir", ":", "当前的工作目录,如果没有", "home", "目录,会因为一些原因导致运行失败,比如没有无法创建", "nohup", ".", "out", ":", "return", ":" ]
a97fee568b112f4e10d878f815d0db3dd0a98d74
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/ssh/__init__.py#L123-L133
train
run nohup command
restran/mountains
mountains/ssh/__init__.py
SSHClient.check_sudo
def check_sudo(self): """ TODO 有问题 :return: """ stdin, stdout, stderr = self.ssh_session.exec_command('sudo whoami') stdin.write("%s\n" % self.password) stdin.write("\n\n\n\n\n\n\n\n") stdout.read() error_message = stderr.read()[:-1] if b"n...
python
def check_sudo(self): """ TODO 有问题 :return: """ stdin, stdout, stderr = self.ssh_session.exec_command('sudo whoami') stdin.write("%s\n" % self.password) stdin.write("\n\n\n\n\n\n\n\n") stdout.read() error_message = stderr.read()[:-1] if b"n...
[ "def", "check_sudo", "(", "self", ")", ":", "stdin", ",", "stdout", ",", "stderr", "=", "self", ".", "ssh_session", ".", "exec_command", "(", "'sudo whoami'", ")", "stdin", ".", "write", "(", "\"%s\\n\"", "%", "self", ".", "password", ")", "stdin", ".", ...
TODO 有问题 :return:
[ "TODO", "有问题", ":", "return", ":" ]
a97fee568b112f4e10d878f815d0db3dd0a98d74
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/ssh/__init__.py#L139-L154
train
check if user is in sudoers file
restran/mountains
mountains/ssh/__init__.py
SSHClient.get
def get(self, remote_file, local_file): """ 下载文件 :param remote_file: :param local_file: :return: """ sftp = self.get_sftp() try: sftp.get(remote_file, local_file) except Exception as e: logger.error('下载文件失败') log...
python
def get(self, remote_file, local_file): """ 下载文件 :param remote_file: :param local_file: :return: """ sftp = self.get_sftp() try: sftp.get(remote_file, local_file) except Exception as e: logger.error('下载文件失败') log...
[ "def", "get", "(", "self", ",", "remote_file", ",", "local_file", ")", ":", "sftp", "=", "self", ".", "get_sftp", "(", ")", "try", ":", "sftp", ".", "get", "(", "remote_file", ",", "local_file", ")", "except", "Exception", "as", "e", ":", "logger", "...
下载文件 :param remote_file: :param local_file: :return:
[ "下载文件", ":", "param", "remote_file", ":", ":", "param", "local_file", ":", ":", "return", ":" ]
a97fee568b112f4e10d878f815d0db3dd0a98d74
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/ssh/__init__.py#L219-L232
train
Get a key from the cache
restran/mountains
mountains/decorator/__init__.py
log
def log(func): """ 打印函数运行日志的装饰器 :param func: :return: """ # wraps 这个装饰器会将 func 的 doc 和 __name__ 复制过来 # 否则在 wrapper 中调用 func.__name__ 输出的就是 wrapper @wraps(func) def wrapper(*args, **kwargs): print('before call %s' % func.__name__) ret = func(*args, **kwargs) p...
python
def log(func): """ 打印函数运行日志的装饰器 :param func: :return: """ # wraps 这个装饰器会将 func 的 doc 和 __name__ 复制过来 # 否则在 wrapper 中调用 func.__name__ 输出的就是 wrapper @wraps(func) def wrapper(*args, **kwargs): print('before call %s' % func.__name__) ret = func(*args, **kwargs) p...
[ "def", "log", "(", "func", ")", ":", "# wraps 这个装饰器会将 func 的 doc 和 __name__ 复制过来", "# 否则在 wrapper 中调用 func.__name__ 输出的就是 wrapper", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "print", "(", "'before call %...
打印函数运行日志的装饰器 :param func: :return:
[ "打印函数运行日志的装饰器", ":", "param", "func", ":", ":", "return", ":" ]
a97fee568b112f4e10d878f815d0db3dd0a98d74
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/decorator/__init__.py#L11-L27
train
log - 发送函数运行日志
restran/mountains
mountains/decorator/__init__.py
log_with_message
def log_with_message(message): """ 打印函数运行日志的装饰器,可以再给装饰器传参数 :param message: :return: """ def decorator(func): @wraps(func) def wrapper(*args, **kwargs): print('decorator log_with_message is running, %s' % message) ret = func(*args, **kwargs) re...
python
def log_with_message(message): """ 打印函数运行日志的装饰器,可以再给装饰器传参数 :param message: :return: """ def decorator(func): @wraps(func) def wrapper(*args, **kwargs): print('decorator log_with_message is running, %s' % message) ret = func(*args, **kwargs) re...
[ "def", "log_with_message", "(", "message", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "print", "(", "'decorator log_with_message is running, %s...
打印函数运行日志的装饰器,可以再给装饰器传参数 :param message: :return:
[ "打印函数运行日志的装饰器,可以再给装饰器传参数", ":", "param", "message", ":", ":", "return", ":" ]
a97fee568b112f4e10d878f815d0db3dd0a98d74
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/decorator/__init__.py#L30-L46
train
log_with_message - log a message
restran/mountains
mountains/decorator/__init__.py
time_elapsed
def time_elapsed(func): """ 记录函数运行耗时的生成器 :param func: :return: """ @wraps(func) def wrapper(*args, **kwargs): timestamp = time.time() * 1000 ret = func(*args, **kwargs) now_ts = time.time() * 1000 elapsed = now_ts - timestamp print('%s costs time: %.2...
python
def time_elapsed(func): """ 记录函数运行耗时的生成器 :param func: :return: """ @wraps(func) def wrapper(*args, **kwargs): timestamp = time.time() * 1000 ret = func(*args, **kwargs) now_ts = time.time() * 1000 elapsed = now_ts - timestamp print('%s costs time: %.2...
[ "def", "time_elapsed", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "timestamp", "=", "time", ".", "time", "(", ")", "*", "1000", "ret", "=", "func", "(", "*", "ar...
记录函数运行耗时的生成器 :param func: :return:
[ "记录函数运行耗时的生成器", ":", "param", "func", ":", ":", "return", ":" ]
a97fee568b112f4e10d878f815d0db3dd0a98d74
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/decorator/__init__.py#L49-L65
train
Decorator to print elapsed time of a function
kytos/kytos-utils
kytos/utils/client.py
CommonClient.make_request
def make_request(endpoint, **kwargs): """Send a request to server.""" data = kwargs.get('json', []) package = kwargs.get('package', None) method = kwargs.get('method', 'GET') function = getattr(requests, method.lower()) try: if package: respo...
python
def make_request(endpoint, **kwargs): """Send a request to server.""" data = kwargs.get('json', []) package = kwargs.get('package', None) method = kwargs.get('method', 'GET') function = getattr(requests, method.lower()) try: if package: respo...
[ "def", "make_request", "(", "endpoint", ",", "*", "*", "kwargs", ")", ":", "data", "=", "kwargs", ".", "get", "(", "'json'", ",", "[", "]", ")", "package", "=", "kwargs", ".", "get", "(", "'package'", ",", "None", ")", "method", "=", "kwargs", ".",...
Send a request to server.
[ "Send", "a", "request", "to", "server", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/client.py#L33-L51
train
Send a request to server.
kytos/kytos-utils
kytos/utils/client.py
NAppsClient.get_napps
def get_napps(self): """Get all NApps from the server.""" endpoint = os.path.join(self._config.get('napps', 'api'), 'napps', '') res = self.make_request(endpoint) if res.status_code != 200: msg = 'Error getting NApps from server (%s) - %s' LOG.error(msg, res.stat...
python
def get_napps(self): """Get all NApps from the server.""" endpoint = os.path.join(self._config.get('napps', 'api'), 'napps', '') res = self.make_request(endpoint) if res.status_code != 200: msg = 'Error getting NApps from server (%s) - %s' LOG.error(msg, res.stat...
[ "def", "get_napps", "(", "self", ")", ":", "endpoint", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_config", ".", "get", "(", "'napps'", ",", "'api'", ")", ",", "'napps'", ",", "''", ")", "res", "=", "self", ".", "make_request", "(", ...
Get all NApps from the server.
[ "Get", "all", "NApps", "from", "the", "server", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/client.py#L57-L67
train
Get all NApps from the server.
kytos/kytos-utils
kytos/utils/client.py
NAppsClient.get_napp
def get_napp(self, username, name): """Return napp metadata or None if not found.""" endpoint = os.path.join(self._config.get('napps', 'api'), 'napps', username, name, '') res = self.make_request(endpoint) if res.status_code == 404: # We need to know if N...
python
def get_napp(self, username, name): """Return napp metadata or None if not found.""" endpoint = os.path.join(self._config.get('napps', 'api'), 'napps', username, name, '') res = self.make_request(endpoint) if res.status_code == 404: # We need to know if N...
[ "def", "get_napp", "(", "self", ",", "username", ",", "name", ")", ":", "endpoint", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_config", ".", "get", "(", "'napps'", ",", "'api'", ")", ",", "'napps'", ",", "username", ",", "name", ",", ...
Return napp metadata or None if not found.
[ "Return", "napp", "metadata", "or", "None", "if", "not", "found", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/client.py#L69-L80
train
Get napp metadata or None if not found.
kytos/kytos-utils
kytos/utils/client.py
NAppsClient.reload_napps
def reload_napps(self, napps=None): """Reload a specific NApp or all Napps. Args: napp (list): NApp list to be reload. Raises: requests.HTTPError: When there's a server error. """ if napps is None: napps = [] api = self._config.ge...
python
def reload_napps(self, napps=None): """Reload a specific NApp or all Napps. Args: napp (list): NApp list to be reload. Raises: requests.HTTPError: When there's a server error. """ if napps is None: napps = [] api = self._config.ge...
[ "def", "reload_napps", "(", "self", ",", "napps", "=", "None", ")", ":", "if", "napps", "is", "None", ":", "napps", "=", "[", "]", "api", "=", "self", ".", "_config", ".", "get", "(", "'kytos'", ",", "'api'", ")", "endpoint", "=", "os", ".", "pat...
Reload a specific NApp or all Napps. Args: napp (list): NApp list to be reload. Raises: requests.HTTPError: When there's a server error.
[ "Reload", "a", "specific", "NApp", "or", "all", "Napps", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/client.py#L82-L108
train
Reload a specific NApp or all NApps.
kytos/kytos-utils
kytos/utils/client.py
NAppsClient.upload_napp
def upload_napp(self, metadata, package): """Upload the napp from the current directory to the napps server.""" endpoint = os.path.join(self._config.get('napps', 'api'), 'napps', '') metadata['token'] = self._config.get('auth', 'token') request = self.make_request(endpoint, json=metadata...
python
def upload_napp(self, metadata, package): """Upload the napp from the current directory to the napps server.""" endpoint = os.path.join(self._config.get('napps', 'api'), 'napps', '') metadata['token'] = self._config.get('auth', 'token') request = self.make_request(endpoint, json=metadata...
[ "def", "upload_napp", "(", "self", ",", "metadata", ",", "package", ")", ":", "endpoint", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_config", ".", "get", "(", "'napps'", ",", "'api'", ")", ",", "'napps'", ",", "''", ")", "metadata", "...
Upload the napp from the current directory to the napps server.
[ "Upload", "the", "napp", "from", "the", "current", "directory", "to", "the", "napps", "server", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/client.py#L111-L127
train
Upload the napp from the current directory to the napps server.
kytos/kytos-utils
kytos/utils/client.py
NAppsClient.delete
def delete(self, username, napp): """Delete a NApp. Raises: requests.HTTPError: If 400 <= status < 600. """ api = self._config.get('napps', 'api') endpoint = os.path.join(api, 'napps', username, napp, '') content = {'token': self._config.get('auth', 'token')...
python
def delete(self, username, napp): """Delete a NApp. Raises: requests.HTTPError: If 400 <= status < 600. """ api = self._config.get('napps', 'api') endpoint = os.path.join(api, 'napps', username, napp, '') content = {'token': self._config.get('auth', 'token')...
[ "def", "delete", "(", "self", ",", "username", ",", "napp", ")", ":", "api", "=", "self", ".", "_config", ".", "get", "(", "'napps'", ",", "'api'", ")", "endpoint", "=", "os", ".", "path", ".", "join", "(", "api", ",", "'napps'", ",", "username", ...
Delete a NApp. Raises: requests.HTTPError: If 400 <= status < 600.
[ "Delete", "a", "NApp", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/client.py#L130-L141
train
Delete a NApp.
kytos/kytos-utils
kytos/utils/client.py
UsersClient.register
def register(self, user_dict): """Send an user_dict to NApps server using POST request. Args: user_dict(dict): Dictionary with user attributes. Returns: result(string): Return the response of Napps server. """ endpoint = os.path.join(self._config.get('n...
python
def register(self, user_dict): """Send an user_dict to NApps server using POST request. Args: user_dict(dict): Dictionary with user attributes. Returns: result(string): Return the response of Napps server. """ endpoint = os.path.join(self._config.get('n...
[ "def", "register", "(", "self", ",", "user_dict", ")", ":", "endpoint", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_config", ".", "get", "(", "'napps'", ",", "'api'", ")", ",", "'users'", ",", "''", ")", "res", "=", "self", ".", "mak...
Send an user_dict to NApps server using POST request. Args: user_dict(dict): Dictionary with user attributes. Returns: result(string): Return the response of Napps server.
[ "Send", "an", "user_dict", "to", "NApps", "server", "using", "POST", "request", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/utils/client.py#L147-L160
train
Send a user_dict to NApps server using POST request.
thomasdelaet/python-velbus
velbus/messages/module_status.py
ModuleStatusMessage.populate
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_low_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 4) self.set_attributes(priority, address, rtr) self.closed = self....
python
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_low_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 4) self.set_attributes(priority, address, rtr) self.closed = self....
[ "def", "populate", "(", "self", ",", "priority", ",", "address", ",", "rtr", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "needs_low_priority", "(", "priority", ")", "self", ".", "needs_no_rtr", "(", "rtr", ...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/module_status.py#L24-L36
train
Populates the object with the data from the server.
thomasdelaet/python-velbus
velbus/messages/module_status.py
ModuleStatusMessage2.data_to_binary
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, self.channels_to_byte(self.closed), self.channels_to_byte(self.enabled), self.channels_to_byte(self.normal), self.channels_to_byte(self.locked) ...
python
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, self.channels_to_byte(self.closed), self.channels_to_byte(self.enabled), self.channels_to_byte(self.normal), self.channels_to_byte(self.locked) ...
[ "def", "data_to_binary", "(", "self", ")", ":", "return", "bytes", "(", "[", "COMMAND_CODE", ",", "self", ".", "channels_to_byte", "(", "self", ".", "closed", ")", ",", "self", ".", "channels_to_byte", "(", "self", ".", "enabled", ")", ",", "self", ".", ...
:return: bytes
[ ":", "return", ":", "bytes" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/module_status.py#L73-L83
train
Converts the object to a byte array.
thomasdelaet/python-velbus
velbus/messages/module_status.py
ModuleStatusMessage2.to_json
def to_json(self): """ :return: str """ json_dict = self.to_json_basic() json_dict['closed'] = self.closed json_dict['enabled'] = self.enabled json_dict['normal'] = self.normal json_dict['locked'] = self.locked return json.dumps(json_dict)
python
def to_json(self): """ :return: str """ json_dict = self.to_json_basic() json_dict['closed'] = self.closed json_dict['enabled'] = self.enabled json_dict['normal'] = self.normal json_dict['locked'] = self.locked return json.dumps(json_dict)
[ "def", "to_json", "(", "self", ")", ":", "json_dict", "=", "self", ".", "to_json_basic", "(", ")", "json_dict", "[", "'closed'", "]", "=", "self", ".", "closed", "json_dict", "[", "'enabled'", "]", "=", "self", ".", "enabled", "json_dict", "[", "'normal'...
:return: str
[ ":", "return", ":", "str" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/module_status.py#L85-L94
train
Returns a string representation of the current set of cache entries in JSON format.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/biosignalsnotebooks/train_and_classify.py
windowing
def windowing(signal, sampling_rate=1000, time_window=.25, overlap=0): """ ----- Brief ----- Function to window the input signal, that return the windowed signal. ----------- Description ----------- Machine learning pipelines usually use features to represent each sample of the inpu...
python
def windowing(signal, sampling_rate=1000, time_window=.25, overlap=0): """ ----- Brief ----- Function to window the input signal, that return the windowed signal. ----------- Description ----------- Machine learning pipelines usually use features to represent each sample of the inpu...
[ "def", "windowing", "(", "signal", ",", "sampling_rate", "=", "1000", ",", "time_window", "=", ".25", ",", "overlap", "=", "0", ")", ":", "if", "overlap", "<", "0", "or", "overlap", ">=", "1", ":", "raise", "ValueError", "(", "\"overlap should be a float i...
----- Brief ----- Function to window the input signal, that return the windowed signal. ----------- Description ----------- Machine learning pipelines usually use features to represent each sample of the input signals. In order to extract those features, it is required to window the sig...
[ "-----", "Brief", "-----", "Function", "to", "window", "the", "input", "signal", "that", "return", "the", "windowed", "signal", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/train_and_classify.py#L28-L73
train
This function returns a new array that is a windowed version of the input signal.
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/biosignalsnotebooks/train_and_classify.py
features_extraction
def features_extraction(windowed_signal, functions): """ ----- Brief ----- Function to extract features given in functions, that returns an array with the set of features for each time window. ----------- Description ----------- Machine learning pipelines usually use features to...
python
def features_extraction(windowed_signal, functions): """ ----- Brief ----- Function to extract features given in functions, that returns an array with the set of features for each time window. ----------- Description ----------- Machine learning pipelines usually use features to...
[ "def", "features_extraction", "(", "windowed_signal", ",", "functions", ")", ":", "features", "=", "np", ".", "zeros", "(", "shape", "=", "(", "windowed_signal", ".", "shape", "[", "0", "]", ",", "len", "(", "functions", ")", ")", ")", "for", "i", ",",...
----- Brief ----- Function to extract features given in functions, that returns an array with the set of features for each time window. ----------- Description ----------- Machine learning pipelines usually use features to represent each sample of the input signals. Those features s...
[ "-----", "Brief", "-----", "Function", "to", "extract", "features", "given", "in", "functions", "that", "returns", "an", "array", "with", "the", "set", "of", "features", "for", "each", "time", "window", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/train_and_classify.py#L105-L143
train
Function to extract features from a set of functions given in functions.
thomasdelaet/python-velbus
velbus/module.py
Module.on_message
def on_message(self, message): """ Process received message """ if message.address != self._address: return if isinstance(message, velbus.ChannelNamePart1Message) or isinstance(message, velbus.ChannelNamePart1Message2): self._process_channel_name_message(1...
python
def on_message(self, message): """ Process received message """ if message.address != self._address: return if isinstance(message, velbus.ChannelNamePart1Message) or isinstance(message, velbus.ChannelNamePart1Message2): self._process_channel_name_message(1...
[ "def", "on_message", "(", "self", ",", "message", ")", ":", "if", "message", ".", "address", "!=", "self", ".", "_address", ":", "return", "if", "isinstance", "(", "message", ",", "velbus", ".", "ChannelNamePart1Message", ")", "or", "isinstance", "(", "mes...
Process received message
[ "Process", "received", "message" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/module.py#L65-L80
train
Process a message received from the controller.
thomasdelaet/python-velbus
velbus/module.py
Module.load
def load(self, callback): """ Retrieve names of channels """ if callback is None: def callb(): """No-op""" pass callback = callb if len(self._loaded_callbacks) == 0: self._request_module_status() self...
python
def load(self, callback): """ Retrieve names of channels """ if callback is None: def callb(): """No-op""" pass callback = callb if len(self._loaded_callbacks) == 0: self._request_module_status() self...
[ "def", "load", "(", "self", ",", "callback", ")", ":", "if", "callback", "is", "None", ":", "def", "callb", "(", ")", ":", "\"\"\"No-op\"\"\"", "pass", "callback", "=", "callb", "if", "len", "(", "self", ".", "_loaded_callbacks", ")", "==", "0", ":", ...
Retrieve names of channels
[ "Retrieve", "names", "of", "channels" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/module.py#L90-L105
train
Load the current state of the user.
thomasdelaet/python-velbus
velbus/module.py
Module._name_messages_complete
def _name_messages_complete(self): """ Check if all name messages have been received """ for channel in range(1, self.number_of_channels() + 1): try: for name_index in range(1, 4): if not isinstance(self._name_data[channel][name_index], str...
python
def _name_messages_complete(self): """ Check if all name messages have been received """ for channel in range(1, self.number_of_channels() + 1): try: for name_index in range(1, 4): if not isinstance(self._name_data[channel][name_index], str...
[ "def", "_name_messages_complete", "(", "self", ")", ":", "for", "channel", "in", "range", "(", "1", ",", "self", ".", "number_of_channels", "(", ")", "+", "1", ")", ":", "try", ":", "for", "name_index", "in", "range", "(", "1", ",", "4", ")", ":", ...
Check if all name messages have been received
[ "Check", "if", "all", "name", "messages", "have", "been", "received" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/module.py#L147-L158
train
Check if all name messages have been received
KE-works/pykechain
pykechain/models/validators/effects.py
VisualEffect.as_json
def as_json(self): # type: () -> dict """Represent effect as JSON dict.""" self._config['applyCss'] = self.applyCss self._json['config'] = self._config return self._json
python
def as_json(self): # type: () -> dict """Represent effect as JSON dict.""" self._config['applyCss'] = self.applyCss self._json['config'] = self._config return self._json
[ "def", "as_json", "(", "self", ")", ":", "# type: () -> dict", "self", ".", "_config", "[", "'applyCss'", "]", "=", "self", ".", "applyCss", "self", ".", "_json", "[", "'config'", "]", "=", "self", ".", "_config", "return", "self", ".", "_json" ]
Represent effect as JSON dict.
[ "Represent", "effect", "as", "JSON", "dict", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/validators/effects.py#L98-L103
train
Represent effect as JSON dict.
samuelcolvin/grablib
grablib/download.py
Downloader._delete_stale
def _delete_stale(self): """ Delete files left in self._stale_files. Also delete their directories if empty. """ for name, hash_ in self._stale_files.items(): path = self.download_root.joinpath(name) if not path.exists(): continue curre...
python
def _delete_stale(self): """ Delete files left in self._stale_files. Also delete their directories if empty. """ for name, hash_ in self._stale_files.items(): path = self.download_root.joinpath(name) if not path.exists(): continue curre...
[ "def", "_delete_stale", "(", "self", ")", ":", "for", "name", ",", "hash_", "in", "self", ".", "_stale_files", ".", "items", "(", ")", ":", "path", "=", "self", ".", "download_root", ".", "joinpath", "(", "name", ")", "if", "not", "path", ".", "exist...
Delete files left in self._stale_files. Also delete their directories if empty.
[ "Delete", "files", "left", "in", "self", ".", "_stale_files", ".", "Also", "delete", "their", "directories", "if", "empty", "." ]
2fca8a3950f29fb2a97a7bd75c0839060a91cedf
https://github.com/samuelcolvin/grablib/blob/2fca8a3950f29fb2a97a7bd75c0839060a91cedf/grablib/download.py#L172-L195
train
Delete stale files and directories if empty.
samuelcolvin/grablib
grablib/download.py
Downloader._file_path
def _file_path(self, src_path, dest, regex): """ check src_path complies with regex and generate new filename """ m = re.search(regex, src_path) if dest.endswith('/') or dest == '': dest += '{filename}' names = m.groupdict() if not names and m.groups()...
python
def _file_path(self, src_path, dest, regex): """ check src_path complies with regex and generate new filename """ m = re.search(regex, src_path) if dest.endswith('/') or dest == '': dest += '{filename}' names = m.groupdict() if not names and m.groups()...
[ "def", "_file_path", "(", "self", ",", "src_path", ",", "dest", ",", "regex", ")", ":", "m", "=", "re", ".", "search", "(", "regex", ",", "src_path", ")", "if", "dest", ".", "endswith", "(", "'/'", ")", "or", "dest", "==", "''", ":", "dest", "+="...
check src_path complies with regex and generate new filename
[ "check", "src_path", "complies", "with", "regex", "and", "generate", "new", "filename" ]
2fca8a3950f29fb2a97a7bd75c0839060a91cedf
https://github.com/samuelcolvin/grablib/blob/2fca8a3950f29fb2a97a7bd75c0839060a91cedf/grablib/download.py#L197-L216
train
Generate a new path from src_path to dest.
samuelcolvin/grablib
grablib/download.py
Downloader._lock
def _lock(self, url: str, name: str, hash_: str): """ Add details of the files downloaded to _new_lock so they can be saved to the lock file. Also remove path from _stale_files, whatever remains at the end therefore is stale and can be deleted. """ self._new_lock.append({ ...
python
def _lock(self, url: str, name: str, hash_: str): """ Add details of the files downloaded to _new_lock so they can be saved to the lock file. Also remove path from _stale_files, whatever remains at the end therefore is stale and can be deleted. """ self._new_lock.append({ ...
[ "def", "_lock", "(", "self", ",", "url", ":", "str", ",", "name", ":", "str", ",", "hash_", ":", "str", ")", ":", "self", ".", "_new_lock", ".", "append", "(", "{", "'url'", ":", "url", ",", "'name'", ":", "name", ",", "'hash'", ":", "hash_", "...
Add details of the files downloaded to _new_lock so they can be saved to the lock file. Also remove path from _stale_files, whatever remains at the end therefore is stale and can be deleted.
[ "Add", "details", "of", "the", "files", "downloaded", "to", "_new_lock", "so", "they", "can", "be", "saved", "to", "the", "lock", "file", ".", "Also", "remove", "path", "from", "_stale_files", "whatever", "remains", "at", "the", "end", "therefore", "is", "...
2fca8a3950f29fb2a97a7bd75c0839060a91cedf
https://github.com/samuelcolvin/grablib/blob/2fca8a3950f29fb2a97a7bd75c0839060a91cedf/grablib/download.py#L241-L251
train
Adds details of the files downloaded to _new_lock and removes path from _stale_files
lobocv/crashreporter
crashreporter/crashreporter.py
CrashReporter.setup_smtp
def setup_smtp(self, host, port, user, passwd, recipients, **kwargs): """ Set up the crash reporter to send reports via email using SMTP :param host: SMTP host :param port: SMTP port :param user: sender email address :param passwd: sender email password :param re...
python
def setup_smtp(self, host, port, user, passwd, recipients, **kwargs): """ Set up the crash reporter to send reports via email using SMTP :param host: SMTP host :param port: SMTP port :param user: sender email address :param passwd: sender email password :param re...
[ "def", "setup_smtp", "(", "self", ",", "host", ",", "port", ",", "user", ",", "passwd", ",", "recipients", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_smtp", "=", "kwargs", "self", ".", "_smtp", ".", "update", "(", "{", "'host'", ":", "host",...
Set up the crash reporter to send reports via email using SMTP :param host: SMTP host :param port: SMTP port :param user: sender email address :param passwd: sender email password :param recipients: list or comma separated string of recipients
[ "Set", "up", "the", "crash", "reporter", "to", "send", "reports", "via", "email", "using", "SMTP" ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/crashreporter.py#L95-L112
train
Setup the crash reporter to send reports via email using SMTP.
lobocv/crashreporter
crashreporter/crashreporter.py
CrashReporter.enable
def enable(self): """ Enable the crash reporter. CrashReporter is defaulted to be enabled on creation. """ if not CrashReporter.active: CrashReporter.active = True # Store this function so we can set it back if the CrashReporter is deactivated self._ex...
python
def enable(self): """ Enable the crash reporter. CrashReporter is defaulted to be enabled on creation. """ if not CrashReporter.active: CrashReporter.active = True # Store this function so we can set it back if the CrashReporter is deactivated self._ex...
[ "def", "enable", "(", "self", ")", ":", "if", "not", "CrashReporter", ".", "active", ":", "CrashReporter", ".", "active", "=", "True", "# Store this function so we can set it back if the CrashReporter is deactivated", "self", ".", "_excepthook", "=", "sys", ".", "exce...
Enable the crash reporter. CrashReporter is defaulted to be enabled on creation.
[ "Enable", "the", "crash", "reporter", ".", "CrashReporter", "is", "defaulted", "to", "be", "enabled", "on", "creation", "." ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/crashreporter.py#L123-L142
train
Enable the crash reporter.
lobocv/crashreporter
crashreporter/crashreporter.py
CrashReporter.disable
def disable(self): """ Disable the crash reporter. No reports will be sent or saved. """ if CrashReporter.active: CrashReporter.active = False # Restore the original excepthook sys.excepthook = self._excepthook self.stop_watcher() ...
python
def disable(self): """ Disable the crash reporter. No reports will be sent or saved. """ if CrashReporter.active: CrashReporter.active = False # Restore the original excepthook sys.excepthook = self._excepthook self.stop_watcher() ...
[ "def", "disable", "(", "self", ")", ":", "if", "CrashReporter", ".", "active", ":", "CrashReporter", ".", "active", "=", "False", "# Restore the original excepthook", "sys", ".", "excepthook", "=", "self", ".", "_excepthook", "self", ".", "stop_watcher", "(", ...
Disable the crash reporter. No reports will be sent or saved.
[ "Disable", "the", "crash", "reporter", ".", "No", "reports", "will", "be", "sent", "or", "saved", "." ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/crashreporter.py#L144-L153
train
Disable the crash reporter.
lobocv/crashreporter
crashreporter/crashreporter.py
CrashReporter.start_watcher
def start_watcher(self): """ Start the watcher that periodically checks for offline reports and attempts to upload them. """ if self._watcher and self._watcher.is_alive: self._watcher_running = True else: self.logger.info('CrashReporter: Starting watcher.'...
python
def start_watcher(self): """ Start the watcher that periodically checks for offline reports and attempts to upload them. """ if self._watcher and self._watcher.is_alive: self._watcher_running = True else: self.logger.info('CrashReporter: Starting watcher.'...
[ "def", "start_watcher", "(", "self", ")", ":", "if", "self", ".", "_watcher", "and", "self", ".", "_watcher", ".", "is_alive", ":", "self", ".", "_watcher_running", "=", "True", "else", ":", "self", ".", "logger", ".", "info", "(", "'CrashReporter: Startin...
Start the watcher that periodically checks for offline reports and attempts to upload them.
[ "Start", "the", "watcher", "that", "periodically", "checks", "for", "offline", "reports", "and", "attempts", "to", "upload", "them", "." ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/crashreporter.py#L155-L166
train
Start the watcher that periodically checks for offline reports and attempts to upload them.
lobocv/crashreporter
crashreporter/crashreporter.py
CrashReporter.stop_watcher
def stop_watcher(self): """ Stop the watcher thread that tries to send offline reports. """ if self._watcher: self._watcher_running = False self.logger.info('CrashReporter: Stopping watcher.')
python
def stop_watcher(self): """ Stop the watcher thread that tries to send offline reports. """ if self._watcher: self._watcher_running = False self.logger.info('CrashReporter: Stopping watcher.')
[ "def", "stop_watcher", "(", "self", ")", ":", "if", "self", ".", "_watcher", ":", "self", ".", "_watcher_running", "=", "False", "self", ".", "logger", ".", "info", "(", "'CrashReporter: Stopping watcher.'", ")" ]
Stop the watcher thread that tries to send offline reports.
[ "Stop", "the", "watcher", "thread", "that", "tries", "to", "send", "offline", "reports", "." ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/crashreporter.py#L168-L174
train
Stop the watcher thread that tries to send offline reports.
lobocv/crashreporter
crashreporter/crashreporter.py
CrashReporter.exception_handler
def exception_handler(self, etype, evalue, tb): """ Exception hook. Catches crashes / un-caught exceptions and passes them to handle_payload() :param etype: Exception type :param evalue: Exception value :param tb: Traceback :return: """ self.etype = etype...
python
def exception_handler(self, etype, evalue, tb): """ Exception hook. Catches crashes / un-caught exceptions and passes them to handle_payload() :param etype: Exception type :param evalue: Exception value :param tb: Traceback :return: """ self.etype = etype...
[ "def", "exception_handler", "(", "self", ",", "etype", ",", "evalue", ",", "tb", ")", ":", "self", ".", "etype", "=", "etype", "self", ".", "evalue", "=", "evalue", "self", ".", "tb", "=", "tb", "self", ".", "_recursion_error", "=", "\"maximum recursion ...
Exception hook. Catches crashes / un-caught exceptions and passes them to handle_payload() :param etype: Exception type :param evalue: Exception value :param tb: Traceback :return:
[ "Exception", "hook", ".", "Catches", "crashes", "/", "un", "-", "caught", "exceptions", "and", "passes", "them", "to", "handle_payload", "()" ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/crashreporter.py#L204-L225
train
Exception handler for crashes and un - caught exceptions.
lobocv/crashreporter
crashreporter/crashreporter.py
CrashReporter.forward_exception
def forward_exception(self, etype, evalue, tb): """ Forward the exception onto the backup copy that was made of the sys.__excepthook__ :param etype: Exceoption type :param evalue: Exception value :param tb: Traceback :return: """ self._excepthook(etype, e...
python
def forward_exception(self, etype, evalue, tb): """ Forward the exception onto the backup copy that was made of the sys.__excepthook__ :param etype: Exceoption type :param evalue: Exception value :param tb: Traceback :return: """ self._excepthook(etype, e...
[ "def", "forward_exception", "(", "self", ",", "etype", ",", "evalue", ",", "tb", ")", ":", "self", ".", "_excepthook", "(", "etype", ",", "evalue", ",", "tb", ")" ]
Forward the exception onto the backup copy that was made of the sys.__excepthook__ :param etype: Exceoption type :param evalue: Exception value :param tb: Traceback :return:
[ "Forward", "the", "exception", "onto", "the", "backup", "copy", "that", "was", "made", "of", "the", "sys", ".", "__excepthook__" ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/crashreporter.py#L227-L236
train
Forward the exception onto the backup copy that was made of the sys. excepthook__
lobocv/crashreporter
crashreporter/crashreporter.py
CrashReporter.handle_payload
def handle_payload(self, payload): """ Given a crash report (JSON represented payload), attempts to upload the crash reports. Calls the default exception handler (sys.__except_hook__) upon completion. :param payload: JSON structure containing crash report along with metadata :ret...
python
def handle_payload(self, payload): """ Given a crash report (JSON represented payload), attempts to upload the crash reports. Calls the default exception handler (sys.__except_hook__) upon completion. :param payload: JSON structure containing crash report along with metadata :ret...
[ "def", "handle_payload", "(", "self", ",", "payload", ")", ":", "self", ".", "payload", "=", "payload", "if", "CrashReporter", ".", "active", ":", "# Attempt to upload the report", "hq_success", "=", "smtp_success", "=", "False", "if", "self", ".", "_hq", "is"...
Given a crash report (JSON represented payload), attempts to upload the crash reports. Calls the default exception handler (sys.__except_hook__) upon completion. :param payload: JSON structure containing crash report along with metadata :return:
[ "Given", "a", "crash", "report", "(", "JSON", "represented", "payload", ")", "attempts", "to", "upload", "the", "crash", "reports", ".", "Calls", "the", "default", "exception", "handler", "(", "sys", ".", "__except_hook__", ")", "upon", "completion", ".", ":...
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/crashreporter.py#L238-L262
train
Handles the payload of a crash report.
lobocv/crashreporter
crashreporter/crashreporter.py
CrashReporter.subject
def subject(self): """ Return a string to be used as the email subject line. """ if self.application_name and self.application_version: return 'Crash Report - {name} (v{version})'.format(name=self.application_name, ...
python
def subject(self): """ Return a string to be used as the email subject line. """ if self.application_name and self.application_version: return 'Crash Report - {name} (v{version})'.format(name=self.application_name, ...
[ "def", "subject", "(", "self", ")", ":", "if", "self", ".", "application_name", "and", "self", ".", "application_version", ":", "return", "'Crash Report - {name} (v{version})'", ".", "format", "(", "name", "=", "self", ".", "application_name", ",", "version", "=...
Return a string to be used as the email subject line.
[ "Return", "a", "string", "to", "be", "used", "as", "the", "email", "subject", "line", "." ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/crashreporter.py#L301-L309
train
Return a string to be used as the email subject line.
lobocv/crashreporter
crashreporter/crashreporter.py
CrashReporter.delete_offline_reports
def delete_offline_reports(self): """ Delete all stored offline reports :return: List of reports that still require submission """ reports = self.get_offline_reports() remaining_reports = reports[:] for report in reports: with open(report, 'r') as _f: ...
python
def delete_offline_reports(self): """ Delete all stored offline reports :return: List of reports that still require submission """ reports = self.get_offline_reports() remaining_reports = reports[:] for report in reports: with open(report, 'r') as _f: ...
[ "def", "delete_offline_reports", "(", "self", ")", ":", "reports", "=", "self", ".", "get_offline_reports", "(", ")", "remaining_reports", "=", "reports", "[", ":", "]", "for", "report", "in", "reports", ":", "with", "open", "(", "report", ",", "'r'", ")",...
Delete all stored offline reports :return: List of reports that still require submission
[ "Delete", "all", "stored", "offline", "reports", ":", "return", ":", "List", "of", "reports", "that", "still", "require", "submission" ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/crashreporter.py#L328-L352
train
Delete all stored offline reports and return a list of all reports that require submission.
lobocv/crashreporter
crashreporter/crashreporter.py
CrashReporter.submit_offline_reports
def submit_offline_reports(self): """ Submit offline reports using the enabled methods (SMTP and/or HQ) Returns a tuple of (N sent reports, N remaining reports) """ smtp_enabled = bool(self._smtp) hq_enabled = bool(self._hq) offline_reports = self.get_offline_repo...
python
def submit_offline_reports(self): """ Submit offline reports using the enabled methods (SMTP and/or HQ) Returns a tuple of (N sent reports, N remaining reports) """ smtp_enabled = bool(self._smtp) hq_enabled = bool(self._hq) offline_reports = self.get_offline_repo...
[ "def", "submit_offline_reports", "(", "self", ")", ":", "smtp_enabled", "=", "bool", "(", "self", ".", "_smtp", ")", "hq_enabled", "=", "bool", "(", "self", ".", "_hq", ")", "offline_reports", "=", "self", ".", "get_offline_reports", "(", ")", "logging", "...
Submit offline reports using the enabled methods (SMTP and/or HQ) Returns a tuple of (N sent reports, N remaining reports)
[ "Submit", "offline", "reports", "using", "the", "enabled", "methods", "(", "SMTP", "and", "/", "or", "HQ", ")", "Returns", "a", "tuple", "of", "(", "N", "sent", "reports", "N", "remaining", "reports", ")" ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/crashreporter.py#L354-L387
train
Submit offline reports using the enabled methods SMTP and HQ. Returns a tuple of N sent reports and N remaining reports
lobocv/crashreporter
crashreporter/crashreporter.py
CrashReporter.store_report
def store_report(self, payload): """ Save the crash report to a file. Keeping the last `offline_report_limit` files in a cyclical FIFO buffer. The newest crash report always named is 01 """ offline_reports = self.get_offline_reports() if offline_reports: # Inc...
python
def store_report(self, payload): """ Save the crash report to a file. Keeping the last `offline_report_limit` files in a cyclical FIFO buffer. The newest crash report always named is 01 """ offline_reports = self.get_offline_reports() if offline_reports: # Inc...
[ "def", "store_report", "(", "self", ",", "payload", ")", ":", "offline_reports", "=", "self", ".", "get_offline_reports", "(", ")", "if", "offline_reports", ":", "# Increment the name of all existing reports 1 --> 2, 2 --> 3 etc.", "for", "ii", ",", "report", "in", "e...
Save the crash report to a file. Keeping the last `offline_report_limit` files in a cyclical FIFO buffer. The newest crash report always named is 01
[ "Save", "the", "crash", "report", "to", "a", "file", ".", "Keeping", "the", "last", "offline_report_limit", "files", "in", "a", "cyclical", "FIFO", "buffer", ".", "The", "newest", "crash", "report", "always", "named", "is", "01" ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/crashreporter.py#L389-L412
train
Store the crash report to a file.
lobocv/crashreporter
crashreporter/crashreporter.py
CrashReporter._watcher_thread
def _watcher_thread(self): """ Periodically attempt to upload the crash reports. If any upload method is successful, delete the saved reports. """ while 1: time.sleep(self.check_interval) if not self._watcher_running: break self.logger....
python
def _watcher_thread(self): """ Periodically attempt to upload the crash reports. If any upload method is successful, delete the saved reports. """ while 1: time.sleep(self.check_interval) if not self._watcher_running: break self.logger....
[ "def", "_watcher_thread", "(", "self", ")", ":", "while", "1", ":", "time", ".", "sleep", "(", "self", ".", "check_interval", ")", "if", "not", "self", ".", "_watcher_running", ":", "break", "self", ".", "logger", ".", "info", "(", "'CrashReporter: Attempt...
Periodically attempt to upload the crash reports. If any upload method is successful, delete the saved reports.
[ "Periodically", "attempt", "to", "upload", "the", "crash", "reports", ".", "If", "any", "upload", "method", "is", "successful", "delete", "the", "saved", "reports", "." ]
a5bbb3f37977dc64bc865dfedafc365fd5469ef8
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/crashreporter.py#L471-L485
train
Thread that attempts to upload crash reports.
thomasdelaet/python-velbus
velbus/messages/set_date.py
SetDate.populate
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_low_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 4) self.set_attributes(priority, address, rtr) self._day = data[0]...
python
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_low_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 4) self.set_attributes(priority, address, rtr) self._day = data[0]...
[ "def", "populate", "(", "self", ",", "priority", ",", "address", ",", "rtr", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "needs_low_priority", "(", "priority", ")", "self", ".", "needs_no_rtr", "(", "rtr", ...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/set_date.py#L35-L46
train
Populates the object with the data from the specified bitstring.
thomasdelaet/python-velbus
velbus/messages/set_date.py
SetDate.to_json
def to_json(self): """ :return: str """ json_dict = self.to_json_basic() json_dict['day'] = self._day json_dict['mon'] = self._mon json_dict['year'] = self._year return json.dumps(json_dict)
python
def to_json(self): """ :return: str """ json_dict = self.to_json_basic() json_dict['day'] = self._day json_dict['mon'] = self._mon json_dict['year'] = self._year return json.dumps(json_dict)
[ "def", "to_json", "(", "self", ")", ":", "json_dict", "=", "self", ".", "to_json_basic", "(", ")", "json_dict", "[", "'day'", "]", "=", "self", ".", "_day", "json_dict", "[", "'mon'", "]", "=", "self", ".", "_mon", "json_dict", "[", "'year'", "]", "=...
:return: str
[ ":", "return", ":", "str" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/set_date.py#L48-L56
train
Returns a JSON string representation of the object.
thomasdelaet/python-velbus
velbus/messages/set_date.py
SetDate.data_to_binary
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, self._day, self._mon, (self._year >> 8), (self._year & 0x00ff) ])
python
def data_to_binary(self): """ :return: bytes """ return bytes([ COMMAND_CODE, self._day, self._mon, (self._year >> 8), (self._year & 0x00ff) ])
[ "def", "data_to_binary", "(", "self", ")", ":", "return", "bytes", "(", "[", "COMMAND_CODE", ",", "self", ".", "_day", ",", "self", ".", "_mon", ",", "(", "self", ".", "_year", ">>", "8", ")", ",", "(", "self", ".", "_year", "&", "0x00ff", ")", "...
:return: bytes
[ ":", "return", ":", "bytes" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/set_date.py#L58-L68
train
Convert the ISO 3166 - 1 date to binary format.
uranusjr/django-gunicorn
djgunicorn/logging.py
colorize
def colorize(style, msg, resp): """Taken and modified from `django.utils.log.ServerFormatter.format` to mimic runserver's styling. """ code = resp.status.split(maxsplit=1)[0] if code[0] == '2': # Put 2XX first, since it should be the common case msg = style.HTTP_SUCCESS(msg) elif...
python
def colorize(style, msg, resp): """Taken and modified from `django.utils.log.ServerFormatter.format` to mimic runserver's styling. """ code = resp.status.split(maxsplit=1)[0] if code[0] == '2': # Put 2XX first, since it should be the common case msg = style.HTTP_SUCCESS(msg) elif...
[ "def", "colorize", "(", "style", ",", "msg", ",", "resp", ")", ":", "code", "=", "resp", ".", "status", ".", "split", "(", "maxsplit", "=", "1", ")", "[", "0", "]", "if", "code", "[", "0", "]", "==", "'2'", ":", "# Put 2XX first, since it should be t...
Taken and modified from `django.utils.log.ServerFormatter.format` to mimic runserver's styling.
[ "Taken", "and", "modified", "from", "django", ".", "utils", ".", "log", ".", "ServerFormatter", ".", "format", "to", "mimic", "runserver", "s", "styling", "." ]
4fb16f48048ff5fff8f889a007f376236646497b
https://github.com/uranusjr/django-gunicorn/blob/4fb16f48048ff5fff8f889a007f376236646497b/djgunicorn/logging.py#L11-L32
train
Colorizes the message according to the style.
uranusjr/django-gunicorn
djgunicorn/logging.py
GunicornLogger.access
def access(self, resp, req, environ, request_time): """Override to apply styling on access logs. This duplicates a large portion of `gunicorn.glogging.Logger.access`, only adding """ if not (self.cfg.accesslog or self.cfg.logconfig or self.cfg.syslog): return ...
python
def access(self, resp, req, environ, request_time): """Override to apply styling on access logs. This duplicates a large portion of `gunicorn.glogging.Logger.access`, only adding """ if not (self.cfg.accesslog or self.cfg.logconfig or self.cfg.syslog): return ...
[ "def", "access", "(", "self", ",", "resp", ",", "req", ",", "environ", ",", "request_time", ")", ":", "if", "not", "(", "self", ".", "cfg", ".", "accesslog", "or", "self", ".", "cfg", ".", "logconfig", "or", "self", ".", "cfg", ".", "syslog", ")", ...
Override to apply styling on access logs. This duplicates a large portion of `gunicorn.glogging.Logger.access`, only adding
[ "Override", "to", "apply", "styling", "on", "access", "logs", "." ]
4fb16f48048ff5fff8f889a007f376236646497b
https://github.com/uranusjr/django-gunicorn/blob/4fb16f48048ff5fff8f889a007f376236646497b/djgunicorn/logging.py#L60-L73
train
Override to apply styling on access logs.
kytos/kytos-utils
kytos/cli/commands/web/api.py
WebAPI.update
def update(cls, args): """Call the method to update the Web UI.""" kytos_api = KytosConfig().config.get('kytos', 'api') url = f"{kytos_api}api/kytos/core/web/update" version = args["<version>"] if version: url += f"/{version}" try: result = reques...
python
def update(cls, args): """Call the method to update the Web UI.""" kytos_api = KytosConfig().config.get('kytos', 'api') url = f"{kytos_api}api/kytos/core/web/update" version = args["<version>"] if version: url += f"/{version}" try: result = reques...
[ "def", "update", "(", "cls", ",", "args", ")", ":", "kytos_api", "=", "KytosConfig", "(", ")", ".", "config", ".", "get", "(", "'kytos'", ",", "'api'", ")", "url", "=", "f\"{kytos_api}api/kytos/core/web/update\"", "version", "=", "args", "[", "\"<version>\""...
Call the method to update the Web UI.
[ "Call", "the", "method", "to", "update", "the", "Web", "UI", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/web/api.py#L16-L33
train
Call the method to update the Web UI.
kytos/kytos-utils
kytos/cli/commands/napps/api.py
NAppsAPI.disable
def disable(cls, args): """Disable subcommand.""" mgr = NAppsManager() if args['all']: napps = mgr.get_enabled() else: napps = args['<napp>'] for napp in napps: mgr.set_napp(*napp) LOG.info('NApp %s:', mgr.napp_id) cls...
python
def disable(cls, args): """Disable subcommand.""" mgr = NAppsManager() if args['all']: napps = mgr.get_enabled() else: napps = args['<napp>'] for napp in napps: mgr.set_napp(*napp) LOG.info('NApp %s:', mgr.napp_id) cls...
[ "def", "disable", "(", "cls", ",", "args", ")", ":", "mgr", "=", "NAppsManager", "(", ")", "if", "args", "[", "'all'", "]", ":", "napps", "=", "mgr", ".", "get_enabled", "(", ")", "else", ":", "napps", "=", "args", "[", "'<napp>'", "]", "for", "n...
Disable subcommand.
[ "Disable", "subcommand", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L25-L37
train
Disable NApps.
kytos/kytos-utils
kytos/cli/commands/napps/api.py
NAppsAPI.disable_napp
def disable_napp(mgr): """Disable a NApp.""" if mgr.is_enabled(): LOG.info(' Disabling...') mgr.disable() LOG.info(' Disabled.') else: LOG.error(" NApp isn't enabled.")
python
def disable_napp(mgr): """Disable a NApp.""" if mgr.is_enabled(): LOG.info(' Disabling...') mgr.disable() LOG.info(' Disabled.') else: LOG.error(" NApp isn't enabled.")
[ "def", "disable_napp", "(", "mgr", ")", ":", "if", "mgr", ".", "is_enabled", "(", ")", ":", "LOG", ".", "info", "(", "' Disabling...'", ")", "mgr", ".", "disable", "(", ")", "LOG", ".", "info", "(", "' Disabled.'", ")", "else", ":", "LOG", ".", "...
Disable a NApp.
[ "Disable", "a", "NApp", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L40-L47
train
Disable a NApp.
kytos/kytos-utils
kytos/cli/commands/napps/api.py
NAppsAPI.enable
def enable(cls, args): """Enable subcommand.""" mgr = NAppsManager() if args['all']: napps = mgr.get_disabled() else: napps = args['<napp>'] cls.enable_napps(napps)
python
def enable(cls, args): """Enable subcommand.""" mgr = NAppsManager() if args['all']: napps = mgr.get_disabled() else: napps = args['<napp>'] cls.enable_napps(napps)
[ "def", "enable", "(", "cls", ",", "args", ")", ":", "mgr", "=", "NAppsManager", "(", ")", "if", "args", "[", "'all'", "]", ":", "napps", "=", "mgr", ".", "get_disabled", "(", ")", "else", ":", "napps", "=", "args", "[", "'<napp>'", "]", "cls", "....
Enable subcommand.
[ "Enable", "subcommand", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L50-L59
train
Enable subcommand.
kytos/kytos-utils
kytos/cli/commands/napps/api.py
NAppsAPI.enable_napp
def enable_napp(cls, mgr): """Install one NApp using NAppManager object.""" try: if not mgr.is_enabled(): LOG.info(' Enabling...') mgr.enable() LOG.info(' Enabled.') except (FileNotFoundError, PermissionError) as exception: ...
python
def enable_napp(cls, mgr): """Install one NApp using NAppManager object.""" try: if not mgr.is_enabled(): LOG.info(' Enabling...') mgr.enable() LOG.info(' Enabled.') except (FileNotFoundError, PermissionError) as exception: ...
[ "def", "enable_napp", "(", "cls", ",", "mgr", ")", ":", "try", ":", "if", "not", "mgr", ".", "is_enabled", "(", ")", ":", "LOG", ".", "info", "(", "' Enabling...'", ")", "mgr", ".", "enable", "(", ")", "LOG", ".", "info", "(", "' Enabled.'", ...
Install one NApp using NAppManager object.
[ "Install", "one", "NApp", "using", "NAppManager", "object", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L62-L70
train
Install one NApp using NAppManager object.
kytos/kytos-utils
kytos/cli/commands/napps/api.py
NAppsAPI.enable_napps
def enable_napps(cls, napps): """Enable a list of NApps. Args: napps (list): List of NApps. """ mgr = NAppsManager() for napp in napps: mgr.set_napp(*napp) LOG.info('NApp %s:', mgr.napp_id) cls.enable_napp(mgr)
python
def enable_napps(cls, napps): """Enable a list of NApps. Args: napps (list): List of NApps. """ mgr = NAppsManager() for napp in napps: mgr.set_napp(*napp) LOG.info('NApp %s:', mgr.napp_id) cls.enable_napp(mgr)
[ "def", "enable_napps", "(", "cls", ",", "napps", ")", ":", "mgr", "=", "NAppsManager", "(", ")", "for", "napp", "in", "napps", ":", "mgr", ".", "set_napp", "(", "*", "napp", ")", "LOG", ".", "info", "(", "'NApp %s:'", ",", "mgr", ".", "napp_id", ")...
Enable a list of NApps. Args: napps (list): List of NApps.
[ "Enable", "a", "list", "of", "NApps", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L73-L83
train
Enable a list of NApps. napps.
kytos/kytos-utils
kytos/cli/commands/napps/api.py
NAppsAPI.uninstall
def uninstall(cls, args): """Uninstall and delete NApps. For local installations, do not delete code outside install_path and enabled_path. """ mgr = NAppsManager() for napp in args['<napp>']: mgr.set_napp(*napp) LOG.info('NApp %s:', mgr.napp_id) ...
python
def uninstall(cls, args): """Uninstall and delete NApps. For local installations, do not delete code outside install_path and enabled_path. """ mgr = NAppsManager() for napp in args['<napp>']: mgr.set_napp(*napp) LOG.info('NApp %s:', mgr.napp_id) ...
[ "def", "uninstall", "(", "cls", ",", "args", ")", ":", "mgr", "=", "NAppsManager", "(", ")", "for", "napp", "in", "args", "[", "'<napp>'", "]", ":", "mgr", ".", "set_napp", "(", "*", "napp", ")", "LOG", ".", "info", "(", "'NApp %s:'", ",", "mgr", ...
Uninstall and delete NApps. For local installations, do not delete code outside install_path and enabled_path.
[ "Uninstall", "and", "delete", "NApps", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L102-L119
train
Uninstall and delete NApps.
kytos/kytos-utils
kytos/cli/commands/napps/api.py
NAppsAPI.install_napps
def install_napps(cls, napps): """Install local or remote NApps. This method is recursive, it will install each napps and your dependencies. """ mgr = NAppsManager() for napp in napps: mgr.set_napp(*napp) LOG.info(' NApp %s:', mgr.napp_id) ...
python
def install_napps(cls, napps): """Install local or remote NApps. This method is recursive, it will install each napps and your dependencies. """ mgr = NAppsManager() for napp in napps: mgr.set_napp(*napp) LOG.info(' NApp %s:', mgr.napp_id) ...
[ "def", "install_napps", "(", "cls", ",", "napps", ")", ":", "mgr", "=", "NAppsManager", "(", ")", "for", "napp", "in", "napps", ":", "mgr", ".", "set_napp", "(", "*", "napp", ")", "LOG", ".", "info", "(", "' NApp %s:'", ",", "mgr", ".", "napp_id", ...
Install local or remote NApps. This method is recursive, it will install each napps and your dependencies.
[ "Install", "local", "or", "remote", "NApps", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L127-L152
train
This method will install local or remote NApps.
kytos/kytos-utils
kytos/cli/commands/napps/api.py
NAppsAPI.install_napp
def install_napp(cls, mgr): """Install a NApp. Raises: KytosException: If a NApp hasn't been found. """ try: LOG.info(' Searching local NApp...') mgr.install_local() LOG.info(' Found and installed.') except FileNotFoundError...
python
def install_napp(cls, mgr): """Install a NApp. Raises: KytosException: If a NApp hasn't been found. """ try: LOG.info(' Searching local NApp...') mgr.install_local() LOG.info(' Found and installed.') except FileNotFoundError...
[ "def", "install_napp", "(", "cls", ",", "mgr", ")", ":", "try", ":", "LOG", ".", "info", "(", "' Searching local NApp...'", ")", "mgr", ".", "install_local", "(", ")", "LOG", ".", "info", "(", "' Found and installed.'", ")", "except", "FileNotFoundError"...
Install a NApp. Raises: KytosException: If a NApp hasn't been found.
[ "Install", "a", "NApp", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L155-L179
train
Install a NApp.
kytos/kytos-utils
kytos/cli/commands/napps/api.py
NAppsAPI.search
def search(cls, args): """Search for NApps in NApps server matching a pattern.""" safe_shell_pat = re.escape(args['<pattern>']).replace(r'\*', '.*') pat_str = '.*{}.*'.format(safe_shell_pat) pattern = re.compile(pat_str, re.IGNORECASE) remote_json = NAppsManager.search(pattern) ...
python
def search(cls, args): """Search for NApps in NApps server matching a pattern.""" safe_shell_pat = re.escape(args['<pattern>']).replace(r'\*', '.*') pat_str = '.*{}.*'.format(safe_shell_pat) pattern = re.compile(pat_str, re.IGNORECASE) remote_json = NAppsManager.search(pattern) ...
[ "def", "search", "(", "cls", ",", "args", ")", ":", "safe_shell_pat", "=", "re", ".", "escape", "(", "args", "[", "'<pattern>'", "]", ")", ".", "replace", "(", "r'\\*'", ",", "'.*'", ")", "pat_str", "=", "'.*{}.*'", ".", "format", "(", "safe_shell_pat"...
Search for NApps in NApps server matching a pattern.
[ "Search", "for", "NApps", "in", "NApps", "server", "matching", "a", "pattern", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L182-L195
train
Search for NApps in NApps server matching a pattern.
kytos/kytos-utils
kytos/cli/commands/napps/api.py
NAppsAPI._print_napps
def _print_napps(cls, napp_list): """Format the NApp list to be printed.""" mgr = NAppsManager() enabled = mgr.get_enabled() installed = mgr.get_installed() napps = [] for napp, desc in sorted(napp_list): status = 'i' if napp in installed else '-' ...
python
def _print_napps(cls, napp_list): """Format the NApp list to be printed.""" mgr = NAppsManager() enabled = mgr.get_enabled() installed = mgr.get_installed() napps = [] for napp, desc in sorted(napp_list): status = 'i' if napp in installed else '-' ...
[ "def", "_print_napps", "(", "cls", ",", "napp_list", ")", ":", "mgr", "=", "NAppsManager", "(", ")", "enabled", "=", "mgr", ".", "get_enabled", "(", ")", "installed", "=", "mgr", ".", "get_installed", "(", ")", "napps", "=", "[", "]", "for", "napp", ...
Format the NApp list to be printed.
[ "Format", "the", "NApp", "list", "to", "be", "printed", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L198-L210
train
Format the NApp list to be printed.
kytos/kytos-utils
kytos/cli/commands/napps/api.py
NAppsAPI.list
def list(cls, args): # pylint: disable=unused-argument """List all installed NApps and inform whether they are enabled.""" mgr = NAppsManager() # Add status napps = [napp + ('[ie]',) for napp in mgr.get_enabled()] napps += [napp + ('[i-]',) for napp in mgr.get_disabled()] ...
python
def list(cls, args): # pylint: disable=unused-argument """List all installed NApps and inform whether they are enabled.""" mgr = NAppsManager() # Add status napps = [napp + ('[ie]',) for napp in mgr.get_enabled()] napps += [napp + ('[i-]',) for napp in mgr.get_disabled()] ...
[ "def", "list", "(", "cls", ",", "args", ")", ":", "# pylint: disable=unused-argument", "mgr", "=", "NAppsManager", "(", ")", "# Add status", "napps", "=", "[", "napp", "+", "(", "'[ie]'", ",", ")", "for", "napp", "in", "mgr", ".", "get_enabled", "(", ")"...
List all installed NApps and inform whether they are enabled.
[ "List", "all", "installed", "NApps", "and", "inform", "whether", "they", "are", "enabled", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L213-L233
train
List all installed NApps and inform whether they are enabled.
kytos/kytos-utils
kytos/cli/commands/napps/api.py
NAppsAPI.print_napps
def print_napps(napps): """Print status, name and description.""" if not napps: print('No NApps found.') return stat_w = 6 # We already know the size of Status col name_w = max(len(n[1]) for n in napps) desc_w = max(len(n[2]) for n in napps) term...
python
def print_napps(napps): """Print status, name and description.""" if not napps: print('No NApps found.') return stat_w = 6 # We already know the size of Status col name_w = max(len(n[1]) for n in napps) desc_w = max(len(n[2]) for n in napps) term...
[ "def", "print_napps", "(", "napps", ")", ":", "if", "not", "napps", ":", "print", "(", "'No NApps found.'", ")", "return", "stat_w", "=", "6", "# We already know the size of Status col", "name_w", "=", "max", "(", "len", "(", "n", "[", "1", "]", ")", "for"...
Print status, name and description.
[ "Print", "status", "name", "and", "description", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L236-L258
train
Print status name and description.
kytos/kytos-utils
kytos/cli/commands/napps/api.py
NAppsAPI.delete
def delete(args): """Delete NApps from server.""" mgr = NAppsManager() for napp in args['<napp>']: mgr.set_napp(*napp) LOG.info('Deleting NApp %s from server...', mgr.napp_id) try: mgr.delete() LOG.info(' Deleted.') ...
python
def delete(args): """Delete NApps from server.""" mgr = NAppsManager() for napp in args['<napp>']: mgr.set_napp(*napp) LOG.info('Deleting NApp %s from server...', mgr.napp_id) try: mgr.delete() LOG.info(' Deleted.') ...
[ "def", "delete", "(", "args", ")", ":", "mgr", "=", "NAppsManager", "(", ")", "for", "napp", "in", "args", "[", "'<napp>'", "]", ":", "mgr", ".", "set_napp", "(", "*", "napp", ")", "LOG", ".", "info", "(", "'Deleting NApp %s from server...'", ",", "mgr...
Delete NApps from server.
[ "Delete", "NApps", "from", "server", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L261-L275
train
Delete NApps from server.
kytos/kytos-utils
kytos/cli/commands/napps/api.py
NAppsAPI.reload
def reload(cls, args): """Reload NApps code.""" LOG.info('Reloading NApps...') mgr = NAppsManager() try: if args['all']: mgr.reload(None) else: napps = args['<napp>'] mgr.reload(napps) LOG.info('\tReloa...
python
def reload(cls, args): """Reload NApps code.""" LOG.info('Reloading NApps...') mgr = NAppsManager() try: if args['all']: mgr.reload(None) else: napps = args['<napp>'] mgr.reload(napps) LOG.info('\tReloa...
[ "def", "reload", "(", "cls", ",", "args", ")", ":", "LOG", ".", "info", "(", "'Reloading NApps...'", ")", "mgr", "=", "NAppsManager", "(", ")", "try", ":", "if", "args", "[", "'all'", "]", ":", "mgr", ".", "reload", "(", "None", ")", "else", ":", ...
Reload NApps code.
[ "Reload", "NApps", "code", "." ]
b4750c618d15cff75970ea6124bda4d2b9a33578
https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/api.py#L284-L300
train
Reloads the NApps code.
KE-works/pykechain
pykechain/models/property_reference.py
ReferenceProperty.value
def value(self): """Value of a reference property. You can set the reference with a Part, Part id or None value. Ensure that the model of the provided part, matches the configured model :return: a :class:`Part` or None :raises APIError: When unable to find the associated :class...
python
def value(self): """Value of a reference property. You can set the reference with a Part, Part id or None value. Ensure that the model of the provided part, matches the configured model :return: a :class:`Part` or None :raises APIError: When unable to find the associated :class...
[ "def", "value", "(", "self", ")", ":", "if", "not", "self", ".", "_value", ":", "return", "None", "return", "self", ".", "_client", ".", "part", "(", "pk", "=", "self", ".", "_value", "[", "'id'", "]", ")" ]
Value of a reference property. You can set the reference with a Part, Part id or None value. Ensure that the model of the provided part, matches the configured model :return: a :class:`Part` or None :raises APIError: When unable to find the associated :class:`Part` Example ...
[ "Value", "of", "a", "reference", "property", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/property_reference.py#L11-L56
train
Return the value of a reference property.
KE-works/pykechain
pykechain/models/property_reference.py
ReferenceProperty.choices
def choices(self): """Retrieve the parts that you can reference for this `ReferenceProperty`. This method makes 2 API calls: 1) to retrieve the referenced model, and 2) to retrieve the instances of that model. :return: the :class:`Part`'s that can be referenced as a :class:`~pykechain....
python
def choices(self): """Retrieve the parts that you can reference for this `ReferenceProperty`. This method makes 2 API calls: 1) to retrieve the referenced model, and 2) to retrieve the instances of that model. :return: the :class:`Part`'s that can be referenced as a :class:`~pykechain....
[ "def", "choices", "(", "self", ")", ":", "# from the reference property (instance) we need to get the value of the reference property in the model", "# in the reference property of the model the value is set to the ID of the model from which we can choose parts", "model_parent_part", "=", "self"...
Retrieve the parts that you can reference for this `ReferenceProperty`. This method makes 2 API calls: 1) to retrieve the referenced model, and 2) to retrieve the instances of that model. :return: the :class:`Part`'s that can be referenced as a :class:`~pykechain.model.PartSet`. :raise...
[ "Retrieve", "the", "parts", "that", "you", "can", "reference", "for", "this", "ReferenceProperty", "." ]
b0296cf34328fd41660bf6f0b9114fd0167c40c4
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/property_reference.py#L70-L93
train
Retrieve the parts that you can reference for this ReferenceProperty.
thomasdelaet/python-velbus
velbus/messages/temp_sensor_status.py
TempSensorStatusMessage.populate
def populate(self, priority, address, rtr, data): """ -DB1 last bit = local_control -DB1 bit 2+3 = status_mode -DB1 bit 4 = auto send -DB1 bit 5+6+7 = mode -DB1 bit 8 = cool -DB2 = program ...
python
def populate(self, priority, address, rtr, data): """ -DB1 last bit = local_control -DB1 bit 2+3 = status_mode -DB1 bit 4 = auto send -DB1 bit 5+6+7 = mode -DB1 bit 8 = cool -DB2 = program ...
[ "def", "populate", "(", "self", ",", "priority", ",", "address", ",", "rtr", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "needs_no_rtr", "(", "rtr", ")", "self", ".", "needs_data", "(", "data", ",", "7"...
-DB1 last bit = local_control -DB1 bit 2+3 = status_mode -DB1 bit 4 = auto send -DB1 bit 5+6+7 = mode -DB1 bit 8 = cool -DB2 = program (not used) -DB3 last bit = heater -DB3 bi...
[ "-", "DB1", "last", "bit", "=", "local_control", "-", "DB1", "bit", "2", "+", "3", "=", "status_mode", "-", "DB1", "bit", "4", "=", "auto", "send", "-", "DB1", "bit", "5", "+", "6", "+", "7", "=", "mode", "-", "DB1", "bit", "8", "=", "cool", ...
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/temp_sensor_status.py#L42-L88
train
Populates the internal state of the object with the contents of the byte array.
thomasdelaet/python-velbus
velbus/messages/temp_sensor_status.py
TempSensorStatusMessage.to_json
def to_json(self): """ :return: str """ json_dict = self.to_json_basic() json_dict['local_control'] = self.local_control json_dict['status_mode'] = DSTATUS[self.status_mode] json_dict['auto_send'] = self.auto_send json_dict['mode'] = DMODE[self.mode] ...
python
def to_json(self): """ :return: str """ json_dict = self.to_json_basic() json_dict['local_control'] = self.local_control json_dict['status_mode'] = DSTATUS[self.status_mode] json_dict['auto_send'] = self.auto_send json_dict['mode'] = DMODE[self.mode] ...
[ "def", "to_json", "(", "self", ")", ":", "json_dict", "=", "self", ".", "to_json_basic", "(", ")", "json_dict", "[", "'local_control'", "]", "=", "self", ".", "local_control", "json_dict", "[", "'status_mode'", "]", "=", "DSTATUS", "[", "self", ".", "statu...
:return: str
[ ":", "return", ":", "str" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/temp_sensor_status.py#L90-L111
train
Returns a JSON string representation of the current object.
biosignalsnotebooks/biosignalsnotebooks
header_footer/old/osf_notebook_class.py
opensignals_hierarchy
def opensignals_hierarchy(root=None, update=False, clone=False): """ Function that generates the OpenSignalsTools Notebooks File Hierarchy programatically. ---------- Parameters ---------- root : None or str The file path where the OpenSignalsTools Environment will be stored. updat...
python
def opensignals_hierarchy(root=None, update=False, clone=False): """ Function that generates the OpenSignalsTools Notebooks File Hierarchy programatically. ---------- Parameters ---------- root : None or str The file path where the OpenSignalsTools Environment will be stored. updat...
[ "def", "opensignals_hierarchy", "(", "root", "=", "None", ",", "update", "=", "False", ",", "clone", "=", "False", ")", ":", "if", "root", "is", "None", ":", "root", "=", "os", ".", "getcwd", "(", ")", "categories", "=", "list", "(", "NOTEBOOK_KEYS", ...
Function that generates the OpenSignalsTools Notebooks File Hierarchy programatically. ---------- Parameters ---------- root : None or str The file path where the OpenSignalsTools Environment will be stored. update : bool If True the old files will be replaced by the new ones. ...
[ "Function", "that", "generates", "the", "OpenSignalsTools", "Notebooks", "File", "Hierarchy", "programatically", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/header_footer/old/osf_notebook_class.py#L225-L321
train
Function that generates the OpenSignalsTools Notebooks File Hierarchy programatically.
biosignalsnotebooks/biosignalsnotebooks
header_footer/old/osf_notebook_class.py
_generate_main_files_header
def _generate_main_files_header(notebook_object, notebook_title="Notebook Title", notebook_description="Notebook Description"): """ Internal function that is used for generation of the 'MainFiles' notebooks header. ---------- Parameters ---------- notebook_object...
python
def _generate_main_files_header(notebook_object, notebook_title="Notebook Title", notebook_description="Notebook Description"): """ Internal function that is used for generation of the 'MainFiles' notebooks header. ---------- Parameters ---------- notebook_object...
[ "def", "_generate_main_files_header", "(", "notebook_object", ",", "notebook_title", "=", "\"Notebook Title\"", ",", "notebook_description", "=", "\"Notebook Description\"", ")", ":", "# =================================== Creation of Header =======================================", "h...
Internal function that is used for generation of the 'MainFiles' notebooks header. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the header will be created. notebook_title : None or str Title of the Notebook. notebook_descr...
[ "Internal", "function", "that", "is", "used", "for", "generation", "of", "the", "MainFiles", "notebooks", "header", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/header_footer/old/osf_notebook_class.py#L404-L430
train
This function is used to generate the main files header.
biosignalsnotebooks/biosignalsnotebooks
header_footer/old/osf_notebook_class.py
_generate_footer
def _generate_footer(notebook_object, notebook_type): """ Internal function that is used for generation of the notebooks footer. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the footer will be created. notebook_type : str ...
python
def _generate_footer(notebook_object, notebook_type): """ Internal function that is used for generation of the notebooks footer. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the footer will be created. notebook_type : str ...
[ "def", "_generate_footer", "(", "notebook_object", ",", "notebook_type", ")", ":", "footer_aux", "=", "FOOTER", "if", "\"Main_Files\"", "in", "notebook_type", ":", "footer_aux", "=", "footer_aux", ".", "replace", "(", "\"../MainFiles/\"", ",", "\"\"", ")", "# ====...
Internal function that is used for generation of the notebooks footer. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the footer will be created. notebook_type : str Notebook type: - "Main_Files_Signal_Samples" ...
[ "Internal", "function", "that", "is", "used", "for", "generation", "of", "the", "notebooks", "footer", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/header_footer/old/osf_notebook_class.py#L434-L467
train
Internal function that is used for generating the notebooks footer.
biosignalsnotebooks/biosignalsnotebooks
header_footer/old/osf_notebook_class.py
_generate_header
def _generate_header(notebook_object, notebook_type, notebook_file): """ Internal function that is used for generation of the notebooks footer. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the header will be created. notebook_f...
python
def _generate_header(notebook_object, notebook_type, notebook_file): """ Internal function that is used for generation of the notebooks footer. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the header will be created. notebook_f...
[ "def", "_generate_header", "(", "notebook_object", ",", "notebook_type", ",", "notebook_file", ")", ":", "header_aux", "=", "HEADER", "header_aux", "=", "header_aux", ".", "replace", "(", "\"FILENAME\"", ",", "notebook_file", ".", "split", "(", "\".\"", ")", "["...
Internal function that is used for generation of the notebooks footer. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the header will be created. notebook_file : str Notebook filename. notebook_type : str Notebook ty...
[ "Internal", "function", "that", "is", "used", "for", "generation", "of", "the", "notebooks", "footer", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/header_footer/old/osf_notebook_class.py#L470-L509
train
Internal function that is used for generating the header of the notebook.
biosignalsnotebooks/biosignalsnotebooks
header_footer/old/osf_notebook_class.py
_generate_signal_samples_body
def _generate_signal_samples_body(notebook_object): """ Internal function that is used for generation of the 'MainFiles' notebooks header. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the header will be created. """ # ====...
python
def _generate_signal_samples_body(notebook_object): """ Internal function that is used for generation of the 'MainFiles' notebooks header. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the header will be created. """ # ====...
[ "def", "_generate_signal_samples_body", "(", "notebook_object", ")", ":", "# =========================== Code Cell for Importing Packages =================================", "notebook_object", "[", "\"cells\"", "]", ".", "append", "(", "nb", ".", "v4", ".", "new_code_cell", "("...
Internal function that is used for generation of the 'MainFiles' notebooks header. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the header will be created.
[ "Internal", "function", "that", "is", "used", "for", "generation", "of", "the", "MainFiles", "notebooks", "header", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/header_footer/old/osf_notebook_class.py#L511-L564
train
Generates the signal samples body.
biosignalsnotebooks/biosignalsnotebooks
header_footer/old/osf_notebook_class.py
_set_star_value
def _set_star_value(star_code, number_stars): """ Internal function that is used for update the number of active stars (that define notebook difficulty level) ---------- Parameters ---------- star_code : str String with the HTML code to be changed. number_stars : int Nu...
python
def _set_star_value(star_code, number_stars): """ Internal function that is used for update the number of active stars (that define notebook difficulty level) ---------- Parameters ---------- star_code : str String with the HTML code to be changed. number_stars : int Nu...
[ "def", "_set_star_value", "(", "star_code", ",", "number_stars", ")", ":", "for", "star", "in", "range", "(", "1", ",", "6", ")", ":", "if", "star", "<=", "number_stars", ":", "star_code", "=", "star_code", ".", "replace", "(", "\"fa fa-star \"", "+", "s...
Internal function that is used for update the number of active stars (that define notebook difficulty level) ---------- Parameters ---------- star_code : str String with the HTML code to be changed. number_stars : int Number of stars that will be active. Returns ------...
[ "Internal", "function", "that", "is", "used", "for", "update", "the", "number", "of", "active", "stars", "(", "that", "define", "notebook", "difficulty", "level", ")" ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/header_footer/old/osf_notebook_class.py#L609-L637
train
Internal function that is used to update the number of active stars in a notebook.
biosignalsnotebooks/biosignalsnotebooks
header_footer/old/osf_notebook_class.py
_generate_notebook_by_tag_body
def _generate_notebook_by_tag_body(notebook_object, dict_by_tag): """ Internal function that is used for generation of the page where notebooks are organized by tag values. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the body w...
python
def _generate_notebook_by_tag_body(notebook_object, dict_by_tag): """ Internal function that is used for generation of the page where notebooks are organized by tag values. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the body w...
[ "def", "_generate_notebook_by_tag_body", "(", "notebook_object", ",", "dict_by_tag", ")", ":", "tag_keys", "=", "list", "(", "dict_by_tag", ".", "keys", "(", ")", ")", "tag_keys", ".", "sort", "(", ")", "for", "tag", "in", "tag_keys", ":", "if", "tag", "."...
Internal function that is used for generation of the page where notebooks are organized by tag values. ---------- Parameters ---------- notebook_object : notebook object Object of "notebook" class where the body will be created. dict_by_tag : dict Dictionary where each key is a...
[ "Internal", "function", "that", "is", "used", "for", "generation", "of", "the", "page", "where", "notebooks", "are", "organized", "by", "tag", "values", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/header_footer/old/osf_notebook_class.py#L640-L681
train
Internal function that is used for generating the page where notebooks are organized by tag values.
biosignalsnotebooks/biosignalsnotebooks
header_footer/old/osf_notebook_class.py
notebook.write_to_file
def write_to_file(self, path, filename, footer=True): """ Class method responsible for generating a file containing the notebook object data. ---------- Parameters ---------- path : str OpenSignalsTools Root folder path (where the notebook will be stored). ...
python
def write_to_file(self, path, filename, footer=True): """ Class method responsible for generating a file containing the notebook object data. ---------- Parameters ---------- path : str OpenSignalsTools Root folder path (where the notebook will be stored). ...
[ "def", "write_to_file", "(", "self", ",", "path", ",", "filename", ",", "footer", "=", "True", ")", ":", "# =============================== Storage of Filename ======================================", "self", ".", "filename", "=", "filename", "# ======================== Inclu...
Class method responsible for generating a file containing the notebook object data. ---------- Parameters ---------- path : str OpenSignalsTools Root folder path (where the notebook will be stored). filename : str Defines the name of the notebook file. ...
[ "Class", "method", "responsible", "for", "generating", "a", "file", "containing", "the", "notebook", "object", "data", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/header_footer/old/osf_notebook_class.py#L143-L184
train
This method writes the object to a file.
biosignalsnotebooks/biosignalsnotebooks
header_footer/old/osf_notebook_class.py
notebook.add_markdown_cell
def add_markdown_cell(self, content, tags=None): """ Class method responsible for adding a markdown cell with content 'content' to the Notebook object. ---------- Parameters ---------- content : str Text/HTML code/... to include in the markdown cell (...
python
def add_markdown_cell(self, content, tags=None): """ Class method responsible for adding a markdown cell with content 'content' to the Notebook object. ---------- Parameters ---------- content : str Text/HTML code/... to include in the markdown cell (...
[ "def", "add_markdown_cell", "(", "self", ",", "content", ",", "tags", "=", "None", ")", ":", "self", ".", "notebook", "[", "\"cells\"", "]", ".", "append", "(", "nb", ".", "v4", ".", "new_markdown_cell", "(", "content", ",", "*", "*", "{", "\"metadata\...
Class method responsible for adding a markdown cell with content 'content' to the Notebook object. ---------- Parameters ---------- content : str Text/HTML code/... to include in the markdown cell (triple quote for multiline text). tags : list A ...
[ "Class", "method", "responsible", "for", "adding", "a", "markdown", "cell", "with", "content", "content", "to", "the", "Notebook", "object", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/header_footer/old/osf_notebook_class.py#L186-L201
train
Method responsible for adding a markdown cell with content content.
biosignalsnotebooks/biosignalsnotebooks
header_footer/old/osf_notebook_class.py
notebook.add_code_cell
def add_code_cell(self, content, tags=None): """ Class method responsible for adding a code cell with content 'content' to the Notebook object. ---------- Parameters ---------- content : str Code in a string format to include in the cell (triple quote...
python
def add_code_cell(self, content, tags=None): """ Class method responsible for adding a code cell with content 'content' to the Notebook object. ---------- Parameters ---------- content : str Code in a string format to include in the cell (triple quote...
[ "def", "add_code_cell", "(", "self", ",", "content", ",", "tags", "=", "None", ")", ":", "self", ".", "notebook", "[", "\"cells\"", "]", ".", "append", "(", "nb", ".", "v4", ".", "new_code_cell", "(", "content", ",", "*", "*", "{", "\"metadata\"", ":...
Class method responsible for adding a code cell with content 'content' to the Notebook object. ---------- Parameters ---------- content : str Code in a string format to include in the cell (triple quote for multiline text). tags : list ...
[ "Class", "method", "responsible", "for", "adding", "a", "code", "cell", "with", "content", "content", "to", "the", "Notebook", "object", "." ]
aaa01d4125180b3a34f1e26e0d3ff08c23f666d3
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/header_footer/old/osf_notebook_class.py#L203-L219
train
Method responsible for adding a code cell with content to the notebook object.
thomasdelaet/python-velbus
velbus/messages/channel_name_request.py
ChannelNameRequestMessage.populate
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_low_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 1) self.set_attributes(priority, address, rtr) self.channels = sel...
python
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_low_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 1) self.set_attributes(priority, address, rtr) self.channels = sel...
[ "def", "populate", "(", "self", ",", "priority", ",", "address", ",", "rtr", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "needs_low_priority", "(", "priority", ")", "self", ".", "needs_no_rtr", "(", "rtr", ...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/channel_name_request.py#L20-L29
train
Populates the object with the data from the given bytes.
thomasdelaet/python-velbus
velbus/messages/channel_name_request.py
ChannelNameRequestMessage2.data_to_binary
def data_to_binary(self): """ :return: bytes """ tmp = 0x00 if 1 in self.channels: tmp += 0x03 if 2 in self.channels: tmp += 0x0c return bytes([COMMAND_CODE, tmp])
python
def data_to_binary(self): """ :return: bytes """ tmp = 0x00 if 1 in self.channels: tmp += 0x03 if 2 in self.channels: tmp += 0x0c return bytes([COMMAND_CODE, tmp])
[ "def", "data_to_binary", "(", "self", ")", ":", "tmp", "=", "0x00", "if", "1", "in", "self", ".", "channels", ":", "tmp", "+=", "0x03", "if", "2", "in", "self", ".", "channels", ":", "tmp", "+=", "0x0c", "return", "bytes", "(", "[", "COMMAND_CODE", ...
:return: bytes
[ ":", "return", ":", "bytes" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/channel_name_request.py#L56-L65
train
Convert the data to binary format.
thomasdelaet/python-velbus
velbus/message.py
Message.set_attributes
def set_attributes(self, priority, address, rtr): """ :return: None """ assert isinstance(priority, int) assert isinstance(address, int) assert isinstance(rtr, bool) assert priority == velbus.HIGH_PRIORITY or priority == velbus.LOW_PRIORITY assert ...
python
def set_attributes(self, priority, address, rtr): """ :return: None """ assert isinstance(priority, int) assert isinstance(address, int) assert isinstance(rtr, bool) assert priority == velbus.HIGH_PRIORITY or priority == velbus.LOW_PRIORITY assert ...
[ "def", "set_attributes", "(", "self", ",", "priority", ",", "address", ",", "rtr", ")", ":", "assert", "isinstance", "(", "priority", ",", "int", ")", "assert", "isinstance", "(", "address", ",", "int", ")", "assert", "isinstance", "(", "rtr", ",", "bool...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L22-L33
train
Set the priority and address of the last set of node attributes.
thomasdelaet/python-velbus
velbus/message.py
Message.set_defaults
def set_defaults(self, address): """ Set defaults If a message has different than low priority or NO_RTR set, then this method needs override in subclass :return: None """ if address is not None: self.set_address(address) self.set_...
python
def set_defaults(self, address): """ Set defaults If a message has different than low priority or NO_RTR set, then this method needs override in subclass :return: None """ if address is not None: self.set_address(address) self.set_...
[ "def", "set_defaults", "(", "self", ",", "address", ")", ":", "if", "address", "is", "not", "None", ":", "self", ".", "set_address", "(", "address", ")", "self", ".", "set_low_priority", "(", ")", "self", ".", "set_no_rtr", "(", ")" ]
Set defaults If a message has different than low priority or NO_RTR set, then this method needs override in subclass :return: None
[ "Set", "defaults", "If", "a", "message", "has", "different", "than", "low", "priority", "or", "NO_RTR", "set", "then", "this", "method", "needs", "override", "in", "subclass", ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L41-L53
train
Set the message s low priority and NO_RTR attributes.
thomasdelaet/python-velbus
velbus/message.py
Message.to_binary
def to_binary(self): """ :return: bytes """ pre_checksum_data = self.__checksum_data() checksum = velbus.checksum(pre_checksum_data) return pre_checksum_data + checksum + bytes([velbus.END_BYTE])
python
def to_binary(self): """ :return: bytes """ pre_checksum_data = self.__checksum_data() checksum = velbus.checksum(pre_checksum_data) return pre_checksum_data + checksum + bytes([velbus.END_BYTE])
[ "def", "to_binary", "(", "self", ")", ":", "pre_checksum_data", "=", "self", ".", "__checksum_data", "(", ")", "checksum", "=", "velbus", ".", "checksum", "(", "pre_checksum_data", ")", "return", "pre_checksum_data", "+", "checksum", "+", "bytes", "(", "[", ...
:return: bytes
[ ":", "return", ":", "bytes" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L62-L68
train
Converts the object to binary format.
thomasdelaet/python-velbus
velbus/message.py
Message.__checksum_data
def __checksum_data(self): """ :return: bytes """ data_bytes = self.data_to_binary() if self.rtr: rtr_and_size = velbus.RTR | len(data_bytes) else: rtr_and_size = len(data_bytes) prefix = bytes([velbus.START_BYTE, self.priority, se...
python
def __checksum_data(self): """ :return: bytes """ data_bytes = self.data_to_binary() if self.rtr: rtr_and_size = velbus.RTR | len(data_bytes) else: rtr_and_size = len(data_bytes) prefix = bytes([velbus.START_BYTE, self.priority, se...
[ "def", "__checksum_data", "(", "self", ")", ":", "data_bytes", "=", "self", ".", "data_to_binary", "(", ")", "if", "self", ".", "rtr", ":", "rtr_and_size", "=", "velbus", ".", "RTR", "|", "len", "(", "data_bytes", ")", "else", ":", "rtr_and_size", "=", ...
:return: bytes
[ ":", "return", ":", "bytes" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L76-L87
train
Returns the checksum of the data.
thomasdelaet/python-velbus
velbus/message.py
Message.to_json_basic
def to_json_basic(self): """ Create JSON structure with generic attributes :return: dict """ return {'name': self.__class__.__name__, 'priority': self.priority, 'address': self.address, 'rtr': self.rtr}
python
def to_json_basic(self): """ Create JSON structure with generic attributes :return: dict """ return {'name': self.__class__.__name__, 'priority': self.priority, 'address': self.address, 'rtr': self.rtr}
[ "def", "to_json_basic", "(", "self", ")", ":", "return", "{", "'name'", ":", "self", ".", "__class__", ".", "__name__", ",", "'priority'", ":", "self", ".", "priority", ",", "'address'", ":", "self", ".", "address", ",", "'rtr'", ":", "self", ".", "rtr...
Create JSON structure with generic attributes :return: dict
[ "Create", "JSON", "structure", "with", "generic", "attributes", ":", "return", ":", "dict" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L95-L102
train
Create JSON structure with generic attributes
thomasdelaet/python-velbus
velbus/message.py
Message.byte_to_channels
def byte_to_channels(self, byte): """ :return: list(int) """ # pylint: disable-msg=R0201 assert isinstance(byte, int) assert byte >= 0 assert byte < 256 result = [] for offset in range(0, 8): if byte & (1 << offset): ...
python
def byte_to_channels(self, byte): """ :return: list(int) """ # pylint: disable-msg=R0201 assert isinstance(byte, int) assert byte >= 0 assert byte < 256 result = [] for offset in range(0, 8): if byte & (1 << offset): ...
[ "def", "byte_to_channels", "(", "self", ",", "byte", ")", ":", "# pylint: disable-msg=R0201\r", "assert", "isinstance", "(", "byte", ",", "int", ")", "assert", "byte", ">=", "0", "assert", "byte", "<", "256", "result", "=", "[", "]", "for", "offset", "in",...
:return: list(int)
[ ":", "return", ":", "list", "(", "int", ")" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L117-L129
train
Converts a byte value to a list of channels.
thomasdelaet/python-velbus
velbus/message.py
Message.channels_to_byte
def channels_to_byte(self, channels): """ :return: int """ # pylint: disable-msg=R0201 assert isinstance(channels, list) result = 0 for offset in range(0, 8): if offset + 1 in channels: result = result + (1 << offset) ...
python
def channels_to_byte(self, channels): """ :return: int """ # pylint: disable-msg=R0201 assert isinstance(channels, list) result = 0 for offset in range(0, 8): if offset + 1 in channels: result = result + (1 << offset) ...
[ "def", "channels_to_byte", "(", "self", ",", "channels", ")", ":", "# pylint: disable-msg=R0201\r", "assert", "isinstance", "(", "channels", ",", "list", ")", "result", "=", "0", "for", "offset", "in", "range", "(", "0", ",", "8", ")", ":", "if", "offset",...
:return: int
[ ":", "return", ":", "int" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L131-L141
train
Converts a list of channels into a byte array.
thomasdelaet/python-velbus
velbus/message.py
Message.byte_to_channel
def byte_to_channel(self, byte): """ :return: int """ assert isinstance(byte, int) channels = self.byte_to_channels(byte) self.needs_one_channel(channels) return channels[0]
python
def byte_to_channel(self, byte): """ :return: int """ assert isinstance(byte, int) channels = self.byte_to_channels(byte) self.needs_one_channel(channels) return channels[0]
[ "def", "byte_to_channel", "(", "self", ",", "byte", ")", ":", "assert", "isinstance", "(", "byte", ",", "int", ")", "channels", "=", "self", ".", "byte_to_channels", "(", "byte", ")", "self", ".", "needs_one_channel", "(", "channels", ")", "return", "chann...
:return: int
[ ":", "return", ":", "int" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L143-L150
train
Converts a byte to a channel number.
thomasdelaet/python-velbus
velbus/message.py
Message.needs_valid_channel
def needs_valid_channel(self, channel, maximum): """ :return: None """ assert isinstance(channel, int) assert isinstance(maximum, int) if channel < 1 and channel > maximum: self.parser_error("needs valid channel in channel byte")
python
def needs_valid_channel(self, channel, maximum): """ :return: None """ assert isinstance(channel, int) assert isinstance(maximum, int) if channel < 1 and channel > maximum: self.parser_error("needs valid channel in channel byte")
[ "def", "needs_valid_channel", "(", "self", ",", "channel", ",", "maximum", ")", ":", "assert", "isinstance", "(", "channel", ",", "int", ")", "assert", "isinstance", "(", "maximum", ",", "int", ")", "if", "channel", "<", "1", "and", "channel", ">", "maxi...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L152-L159
train
Check that the given channel is valid.
thomasdelaet/python-velbus
velbus/message.py
Message.needs_low_priority
def needs_low_priority(self, priority): """ :return: None """ assert isinstance(priority, int) if priority != velbus.LOW_PRIORITY: self.parser_error("needs low priority set")
python
def needs_low_priority(self, priority): """ :return: None """ assert isinstance(priority, int) if priority != velbus.LOW_PRIORITY: self.parser_error("needs low priority set")
[ "def", "needs_low_priority", "(", "self", ",", "priority", ")", ":", "assert", "isinstance", "(", "priority", ",", "int", ")", "if", "priority", "!=", "velbus", ".", "LOW_PRIORITY", ":", "self", ".", "parser_error", "(", "\"needs low priority set\"", ")" ]
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L195-L201
train
Check if the set of available local attributes is set to low priority.
thomasdelaet/python-velbus
velbus/message.py
Message.needs_high_priority
def needs_high_priority(self, priority): """ :return: None """ assert isinstance(priority, int) if priority != velbus.HIGH_PRIORITY: self.parser_error("needs high priority set")
python
def needs_high_priority(self, priority): """ :return: None """ assert isinstance(priority, int) if priority != velbus.HIGH_PRIORITY: self.parser_error("needs high priority set")
[ "def", "needs_high_priority", "(", "self", ",", "priority", ")", ":", "assert", "isinstance", "(", "priority", ",", "int", ")", "if", "priority", "!=", "velbus", ".", "HIGH_PRIORITY", ":", "self", ".", "parser_error", "(", "\"needs high priority set\"", ")" ]
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L209-L215
train
Check if the set of high priority items is set.
thomasdelaet/python-velbus
velbus/message.py
Message.needs_firmware_priority
def needs_firmware_priority(self, priority): """ :return: None """ assert isinstance(priority, int) if priority != velbus.FIRMWARE_PRIORITY: self.parser_error("needs firmware priority set")
python
def needs_firmware_priority(self, priority): """ :return: None """ assert isinstance(priority, int) if priority != velbus.FIRMWARE_PRIORITY: self.parser_error("needs firmware priority set")
[ "def", "needs_firmware_priority", "(", "self", ",", "priority", ")", ":", "assert", "isinstance", "(", "priority", ",", "int", ")", "if", "priority", "!=", "velbus", ".", "FIRMWARE_PRIORITY", ":", "self", ".", "parser_error", "(", "\"needs firmware priority set\""...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L223-L229
train
Check if the given priority is set.
thomasdelaet/python-velbus
velbus/message.py
Message.needs_data
def needs_data(self, data, length): """ :return: None """ assert isinstance(data, bytes) if len(data) < length: self.parser_error("needs " + str(length) + " bytes of data have " + str(len(data)))
python
def needs_data(self, data, length): """ :return: None """ assert isinstance(data, bytes) if len(data) < length: self.parser_error("needs " + str(length) + " bytes of data have " + str(len(data)))
[ "def", "needs_data", "(", "self", ",", "data", ",", "length", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "if", "len", "(", "data", ")", "<", "length", ":", "self", ".", "parser_error", "(", "\"needs \"", "+", "str", "(", "lengt...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L245-L251
train
Check that the data is at least length bytes.
thomasdelaet/python-velbus
velbus/message.py
Message.needs_fixed_byte
def needs_fixed_byte(self, byte, value): """ :return: None """ assert isinstance(byte, int) assert isinstance(value, int) assert byte >= 0 and value >= 0 assert byte <= 0xff and value <= 0xff if byte != value: self.parser_error("expect...
python
def needs_fixed_byte(self, byte, value): """ :return: None """ assert isinstance(byte, int) assert isinstance(value, int) assert byte >= 0 and value >= 0 assert byte <= 0xff and value <= 0xff if byte != value: self.parser_error("expect...
[ "def", "needs_fixed_byte", "(", "self", ",", "byte", ",", "value", ")", ":", "assert", "isinstance", "(", "byte", ",", "int", ")", "assert", "isinstance", "(", "value", ",", "int", ")", "assert", "byte", ">=", "0", "and", "value", ">=", "0", "assert", ...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L253-L262
train
Check that the given byte is a fixed byte.
thomasdelaet/python-velbus
velbus/message.py
Message.needs_one_channel
def needs_one_channel(self, channels): """ :return: None """ assert isinstance(channels, list) if len(channels) != 1 or not isinstance(channels[0], int) or \ not channels[0] > 0 or not channels[0] <= 8: self.parser_error("needs exactly one bit s...
python
def needs_one_channel(self, channels): """ :return: None """ assert isinstance(channels, list) if len(channels) != 1 or not isinstance(channels[0], int) or \ not channels[0] > 0 or not channels[0] <= 8: self.parser_error("needs exactly one bit s...
[ "def", "needs_one_channel", "(", "self", ",", "channels", ")", ":", "assert", "isinstance", "(", "channels", ",", "list", ")", "if", "len", "(", "channels", ")", "!=", "1", "or", "not", "isinstance", "(", "channels", "[", "0", "]", ",", "int", ")", "...
:return: None
[ ":", "return", ":", "None" ]
af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/message.py#L264-L271
train
Check that at least one channel is set in the given byte.
mozilla/FoxPuppet
foxpuppet/windows/browser/navbar.py
NavBar.is_tracking_shield_displayed
def is_tracking_shield_displayed(self): """Tracking Protection shield. Returns: bool: True or False if the Tracking Shield is displayed. """ with self.selenium.context(self.selenium.CONTEXT_CHROME): if self.window.firefox_version >= 63: # Bug 1471713, 1476218 ...
python
def is_tracking_shield_displayed(self): """Tracking Protection shield. Returns: bool: True or False if the Tracking Shield is displayed. """ with self.selenium.context(self.selenium.CONTEXT_CHROME): if self.window.firefox_version >= 63: # Bug 1471713, 1476218 ...
[ "def", "is_tracking_shield_displayed", "(", "self", ")", ":", "with", "self", ".", "selenium", ".", "context", "(", "self", ".", "selenium", ".", "CONTEXT_CHROME", ")", ":", "if", "self", ".", "window", ".", "firefox_version", ">=", "63", ":", "# Bug 1471713...
Tracking Protection shield. Returns: bool: True or False if the Tracking Shield is displayed.
[ "Tracking", "Protection", "shield", "." ]
6575eb4c72fd024c986b254e198c8b4e6f68cddd
https://github.com/mozilla/FoxPuppet/blob/6575eb4c72fd024c986b254e198c8b4e6f68cddd/foxpuppet/windows/browser/navbar.py#L26-L38
train
Returns True if the Tracking Protection shield is displayed.
sontek/bulby
bulby/client.py
HueBridgeClient.validate_registration
def validate_registration(self): ''' Checks if the device + username have already been registered with the bridge. ''' url = '/api/%s' % self.username response = self.make_request('GET', url) if 'error' in response: return False return True
python
def validate_registration(self): ''' Checks if the device + username have already been registered with the bridge. ''' url = '/api/%s' % self.username response = self.make_request('GET', url) if 'error' in response: return False return True
[ "def", "validate_registration", "(", "self", ")", ":", "url", "=", "'/api/%s'", "%", "self", ".", "username", "response", "=", "self", ".", "make_request", "(", "'GET'", ",", "url", ")", "if", "'error'", "in", "response", ":", "return", "False", "return", ...
Checks if the device + username have already been registered with the bridge.
[ "Checks", "if", "the", "device", "+", "username", "have", "already", "been", "registered", "with", "the", "bridge", "." ]
a2e741f843ee8e361b50a6079601108bfbe52526
https://github.com/sontek/bulby/blob/a2e741f843ee8e361b50a6079601108bfbe52526/bulby/client.py#L64-L75
train
Checks if the device + username has already been registered with the the bridge.
sontek/bulby
bulby/client.py
HueBridgeClient.connect
def connect(self): ''' Registers a new device + username with the bridge ''' # Don't try to register if we already have if self.validate_registration(): return True body = { 'devicetype': self.device_type, 'username': self.username, ...
python
def connect(self): ''' Registers a new device + username with the bridge ''' # Don't try to register if we already have if self.validate_registration(): return True body = { 'devicetype': self.device_type, 'username': self.username, ...
[ "def", "connect", "(", "self", ")", ":", "# Don't try to register if we already have", "if", "self", ".", "validate_registration", "(", ")", ":", "return", "True", "body", "=", "{", "'devicetype'", ":", "self", ".", "device_type", ",", "'username'", ":", "self",...
Registers a new device + username with the bridge
[ "Registers", "a", "new", "device", "+", "username", "with", "the", "bridge" ]
a2e741f843ee8e361b50a6079601108bfbe52526
https://github.com/sontek/bulby/blob/a2e741f843ee8e361b50a6079601108bfbe52526/bulby/client.py#L77-L97
train
Connect to the device.