id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
231,500
neo4j/neo4j-python-driver
neo4j/types/spatial.py
dehydrate_point
def dehydrate_point(value): """ Dehydrator for Point data. :param value: :type value: Point :return: """ dim = len(value) if dim == 2: return Structure(b"X", value.srid, *value) elif dim == 3: return Structure(b"Y", value.srid, *value) else: raise ValueError("Cannot dehydrate Point with %d dimensions" % dim)
python
def dehydrate_point(value): """ Dehydrator for Point data. :param value: :type value: Point :return: """ dim = len(value) if dim == 2: return Structure(b"X", value.srid, *value) elif dim == 3: return Structure(b"Y", value.srid, *value) else: raise ValueError("Cannot dehydrate Point with %d dimensions" % dim)
[ "def", "dehydrate_point", "(", "value", ")", ":", "dim", "=", "len", "(", "value", ")", "if", "dim", "==", "2", ":", "return", "Structure", "(", "b\"X\"", ",", "value", ".", "srid", ",", "*", "value", ")", "elif", "dim", "==", "3", ":", "return", "Structure", "(", "b\"Y\"", ",", "value", ".", "srid", ",", "*", "value", ")", "else", ":", "raise", "ValueError", "(", "\"Cannot dehydrate Point with %d dimensions\"", "%", "dim", ")" ]
Dehydrator for Point data. :param value: :type value: Point :return:
[ "Dehydrator", "for", "Point", "data", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/spatial.py#L122-L135
231,501
neo4j/neo4j-python-driver
neo4j/types/__init__.py
PackStreamDehydrator.dehydrate
def dehydrate(self, values): """ Convert native values into PackStream values. """ def dehydrate_(obj): try: f = self.dehydration_functions[type(obj)] except KeyError: pass else: return f(obj) if obj is None: return None elif isinstance(obj, bool): return obj elif isinstance(obj, int): if INT64_MIN <= obj <= INT64_MAX: return obj raise ValueError("Integer out of bounds (64-bit signed integer values only)") elif isinstance(obj, float): return obj elif isinstance(obj, str): return obj elif isinstance(obj, (bytes, bytearray)): # order is important here - bytes must be checked after string if self.supports_bytes: return obj else: raise TypeError("This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)") elif isinstance(obj, (list, map_type)): return list(map(dehydrate_, obj)) elif isinstance(obj, dict): if any(not isinstance(key, str) for key in obj.keys()): raise TypeError("Non-string dictionary keys are not supported") return {key: dehydrate_(value) for key, value in obj.items()} else: raise TypeError(obj) return tuple(map(dehydrate_, values))
python
def dehydrate(self, values): """ Convert native values into PackStream values. """ def dehydrate_(obj): try: f = self.dehydration_functions[type(obj)] except KeyError: pass else: return f(obj) if obj is None: return None elif isinstance(obj, bool): return obj elif isinstance(obj, int): if INT64_MIN <= obj <= INT64_MAX: return obj raise ValueError("Integer out of bounds (64-bit signed integer values only)") elif isinstance(obj, float): return obj elif isinstance(obj, str): return obj elif isinstance(obj, (bytes, bytearray)): # order is important here - bytes must be checked after string if self.supports_bytes: return obj else: raise TypeError("This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)") elif isinstance(obj, (list, map_type)): return list(map(dehydrate_, obj)) elif isinstance(obj, dict): if any(not isinstance(key, str) for key in obj.keys()): raise TypeError("Non-string dictionary keys are not supported") return {key: dehydrate_(value) for key, value in obj.items()} else: raise TypeError(obj) return tuple(map(dehydrate_, values))
[ "def", "dehydrate", "(", "self", ",", "values", ")", ":", "def", "dehydrate_", "(", "obj", ")", ":", "try", ":", "f", "=", "self", ".", "dehydration_functions", "[", "type", "(", "obj", ")", "]", "except", "KeyError", ":", "pass", "else", ":", "return", "f", "(", "obj", ")", "if", "obj", "is", "None", ":", "return", "None", "elif", "isinstance", "(", "obj", ",", "bool", ")", ":", "return", "obj", "elif", "isinstance", "(", "obj", ",", "int", ")", ":", "if", "INT64_MIN", "<=", "obj", "<=", "INT64_MAX", ":", "return", "obj", "raise", "ValueError", "(", "\"Integer out of bounds (64-bit signed integer values only)\"", ")", "elif", "isinstance", "(", "obj", ",", "float", ")", ":", "return", "obj", "elif", "isinstance", "(", "obj", ",", "str", ")", ":", "return", "obj", "elif", "isinstance", "(", "obj", ",", "(", "bytes", ",", "bytearray", ")", ")", ":", "# order is important here - bytes must be checked after string", "if", "self", ".", "supports_bytes", ":", "return", "obj", "else", ":", "raise", "TypeError", "(", "\"This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)\"", ")", "elif", "isinstance", "(", "obj", ",", "(", "list", ",", "map_type", ")", ")", ":", "return", "list", "(", "map", "(", "dehydrate_", ",", "obj", ")", ")", "elif", "isinstance", "(", "obj", ",", "dict", ")", ":", "if", "any", "(", "not", "isinstance", "(", "key", ",", "str", ")", "for", "key", "in", "obj", ".", "keys", "(", ")", ")", ":", "raise", "TypeError", "(", "\"Non-string dictionary keys are not supported\"", ")", "return", "{", "key", ":", "dehydrate_", "(", "value", ")", "for", "key", ",", "value", "in", "obj", ".", "items", "(", ")", "}", "else", ":", "raise", "TypeError", "(", "obj", ")", "return", "tuple", "(", "map", "(", "dehydrate_", ",", "values", ")", ")" ]
Convert native values into PackStream values.
[ "Convert", "native", "values", "into", "PackStream", "values", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/__init__.py#L97-L134
231,502
neo4j/neo4j-python-driver
neo4j/types/__init__.py
Record.get
def get(self, key, default=None): """ Obtain a value from the record by key, returning a default value if the key does not exist. :param key: :param default: :return: """ try: index = self.__keys.index(str(key)) except ValueError: return default if 0 <= index < len(self): return super(Record, self).__getitem__(index) else: return default
python
def get(self, key, default=None): """ Obtain a value from the record by key, returning a default value if the key does not exist. :param key: :param default: :return: """ try: index = self.__keys.index(str(key)) except ValueError: return default if 0 <= index < len(self): return super(Record, self).__getitem__(index) else: return default
[ "def", "get", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "try", ":", "index", "=", "self", ".", "__keys", ".", "index", "(", "str", "(", "key", ")", ")", "except", "ValueError", ":", "return", "default", "if", "0", "<=", "index", "<", "len", "(", "self", ")", ":", "return", "super", "(", "Record", ",", "self", ")", ".", "__getitem__", "(", "index", ")", "else", ":", "return", "default" ]
Obtain a value from the record by key, returning a default value if the key does not exist. :param key: :param default: :return:
[ "Obtain", "a", "value", "from", "the", "record", "by", "key", "returning", "a", "default", "value", "if", "the", "key", "does", "not", "exist", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/__init__.py#L202-L217
231,503
neo4j/neo4j-python-driver
neo4j/types/__init__.py
Record.index
def index(self, key): """ Return the index of the given item. :param key: :return: """ if isinstance(key, int): if 0 <= key < len(self.__keys): return key raise IndexError(key) elif isinstance(key, str): try: return self.__keys.index(key) except ValueError: raise KeyError(key) else: raise TypeError(key)
python
def index(self, key): """ Return the index of the given item. :param key: :return: """ if isinstance(key, int): if 0 <= key < len(self.__keys): return key raise IndexError(key) elif isinstance(key, str): try: return self.__keys.index(key) except ValueError: raise KeyError(key) else: raise TypeError(key)
[ "def", "index", "(", "self", ",", "key", ")", ":", "if", "isinstance", "(", "key", ",", "int", ")", ":", "if", "0", "<=", "key", "<", "len", "(", "self", ".", "__keys", ")", ":", "return", "key", "raise", "IndexError", "(", "key", ")", "elif", "isinstance", "(", "key", ",", "str", ")", ":", "try", ":", "return", "self", ".", "__keys", ".", "index", "(", "key", ")", "except", "ValueError", ":", "raise", "KeyError", "(", "key", ")", "else", ":", "raise", "TypeError", "(", "key", ")" ]
Return the index of the given item. :param key: :return:
[ "Return", "the", "index", "of", "the", "given", "item", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/__init__.py#L219-L235
231,504
neo4j/neo4j-python-driver
neo4j/types/__init__.py
Record.value
def value(self, key=0, default=None): """ Obtain a single value from the record by index or key. If no index or key is specified, the first value is returned. If the specified item does not exist, the default value is returned. :param key: :param default: :return: """ try: index = self.index(key) except (IndexError, KeyError): return default else: return self[index]
python
def value(self, key=0, default=None): """ Obtain a single value from the record by index or key. If no index or key is specified, the first value is returned. If the specified item does not exist, the default value is returned. :param key: :param default: :return: """ try: index = self.index(key) except (IndexError, KeyError): return default else: return self[index]
[ "def", "value", "(", "self", ",", "key", "=", "0", ",", "default", "=", "None", ")", ":", "try", ":", "index", "=", "self", ".", "index", "(", "key", ")", "except", "(", "IndexError", ",", "KeyError", ")", ":", "return", "default", "else", ":", "return", "self", "[", "index", "]" ]
Obtain a single value from the record by index or key. If no index or key is specified, the first value is returned. If the specified item does not exist, the default value is returned. :param key: :param default: :return:
[ "Obtain", "a", "single", "value", "from", "the", "record", "by", "index", "or", "key", ".", "If", "no", "index", "or", "key", "is", "specified", "the", "first", "value", "is", "returned", ".", "If", "the", "specified", "item", "does", "not", "exist", "the", "default", "value", "is", "returned", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/__init__.py#L237-L251
231,505
neo4j/neo4j-python-driver
neo4j/types/__init__.py
Record.values
def values(self, *keys): """ Return the values of the record, optionally filtering to include only certain values by index or key. :param keys: indexes or keys of the items to include; if none are provided, all values will be included :return: list of values """ if keys: d = [] for key in keys: try: i = self.index(key) except KeyError: d.append(None) else: d.append(self[i]) return d return list(self)
python
def values(self, *keys): """ Return the values of the record, optionally filtering to include only certain values by index or key. :param keys: indexes or keys of the items to include; if none are provided, all values will be included :return: list of values """ if keys: d = [] for key in keys: try: i = self.index(key) except KeyError: d.append(None) else: d.append(self[i]) return d return list(self)
[ "def", "values", "(", "self", ",", "*", "keys", ")", ":", "if", "keys", ":", "d", "=", "[", "]", "for", "key", "in", "keys", ":", "try", ":", "i", "=", "self", ".", "index", "(", "key", ")", "except", "KeyError", ":", "d", ".", "append", "(", "None", ")", "else", ":", "d", ".", "append", "(", "self", "[", "i", "]", ")", "return", "d", "return", "list", "(", "self", ")" ]
Return the values of the record, optionally filtering to include only certain values by index or key. :param keys: indexes or keys of the items to include; if none are provided, all values will be included :return: list of values
[ "Return", "the", "values", "of", "the", "record", "optionally", "filtering", "to", "include", "only", "certain", "values", "by", "index", "or", "key", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/__init__.py#L260-L278
231,506
neo4j/neo4j-python-driver
neo4j/types/__init__.py
Record.items
def items(self, *keys): """ Return the fields of the record as a list of key and value tuples :return: """ if keys: d = [] for key in keys: try: i = self.index(key) except KeyError: d.append((key, None)) else: d.append((self.__keys[i], self[i])) return d return list((self.__keys[i], super(Record, self).__getitem__(i)) for i in range(len(self)))
python
def items(self, *keys): """ Return the fields of the record as a list of key and value tuples :return: """ if keys: d = [] for key in keys: try: i = self.index(key) except KeyError: d.append((key, None)) else: d.append((self.__keys[i], self[i])) return d return list((self.__keys[i], super(Record, self).__getitem__(i)) for i in range(len(self)))
[ "def", "items", "(", "self", ",", "*", "keys", ")", ":", "if", "keys", ":", "d", "=", "[", "]", "for", "key", "in", "keys", ":", "try", ":", "i", "=", "self", ".", "index", "(", "key", ")", "except", "KeyError", ":", "d", ".", "append", "(", "(", "key", ",", "None", ")", ")", "else", ":", "d", ".", "append", "(", "(", "self", ".", "__keys", "[", "i", "]", ",", "self", "[", "i", "]", ")", ")", "return", "d", "return", "list", "(", "(", "self", ".", "__keys", "[", "i", "]", ",", "super", "(", "Record", ",", "self", ")", ".", "__getitem__", "(", "i", ")", ")", "for", "i", "in", "range", "(", "len", "(", "self", ")", ")", ")" ]
Return the fields of the record as a list of key and value tuples :return:
[ "Return", "the", "fields", "of", "the", "record", "as", "a", "list", "of", "key", "and", "value", "tuples" ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/__init__.py#L280-L295
231,507
neo4j/neo4j-python-driver
neo4j/blocking.py
_make_plan
def _make_plan(plan_dict): """ Construct a Plan or ProfiledPlan from a dictionary of metadata values. :param plan_dict: :return: """ operator_type = plan_dict["operatorType"] identifiers = plan_dict.get("identifiers", []) arguments = plan_dict.get("args", []) children = [_make_plan(child) for child in plan_dict.get("children", [])] if "dbHits" in plan_dict or "rows" in plan_dict: db_hits = plan_dict.get("dbHits", 0) rows = plan_dict.get("rows", 0) return ProfiledPlan(operator_type, identifiers, arguments, children, db_hits, rows) else: return Plan(operator_type, identifiers, arguments, children)
python
def _make_plan(plan_dict): """ Construct a Plan or ProfiledPlan from a dictionary of metadata values. :param plan_dict: :return: """ operator_type = plan_dict["operatorType"] identifiers = plan_dict.get("identifiers", []) arguments = plan_dict.get("args", []) children = [_make_plan(child) for child in plan_dict.get("children", [])] if "dbHits" in plan_dict or "rows" in plan_dict: db_hits = plan_dict.get("dbHits", 0) rows = plan_dict.get("rows", 0) return ProfiledPlan(operator_type, identifiers, arguments, children, db_hits, rows) else: return Plan(operator_type, identifiers, arguments, children)
[ "def", "_make_plan", "(", "plan_dict", ")", ":", "operator_type", "=", "plan_dict", "[", "\"operatorType\"", "]", "identifiers", "=", "plan_dict", ".", "get", "(", "\"identifiers\"", ",", "[", "]", ")", "arguments", "=", "plan_dict", ".", "get", "(", "\"args\"", ",", "[", "]", ")", "children", "=", "[", "_make_plan", "(", "child", ")", "for", "child", "in", "plan_dict", ".", "get", "(", "\"children\"", ",", "[", "]", ")", "]", "if", "\"dbHits\"", "in", "plan_dict", "or", "\"rows\"", "in", "plan_dict", ":", "db_hits", "=", "plan_dict", ".", "get", "(", "\"dbHits\"", ",", "0", ")", "rows", "=", "plan_dict", ".", "get", "(", "\"rows\"", ",", "0", ")", "return", "ProfiledPlan", "(", "operator_type", ",", "identifiers", ",", "arguments", ",", "children", ",", "db_hits", ",", "rows", ")", "else", ":", "return", "Plan", "(", "operator_type", ",", "identifiers", ",", "arguments", ",", "children", ")" ]
Construct a Plan or ProfiledPlan from a dictionary of metadata values. :param plan_dict: :return:
[ "Construct", "a", "Plan", "or", "ProfiledPlan", "from", "a", "dictionary", "of", "metadata", "values", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L962-L977
231,508
neo4j/neo4j-python-driver
neo4j/blocking.py
unit_of_work
def unit_of_work(metadata=None, timeout=None): """ This function is a decorator for transaction functions that allows extra control over how the transaction is carried out. For example, a timeout (in seconds) may be applied:: @unit_of_work(timeout=25.0) def count_people(tx): return tx.run("MATCH (a:Person) RETURN count(a)").single().value() """ def wrapper(f): def wrapped(*args, **kwargs): return f(*args, **kwargs) wrapped.metadata = metadata wrapped.timeout = timeout return wrapped return wrapper
python
def unit_of_work(metadata=None, timeout=None): """ This function is a decorator for transaction functions that allows extra control over how the transaction is carried out. For example, a timeout (in seconds) may be applied:: @unit_of_work(timeout=25.0) def count_people(tx): return tx.run("MATCH (a:Person) RETURN count(a)").single().value() """ def wrapper(f): def wrapped(*args, **kwargs): return f(*args, **kwargs) wrapped.metadata = metadata wrapped.timeout = timeout return wrapped return wrapper
[ "def", "unit_of_work", "(", "metadata", "=", "None", ",", "timeout", "=", "None", ")", ":", "def", "wrapper", "(", "f", ")", ":", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "wrapped", ".", "metadata", "=", "metadata", "wrapped", ".", "timeout", "=", "timeout", "return", "wrapped", "return", "wrapper" ]
This function is a decorator for transaction functions that allows extra control over how the transaction is carried out. For example, a timeout (in seconds) may be applied:: @unit_of_work(timeout=25.0) def count_people(tx): return tx.run("MATCH (a:Person) RETURN count(a)").single().value()
[ "This", "function", "is", "a", "decorator", "for", "transaction", "functions", "that", "allows", "extra", "control", "over", "how", "the", "transaction", "is", "carried", "out", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L1007-L1028
231,509
neo4j/neo4j-python-driver
neo4j/blocking.py
Session.close
def close(self): """ Close the session. This will release any borrowed resources, such as connections, and will roll back any outstanding transactions. """ from neobolt.exceptions import ConnectionExpired, CypherError, ServiceUnavailable try: if self.has_transaction(): try: self.rollback_transaction() except (CypherError, TransactionError, SessionError, ConnectionExpired, ServiceUnavailable): pass finally: self._closed = True self._disconnect(sync=True)
python
def close(self): """ Close the session. This will release any borrowed resources, such as connections, and will roll back any outstanding transactions. """ from neobolt.exceptions import ConnectionExpired, CypherError, ServiceUnavailable try: if self.has_transaction(): try: self.rollback_transaction() except (CypherError, TransactionError, SessionError, ConnectionExpired, ServiceUnavailable): pass finally: self._closed = True self._disconnect(sync=True)
[ "def", "close", "(", "self", ")", ":", "from", "neobolt", ".", "exceptions", "import", "ConnectionExpired", ",", "CypherError", ",", "ServiceUnavailable", "try", ":", "if", "self", ".", "has_transaction", "(", ")", ":", "try", ":", "self", ".", "rollback_transaction", "(", ")", "except", "(", "CypherError", ",", "TransactionError", ",", "SessionError", ",", "ConnectionExpired", ",", "ServiceUnavailable", ")", ":", "pass", "finally", ":", "self", ".", "_closed", "=", "True", "self", ".", "_disconnect", "(", "sync", "=", "True", ")" ]
Close the session. This will release any borrowed resources, such as connections, and will roll back any outstanding transactions.
[ "Close", "the", "session", ".", "This", "will", "release", "any", "borrowed", "resources", "such", "as", "connections", "and", "will", "roll", "back", "any", "outstanding", "transactions", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L144-L157
231,510
neo4j/neo4j-python-driver
neo4j/blocking.py
Session.run
def run(self, statement, parameters=None, **kwparameters): """ Run a Cypher statement within an auto-commit transaction. The statement is sent and the result header received immediately but the :class:`.StatementResult` content is fetched lazily as consumed by the client application. If a statement is executed before a previous :class:`.StatementResult` in the same :class:`.Session` has been fully consumed, the first result will be fully fetched and buffered. Note therefore that the generally recommended pattern of usage is to fully consume one result before executing a subsequent statement. If two results need to be consumed in parallel, multiple :class:`.Session` objects can be used as an alternative to result buffering. For more usage details, see :meth:`.Transaction.run`. :param statement: template Cypher statement :param parameters: dictionary of parameters :param kwparameters: additional keyword parameters :returns: :class:`.StatementResult` object """ from neobolt.exceptions import ConnectionExpired self._assert_open() if not statement: raise ValueError("Cannot run an empty statement") if not isinstance(statement, (str, Statement)): raise TypeError("Statement must be a string or a Statement instance") if not self._connection: self._connect() cx = self._connection protocol_version = cx.protocol_version server = cx.server has_transaction = self.has_transaction() statement_text = str(statement) statement_metadata = getattr(statement, "metadata", None) statement_timeout = getattr(statement, "timeout", None) parameters = fix_parameters(dict(parameters or {}, **kwparameters), protocol_version, supports_bytes=server.supports("bytes")) def fail(_): self._close_transaction() hydrant = PackStreamHydrator(protocol_version) result_metadata = { "statement": statement_text, "parameters": parameters, "server": server, "protocol_version": protocol_version, } run_metadata = { "metadata": statement_metadata, "timeout": statement_timeout, "on_success": result_metadata.update, "on_failure": fail, } def done(summary_metadata): result_metadata.update(summary_metadata) bookmark = result_metadata.get("bookmark") if bookmark: self._bookmarks_in = tuple([bookmark]) self._bookmark_out = bookmark self._last_result = result = BoltStatementResult(self, hydrant, result_metadata) if has_transaction: if statement_metadata: raise ValueError("Metadata can only be attached at transaction level") if statement_timeout: raise ValueError("Timeouts only apply at transaction level") else: run_metadata["bookmarks"] = self._bookmarks_in cx.run(statement_text, parameters, **run_metadata) cx.pull_all( on_records=lambda records: result._records.extend( hydrant.hydrate_records(result.keys(), records)), on_success=done, on_failure=fail, on_summary=lambda: result.detach(sync=False), ) if not has_transaction: try: self._connection.send() self._connection.fetch() except ConnectionExpired as error: raise SessionExpired(*error.args) return result
python
def run(self, statement, parameters=None, **kwparameters): """ Run a Cypher statement within an auto-commit transaction. The statement is sent and the result header received immediately but the :class:`.StatementResult` content is fetched lazily as consumed by the client application. If a statement is executed before a previous :class:`.StatementResult` in the same :class:`.Session` has been fully consumed, the first result will be fully fetched and buffered. Note therefore that the generally recommended pattern of usage is to fully consume one result before executing a subsequent statement. If two results need to be consumed in parallel, multiple :class:`.Session` objects can be used as an alternative to result buffering. For more usage details, see :meth:`.Transaction.run`. :param statement: template Cypher statement :param parameters: dictionary of parameters :param kwparameters: additional keyword parameters :returns: :class:`.StatementResult` object """ from neobolt.exceptions import ConnectionExpired self._assert_open() if not statement: raise ValueError("Cannot run an empty statement") if not isinstance(statement, (str, Statement)): raise TypeError("Statement must be a string or a Statement instance") if not self._connection: self._connect() cx = self._connection protocol_version = cx.protocol_version server = cx.server has_transaction = self.has_transaction() statement_text = str(statement) statement_metadata = getattr(statement, "metadata", None) statement_timeout = getattr(statement, "timeout", None) parameters = fix_parameters(dict(parameters or {}, **kwparameters), protocol_version, supports_bytes=server.supports("bytes")) def fail(_): self._close_transaction() hydrant = PackStreamHydrator(protocol_version) result_metadata = { "statement": statement_text, "parameters": parameters, "server": server, "protocol_version": protocol_version, } run_metadata = { "metadata": statement_metadata, "timeout": statement_timeout, "on_success": result_metadata.update, "on_failure": fail, } def done(summary_metadata): result_metadata.update(summary_metadata) bookmark = result_metadata.get("bookmark") if bookmark: self._bookmarks_in = tuple([bookmark]) self._bookmark_out = bookmark self._last_result = result = BoltStatementResult(self, hydrant, result_metadata) if has_transaction: if statement_metadata: raise ValueError("Metadata can only be attached at transaction level") if statement_timeout: raise ValueError("Timeouts only apply at transaction level") else: run_metadata["bookmarks"] = self._bookmarks_in cx.run(statement_text, parameters, **run_metadata) cx.pull_all( on_records=lambda records: result._records.extend( hydrant.hydrate_records(result.keys(), records)), on_success=done, on_failure=fail, on_summary=lambda: result.detach(sync=False), ) if not has_transaction: try: self._connection.send() self._connection.fetch() except ConnectionExpired as error: raise SessionExpired(*error.args) return result
[ "def", "run", "(", "self", ",", "statement", ",", "parameters", "=", "None", ",", "*", "*", "kwparameters", ")", ":", "from", "neobolt", ".", "exceptions", "import", "ConnectionExpired", "self", ".", "_assert_open", "(", ")", "if", "not", "statement", ":", "raise", "ValueError", "(", "\"Cannot run an empty statement\"", ")", "if", "not", "isinstance", "(", "statement", ",", "(", "str", ",", "Statement", ")", ")", ":", "raise", "TypeError", "(", "\"Statement must be a string or a Statement instance\"", ")", "if", "not", "self", ".", "_connection", ":", "self", ".", "_connect", "(", ")", "cx", "=", "self", ".", "_connection", "protocol_version", "=", "cx", ".", "protocol_version", "server", "=", "cx", ".", "server", "has_transaction", "=", "self", ".", "has_transaction", "(", ")", "statement_text", "=", "str", "(", "statement", ")", "statement_metadata", "=", "getattr", "(", "statement", ",", "\"metadata\"", ",", "None", ")", "statement_timeout", "=", "getattr", "(", "statement", ",", "\"timeout\"", ",", "None", ")", "parameters", "=", "fix_parameters", "(", "dict", "(", "parameters", "or", "{", "}", ",", "*", "*", "kwparameters", ")", ",", "protocol_version", ",", "supports_bytes", "=", "server", ".", "supports", "(", "\"bytes\"", ")", ")", "def", "fail", "(", "_", ")", ":", "self", ".", "_close_transaction", "(", ")", "hydrant", "=", "PackStreamHydrator", "(", "protocol_version", ")", "result_metadata", "=", "{", "\"statement\"", ":", "statement_text", ",", "\"parameters\"", ":", "parameters", ",", "\"server\"", ":", "server", ",", "\"protocol_version\"", ":", "protocol_version", ",", "}", "run_metadata", "=", "{", "\"metadata\"", ":", "statement_metadata", ",", "\"timeout\"", ":", "statement_timeout", ",", "\"on_success\"", ":", "result_metadata", ".", "update", ",", "\"on_failure\"", ":", "fail", ",", "}", "def", "done", "(", "summary_metadata", ")", ":", "result_metadata", ".", "update", "(", "summary_metadata", ")", "bookmark", "=", "result_metadata", ".", "get", "(", "\"bookmark\"", ")", "if", "bookmark", ":", "self", ".", "_bookmarks_in", "=", "tuple", "(", "[", "bookmark", "]", ")", "self", ".", "_bookmark_out", "=", "bookmark", "self", ".", "_last_result", "=", "result", "=", "BoltStatementResult", "(", "self", ",", "hydrant", ",", "result_metadata", ")", "if", "has_transaction", ":", "if", "statement_metadata", ":", "raise", "ValueError", "(", "\"Metadata can only be attached at transaction level\"", ")", "if", "statement_timeout", ":", "raise", "ValueError", "(", "\"Timeouts only apply at transaction level\"", ")", "else", ":", "run_metadata", "[", "\"bookmarks\"", "]", "=", "self", ".", "_bookmarks_in", "cx", ".", "run", "(", "statement_text", ",", "parameters", ",", "*", "*", "run_metadata", ")", "cx", ".", "pull_all", "(", "on_records", "=", "lambda", "records", ":", "result", ".", "_records", ".", "extend", "(", "hydrant", ".", "hydrate_records", "(", "result", ".", "keys", "(", ")", ",", "records", ")", ")", ",", "on_success", "=", "done", ",", "on_failure", "=", "fail", ",", "on_summary", "=", "lambda", ":", "result", ".", "detach", "(", "sync", "=", "False", ")", ",", ")", "if", "not", "has_transaction", ":", "try", ":", "self", ".", "_connection", ".", "send", "(", ")", "self", ".", "_connection", ".", "fetch", "(", ")", "except", "ConnectionExpired", "as", "error", ":", "raise", "SessionExpired", "(", "*", "error", ".", "args", ")", "return", "result" ]
Run a Cypher statement within an auto-commit transaction. The statement is sent and the result header received immediately but the :class:`.StatementResult` content is fetched lazily as consumed by the client application. If a statement is executed before a previous :class:`.StatementResult` in the same :class:`.Session` has been fully consumed, the first result will be fully fetched and buffered. Note therefore that the generally recommended pattern of usage is to fully consume one result before executing a subsequent statement. If two results need to be consumed in parallel, multiple :class:`.Session` objects can be used as an alternative to result buffering. For more usage details, see :meth:`.Transaction.run`. :param statement: template Cypher statement :param parameters: dictionary of parameters :param kwparameters: additional keyword parameters :returns: :class:`.StatementResult` object
[ "Run", "a", "Cypher", "statement", "within", "an", "auto", "-", "commit", "transaction", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L166-L261
231,511
neo4j/neo4j-python-driver
neo4j/blocking.py
Session.send
def send(self): """ Send all outstanding requests. """ from neobolt.exceptions import ConnectionExpired if self._connection: try: self._connection.send() except ConnectionExpired as error: raise SessionExpired(*error.args)
python
def send(self): """ Send all outstanding requests. """ from neobolt.exceptions import ConnectionExpired if self._connection: try: self._connection.send() except ConnectionExpired as error: raise SessionExpired(*error.args)
[ "def", "send", "(", "self", ")", ":", "from", "neobolt", ".", "exceptions", "import", "ConnectionExpired", "if", "self", ".", "_connection", ":", "try", ":", "self", ".", "_connection", ".", "send", "(", ")", "except", "ConnectionExpired", "as", "error", ":", "raise", "SessionExpired", "(", "*", "error", ".", "args", ")" ]
Send all outstanding requests.
[ "Send", "all", "outstanding", "requests", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L263-L271
231,512
neo4j/neo4j-python-driver
neo4j/blocking.py
Session.fetch
def fetch(self): """ Attempt to fetch at least one more record. :returns: number of records fetched """ from neobolt.exceptions import ConnectionExpired if self._connection: try: detail_count, _ = self._connection.fetch() except ConnectionExpired as error: raise SessionExpired(*error.args) else: return detail_count return 0
python
def fetch(self): """ Attempt to fetch at least one more record. :returns: number of records fetched """ from neobolt.exceptions import ConnectionExpired if self._connection: try: detail_count, _ = self._connection.fetch() except ConnectionExpired as error: raise SessionExpired(*error.args) else: return detail_count return 0
[ "def", "fetch", "(", "self", ")", ":", "from", "neobolt", ".", "exceptions", "import", "ConnectionExpired", "if", "self", ".", "_connection", ":", "try", ":", "detail_count", ",", "_", "=", "self", ".", "_connection", ".", "fetch", "(", ")", "except", "ConnectionExpired", "as", "error", ":", "raise", "SessionExpired", "(", "*", "error", ".", "args", ")", "else", ":", "return", "detail_count", "return", "0" ]
Attempt to fetch at least one more record. :returns: number of records fetched
[ "Attempt", "to", "fetch", "at", "least", "one", "more", "record", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L273-L286
231,513
neo4j/neo4j-python-driver
neo4j/blocking.py
Session.detach
def detach(self, result, sync=True): """ Detach a result from this session by fetching and buffering any remaining records. :param result: :param sync: :returns: number of records fetched """ count = 0 if sync and result.attached(): self.send() fetch = self.fetch while result.attached(): count += fetch() if self._last_result is result: self._last_result = None if not self.has_transaction(): self._disconnect(sync=False) result._session = None return count
python
def detach(self, result, sync=True): """ Detach a result from this session by fetching and buffering any remaining records. :param result: :param sync: :returns: number of records fetched """ count = 0 if sync and result.attached(): self.send() fetch = self.fetch while result.attached(): count += fetch() if self._last_result is result: self._last_result = None if not self.has_transaction(): self._disconnect(sync=False) result._session = None return count
[ "def", "detach", "(", "self", ",", "result", ",", "sync", "=", "True", ")", ":", "count", "=", "0", "if", "sync", "and", "result", ".", "attached", "(", ")", ":", "self", ".", "send", "(", ")", "fetch", "=", "self", ".", "fetch", "while", "result", ".", "attached", "(", ")", ":", "count", "+=", "fetch", "(", ")", "if", "self", ".", "_last_result", "is", "result", ":", "self", ".", "_last_result", "=", "None", "if", "not", "self", ".", "has_transaction", "(", ")", ":", "self", ".", "_disconnect", "(", "sync", "=", "False", ")", "result", ".", "_session", "=", "None", "return", "count" ]
Detach a result from this session by fetching and buffering any remaining records. :param result: :param sync: :returns: number of records fetched
[ "Detach", "a", "result", "from", "this", "session", "by", "fetching", "and", "buffering", "any", "remaining", "records", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L303-L325
231,514
neo4j/neo4j-python-driver
neo4j/blocking.py
Transaction.run
def run(self, statement, parameters=None, **kwparameters): """ Run a Cypher statement within the context of this transaction. The statement is sent to the server lazily, when its result is consumed. To force the statement to be sent to the server, use the :meth:`.Transaction.sync` method. Cypher is typically expressed as a statement template plus a set of named parameters. In Python, parameters may be expressed through a dictionary of parameters, through individual parameter arguments, or as a mixture of both. For example, the `run` statements below are all equivalent:: >>> statement = "CREATE (a:Person {name:{name}, age:{age}})" >>> tx.run(statement, {"name": "Alice", "age": 33}) >>> tx.run(statement, {"name": "Alice"}, age=33) >>> tx.run(statement, name="Alice", age=33) Parameter values can be of any type supported by the Neo4j type system. In Python, this includes :class:`bool`, :class:`int`, :class:`str`, :class:`list` and :class:`dict`. Note however that :class:`list` properties must be homogenous. :param statement: template Cypher statement :param parameters: dictionary of parameters :param kwparameters: additional keyword parameters :returns: :class:`.StatementResult` object :raise TransactionError: if the transaction is closed """ self._assert_open() return self.session.run(statement, parameters, **kwparameters)
python
def run(self, statement, parameters=None, **kwparameters): """ Run a Cypher statement within the context of this transaction. The statement is sent to the server lazily, when its result is consumed. To force the statement to be sent to the server, use the :meth:`.Transaction.sync` method. Cypher is typically expressed as a statement template plus a set of named parameters. In Python, parameters may be expressed through a dictionary of parameters, through individual parameter arguments, or as a mixture of both. For example, the `run` statements below are all equivalent:: >>> statement = "CREATE (a:Person {name:{name}, age:{age}})" >>> tx.run(statement, {"name": "Alice", "age": 33}) >>> tx.run(statement, {"name": "Alice"}, age=33) >>> tx.run(statement, name="Alice", age=33) Parameter values can be of any type supported by the Neo4j type system. In Python, this includes :class:`bool`, :class:`int`, :class:`str`, :class:`list` and :class:`dict`. Note however that :class:`list` properties must be homogenous. :param statement: template Cypher statement :param parameters: dictionary of parameters :param kwparameters: additional keyword parameters :returns: :class:`.StatementResult` object :raise TransactionError: if the transaction is closed """ self._assert_open() return self.session.run(statement, parameters, **kwparameters)
[ "def", "run", "(", "self", ",", "statement", ",", "parameters", "=", "None", ",", "*", "*", "kwparameters", ")", ":", "self", ".", "_assert_open", "(", ")", "return", "self", ".", "session", ".", "run", "(", "statement", ",", "parameters", ",", "*", "*", "kwparameters", ")" ]
Run a Cypher statement within the context of this transaction. The statement is sent to the server lazily, when its result is consumed. To force the statement to be sent to the server, use the :meth:`.Transaction.sync` method. Cypher is typically expressed as a statement template plus a set of named parameters. In Python, parameters may be expressed through a dictionary of parameters, through individual parameter arguments, or as a mixture of both. For example, the `run` statements below are all equivalent:: >>> statement = "CREATE (a:Person {name:{name}, age:{age}})" >>> tx.run(statement, {"name": "Alice", "age": 33}) >>> tx.run(statement, {"name": "Alice"}, age=33) >>> tx.run(statement, name="Alice", age=33) Parameter values can be of any type supported by the Neo4j type system. In Python, this includes :class:`bool`, :class:`int`, :class:`str`, :class:`list` and :class:`dict`. Note however that :class:`list` properties must be homogenous. :param statement: template Cypher statement :param parameters: dictionary of parameters :param kwparameters: additional keyword parameters :returns: :class:`.StatementResult` object :raise TransactionError: if the transaction is closed
[ "Run", "a", "Cypher", "statement", "within", "the", "context", "of", "this", "transaction", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L497-L527
231,515
neo4j/neo4j-python-driver
neo4j/blocking.py
StatementResult.detach
def detach(self, sync=True): """ Detach this result from its parent session by fetching the remainder of this result from the network into the buffer. :returns: number of records fetched """ if self.attached(): return self._session.detach(self, sync=sync) else: return 0
python
def detach(self, sync=True): """ Detach this result from its parent session by fetching the remainder of this result from the network into the buffer. :returns: number of records fetched """ if self.attached(): return self._session.detach(self, sync=sync) else: return 0
[ "def", "detach", "(", "self", ",", "sync", "=", "True", ")", ":", "if", "self", ".", "attached", "(", ")", ":", "return", "self", ".", "_session", ".", "detach", "(", "self", ",", "sync", "=", "sync", ")", "else", ":", "return", "0" ]
Detach this result from its parent session by fetching the remainder of this result from the network into the buffer. :returns: number of records fetched
[ "Detach", "this", "result", "from", "its", "parent", "session", "by", "fetching", "the", "remainder", "of", "this", "result", "from", "the", "network", "into", "the", "buffer", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L653-L662
231,516
neo4j/neo4j-python-driver
neo4j/blocking.py
StatementResult.keys
def keys(self): """ The keys for the records in this result. :returns: tuple of key names """ try: return self._metadata["fields"] except KeyError: if self.attached(): self._session.send() while self.attached() and "fields" not in self._metadata: self._session.fetch() return self._metadata.get("fields")
python
def keys(self): """ The keys for the records in this result. :returns: tuple of key names """ try: return self._metadata["fields"] except KeyError: if self.attached(): self._session.send() while self.attached() and "fields" not in self._metadata: self._session.fetch() return self._metadata.get("fields")
[ "def", "keys", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_metadata", "[", "\"fields\"", "]", "except", "KeyError", ":", "if", "self", ".", "attached", "(", ")", ":", "self", ".", "_session", ".", "send", "(", ")", "while", "self", ".", "attached", "(", ")", "and", "\"fields\"", "not", "in", "self", ".", "_metadata", ":", "self", ".", "_session", ".", "fetch", "(", ")", "return", "self", ".", "_metadata", ".", "get", "(", "\"fields\"", ")" ]
The keys for the records in this result. :returns: tuple of key names
[ "The", "keys", "for", "the", "records", "in", "this", "result", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L664-L676
231,517
neo4j/neo4j-python-driver
neo4j/blocking.py
StatementResult.records
def records(self): """ Generator for records obtained from this result. :yields: iterable of :class:`.Record` objects """ records = self._records next_record = records.popleft while records: yield next_record() attached = self.attached if attached(): self._session.send() while attached(): self._session.fetch() while records: yield next_record()
python
def records(self): """ Generator for records obtained from this result. :yields: iterable of :class:`.Record` objects """ records = self._records next_record = records.popleft while records: yield next_record() attached = self.attached if attached(): self._session.send() while attached(): self._session.fetch() while records: yield next_record()
[ "def", "records", "(", "self", ")", ":", "records", "=", "self", ".", "_records", "next_record", "=", "records", ".", "popleft", "while", "records", ":", "yield", "next_record", "(", ")", "attached", "=", "self", ".", "attached", "if", "attached", "(", ")", ":", "self", ".", "_session", ".", "send", "(", ")", "while", "attached", "(", ")", ":", "self", ".", "_session", ".", "fetch", "(", ")", "while", "records", ":", "yield", "next_record", "(", ")" ]
Generator for records obtained from this result. :yields: iterable of :class:`.Record` objects
[ "Generator", "for", "records", "obtained", "from", "this", "result", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L678-L693
231,518
neo4j/neo4j-python-driver
neo4j/blocking.py
StatementResult.summary
def summary(self): """ Obtain the summary of this result, buffering any remaining records. :returns: The :class:`.ResultSummary` for this result """ self.detach() if self._summary is None: self._summary = BoltStatementResultSummary(**self._metadata) return self._summary
python
def summary(self): """ Obtain the summary of this result, buffering any remaining records. :returns: The :class:`.ResultSummary` for this result """ self.detach() if self._summary is None: self._summary = BoltStatementResultSummary(**self._metadata) return self._summary
[ "def", "summary", "(", "self", ")", ":", "self", ".", "detach", "(", ")", "if", "self", ".", "_summary", "is", "None", ":", "self", ".", "_summary", "=", "BoltStatementResultSummary", "(", "*", "*", "self", ".", "_metadata", ")", "return", "self", ".", "_summary" ]
Obtain the summary of this result, buffering any remaining records. :returns: The :class:`.ResultSummary` for this result
[ "Obtain", "the", "summary", "of", "this", "result", "buffering", "any", "remaining", "records", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L695-L703
231,519
neo4j/neo4j-python-driver
neo4j/blocking.py
StatementResult.single
def single(self): """ Obtain the next and only remaining record from this result. A warning is generated if more than one record is available but the first of these is still returned. :returns: the next :class:`.Record` or :const:`None` if none remain :warns: if more than one record is available """ records = list(self) size = len(records) if size == 0: return None if size != 1: warn("Expected a result with a single record, but this result contains %d" % size) return records[0]
python
def single(self): """ Obtain the next and only remaining record from this result. A warning is generated if more than one record is available but the first of these is still returned. :returns: the next :class:`.Record` or :const:`None` if none remain :warns: if more than one record is available """ records = list(self) size = len(records) if size == 0: return None if size != 1: warn("Expected a result with a single record, but this result contains %d" % size) return records[0]
[ "def", "single", "(", "self", ")", ":", "records", "=", "list", "(", "self", ")", "size", "=", "len", "(", "records", ")", "if", "size", "==", "0", ":", "return", "None", "if", "size", "!=", "1", ":", "warn", "(", "\"Expected a result with a single record, but this result contains %d\"", "%", "size", ")", "return", "records", "[", "0", "]" ]
Obtain the next and only remaining record from this result. A warning is generated if more than one record is available but the first of these is still returned. :returns: the next :class:`.Record` or :const:`None` if none remain :warns: if more than one record is available
[ "Obtain", "the", "next", "and", "only", "remaining", "record", "from", "this", "result", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L715-L730
231,520
neo4j/neo4j-python-driver
neo4j/blocking.py
StatementResult.peek
def peek(self): """ Obtain the next record from this result without consuming it. This leaves the record in the buffer for further processing. :returns: the next :class:`.Record` or :const:`None` if none remain """ records = self._records if records: return records[0] if not self.attached(): return None if self.attached(): self._session.send() while self.attached() and not records: self._session.fetch() if records: return records[0] return None
python
def peek(self): """ Obtain the next record from this result without consuming it. This leaves the record in the buffer for further processing. :returns: the next :class:`.Record` or :const:`None` if none remain """ records = self._records if records: return records[0] if not self.attached(): return None if self.attached(): self._session.send() while self.attached() and not records: self._session.fetch() if records: return records[0] return None
[ "def", "peek", "(", "self", ")", ":", "records", "=", "self", ".", "_records", "if", "records", ":", "return", "records", "[", "0", "]", "if", "not", "self", ".", "attached", "(", ")", ":", "return", "None", "if", "self", ".", "attached", "(", ")", ":", "self", ".", "_session", ".", "send", "(", ")", "while", "self", ".", "attached", "(", ")", "and", "not", "records", ":", "self", ".", "_session", ".", "fetch", "(", ")", "if", "records", ":", "return", "records", "[", "0", "]", "return", "None" ]
Obtain the next record from this result without consuming it. This leaves the record in the buffer for further processing. :returns: the next :class:`.Record` or :const:`None` if none remain
[ "Obtain", "the", "next", "record", "from", "this", "result", "without", "consuming", "it", ".", "This", "leaves", "the", "record", "in", "the", "buffer", "for", "further", "processing", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L732-L749
231,521
neo4j/neo4j-python-driver
neo4j/blocking.py
BoltStatementResult.value
def value(self, item=0, default=None): """ Return the remainder of the result as a list of values. :param item: field to return for each remaining record :param default: default value, used if the index of key is unavailable :returns: list of individual values """ return [record.value(item, default) for record in self.records()]
python
def value(self, item=0, default=None): """ Return the remainder of the result as a list of values. :param item: field to return for each remaining record :param default: default value, used if the index of key is unavailable :returns: list of individual values """ return [record.value(item, default) for record in self.records()]
[ "def", "value", "(", "self", ",", "item", "=", "0", ",", "default", "=", "None", ")", ":", "return", "[", "record", ".", "value", "(", "item", ",", "default", ")", "for", "record", "in", "self", ".", "records", "(", ")", "]" ]
Return the remainder of the result as a list of values. :param item: field to return for each remaining record :param default: default value, used if the index of key is unavailable :returns: list of individual values
[ "Return", "the", "remainder", "of", "the", "result", "as", "a", "list", "of", "values", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L769-L776
231,522
neo4j/neo4j-python-driver
neo4j/pipelining.py
Pipeline.pull
def pull(self): """Returns a generator containing the results of the next query in the pipeline""" # n.b. pull is now somewhat misleadingly named because it doesn't do anything # the connection isn't touched until you try and iterate the generator we return lock_acquired = self._pull_lock.acquire(blocking=False) if not lock_acquired: raise PullOrderException() return self._results_generator()
python
def pull(self): """Returns a generator containing the results of the next query in the pipeline""" # n.b. pull is now somewhat misleadingly named because it doesn't do anything # the connection isn't touched until you try and iterate the generator we return lock_acquired = self._pull_lock.acquire(blocking=False) if not lock_acquired: raise PullOrderException() return self._results_generator()
[ "def", "pull", "(", "self", ")", ":", "# n.b. pull is now somewhat misleadingly named because it doesn't do anything", "# the connection isn't touched until you try and iterate the generator we return", "lock_acquired", "=", "self", ".", "_pull_lock", ".", "acquire", "(", "blocking", "=", "False", ")", "if", "not", "lock_acquired", ":", "raise", "PullOrderException", "(", ")", "return", "self", ".", "_results_generator", "(", ")" ]
Returns a generator containing the results of the next query in the pipeline
[ "Returns", "a", "generator", "containing", "the", "results", "of", "the", "next", "query", "in", "the", "pipeline" ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/pipelining.py#L61-L68
231,523
neo4j/neo4j-python-driver
neo4j/meta.py
deprecated
def deprecated(message): """ Decorator for deprecating functions and methods. :: @deprecated("'foo' has been deprecated in favour of 'bar'") def foo(x): pass """ def f__(f): def f_(*args, **kwargs): from warnings import warn warn(message, category=DeprecationWarning, stacklevel=2) return f(*args, **kwargs) f_.__name__ = f.__name__ f_.__doc__ = f.__doc__ f_.__dict__.update(f.__dict__) return f_ return f__
python
def deprecated(message): """ Decorator for deprecating functions and methods. :: @deprecated("'foo' has been deprecated in favour of 'bar'") def foo(x): pass """ def f__(f): def f_(*args, **kwargs): from warnings import warn warn(message, category=DeprecationWarning, stacklevel=2) return f(*args, **kwargs) f_.__name__ = f.__name__ f_.__doc__ = f.__doc__ f_.__dict__.update(f.__dict__) return f_ return f__
[ "def", "deprecated", "(", "message", ")", ":", "def", "f__", "(", "f", ")", ":", "def", "f_", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "warnings", "import", "warn", "warn", "(", "message", ",", "category", "=", "DeprecationWarning", ",", "stacklevel", "=", "2", ")", "return", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "f_", ".", "__name__", "=", "f", ".", "__name__", "f_", ".", "__doc__", "=", "f", ".", "__doc__", "f_", ".", "__dict__", ".", "update", "(", "f", ".", "__dict__", ")", "return", "f_", "return", "f__" ]
Decorator for deprecating functions and methods. :: @deprecated("'foo' has been deprecated in favour of 'bar'") def foo(x): pass
[ "Decorator", "for", "deprecating", "functions", "and", "methods", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/meta.py#L27-L46
231,524
neo4j/neo4j-python-driver
neo4j/meta.py
experimental
def experimental(message): """ Decorator for tagging experimental functions and methods. :: @experimental("'foo' is an experimental function and may be " "removed in a future release") def foo(x): pass """ def f__(f): def f_(*args, **kwargs): from warnings import warn warn(message, category=ExperimentalWarning, stacklevel=2) return f(*args, **kwargs) f_.__name__ = f.__name__ f_.__doc__ = f.__doc__ f_.__dict__.update(f.__dict__) return f_ return f__
python
def experimental(message): """ Decorator for tagging experimental functions and methods. :: @experimental("'foo' is an experimental function and may be " "removed in a future release") def foo(x): pass """ def f__(f): def f_(*args, **kwargs): from warnings import warn warn(message, category=ExperimentalWarning, stacklevel=2) return f(*args, **kwargs) f_.__name__ = f.__name__ f_.__doc__ = f.__doc__ f_.__dict__.update(f.__dict__) return f_ return f__
[ "def", "experimental", "(", "message", ")", ":", "def", "f__", "(", "f", ")", ":", "def", "f_", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "warnings", "import", "warn", "warn", "(", "message", ",", "category", "=", "ExperimentalWarning", ",", "stacklevel", "=", "2", ")", "return", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "f_", ".", "__name__", "=", "f", ".", "__name__", "f_", ".", "__doc__", "=", "f", ".", "__doc__", "f_", ".", "__dict__", ".", "update", "(", "f", ".", "__dict__", ")", "return", "f_", "return", "f__" ]
Decorator for tagging experimental functions and methods. :: @experimental("'foo' is an experimental function and may be " "removed in a future release") def foo(x): pass
[ "Decorator", "for", "tagging", "experimental", "functions", "and", "methods", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/meta.py#L54-L74
231,525
neo4j/neo4j-python-driver
neo4j/types/temporal.py
hydrate_time
def hydrate_time(nanoseconds, tz=None): """ Hydrator for `Time` and `LocalTime` values. :param nanoseconds: :param tz: :return: Time """ seconds, nanoseconds = map(int, divmod(nanoseconds, 1000000000)) minutes, seconds = map(int, divmod(seconds, 60)) hours, minutes = map(int, divmod(minutes, 60)) seconds = (1000000000 * seconds + nanoseconds) / 1000000000 t = Time(hours, minutes, seconds) if tz is None: return t tz_offset_minutes, tz_offset_seconds = divmod(tz, 60) zone = FixedOffset(tz_offset_minutes) return zone.localize(t)
python
def hydrate_time(nanoseconds, tz=None): """ Hydrator for `Time` and `LocalTime` values. :param nanoseconds: :param tz: :return: Time """ seconds, nanoseconds = map(int, divmod(nanoseconds, 1000000000)) minutes, seconds = map(int, divmod(seconds, 60)) hours, minutes = map(int, divmod(minutes, 60)) seconds = (1000000000 * seconds + nanoseconds) / 1000000000 t = Time(hours, minutes, seconds) if tz is None: return t tz_offset_minutes, tz_offset_seconds = divmod(tz, 60) zone = FixedOffset(tz_offset_minutes) return zone.localize(t)
[ "def", "hydrate_time", "(", "nanoseconds", ",", "tz", "=", "None", ")", ":", "seconds", ",", "nanoseconds", "=", "map", "(", "int", ",", "divmod", "(", "nanoseconds", ",", "1000000000", ")", ")", "minutes", ",", "seconds", "=", "map", "(", "int", ",", "divmod", "(", "seconds", ",", "60", ")", ")", "hours", ",", "minutes", "=", "map", "(", "int", ",", "divmod", "(", "minutes", ",", "60", ")", ")", "seconds", "=", "(", "1000000000", "*", "seconds", "+", "nanoseconds", ")", "/", "1000000000", "t", "=", "Time", "(", "hours", ",", "minutes", ",", "seconds", ")", "if", "tz", "is", "None", ":", "return", "t", "tz_offset_minutes", ",", "tz_offset_seconds", "=", "divmod", "(", "tz", ",", "60", ")", "zone", "=", "FixedOffset", "(", "tz_offset_minutes", ")", "return", "zone", ".", "localize", "(", "t", ")" ]
Hydrator for `Time` and `LocalTime` values. :param nanoseconds: :param tz: :return: Time
[ "Hydrator", "for", "Time", "and", "LocalTime", "values", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/temporal.py#L61-L77
231,526
neo4j/neo4j-python-driver
neo4j/types/temporal.py
dehydrate_time
def dehydrate_time(value): """ Dehydrator for `time` values. :param value: :type value: Time :return: """ if isinstance(value, Time): nanoseconds = int(value.ticks * 1000000000) elif isinstance(value, time): nanoseconds = (3600000000000 * value.hour + 60000000000 * value.minute + 1000000000 * value.second + 1000 * value.microsecond) else: raise TypeError("Value must be a neotime.Time or a datetime.time") if value.tzinfo: return Structure(b"T", nanoseconds, value.tzinfo.utcoffset(value).seconds) else: return Structure(b"t", nanoseconds)
python
def dehydrate_time(value): """ Dehydrator for `time` values. :param value: :type value: Time :return: """ if isinstance(value, Time): nanoseconds = int(value.ticks * 1000000000) elif isinstance(value, time): nanoseconds = (3600000000000 * value.hour + 60000000000 * value.minute + 1000000000 * value.second + 1000 * value.microsecond) else: raise TypeError("Value must be a neotime.Time or a datetime.time") if value.tzinfo: return Structure(b"T", nanoseconds, value.tzinfo.utcoffset(value).seconds) else: return Structure(b"t", nanoseconds)
[ "def", "dehydrate_time", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "Time", ")", ":", "nanoseconds", "=", "int", "(", "value", ".", "ticks", "*", "1000000000", ")", "elif", "isinstance", "(", "value", ",", "time", ")", ":", "nanoseconds", "=", "(", "3600000000000", "*", "value", ".", "hour", "+", "60000000000", "*", "value", ".", "minute", "+", "1000000000", "*", "value", ".", "second", "+", "1000", "*", "value", ".", "microsecond", ")", "else", ":", "raise", "TypeError", "(", "\"Value must be a neotime.Time or a datetime.time\"", ")", "if", "value", ".", "tzinfo", ":", "return", "Structure", "(", "b\"T\"", ",", "nanoseconds", ",", "value", ".", "tzinfo", ".", "utcoffset", "(", "value", ")", ".", "seconds", ")", "else", ":", "return", "Structure", "(", "b\"t\"", ",", "nanoseconds", ")" ]
Dehydrator for `time` values. :param value: :type value: Time :return:
[ "Dehydrator", "for", "time", "values", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/temporal.py#L80-L97
231,527
neo4j/neo4j-python-driver
neo4j/types/temporal.py
hydrate_datetime
def hydrate_datetime(seconds, nanoseconds, tz=None): """ Hydrator for `DateTime` and `LocalDateTime` values. :param seconds: :param nanoseconds: :param tz: :return: datetime """ minutes, seconds = map(int, divmod(seconds, 60)) hours, minutes = map(int, divmod(minutes, 60)) days, hours = map(int, divmod(hours, 24)) seconds = (1000000000 * seconds + nanoseconds) / 1000000000 t = DateTime.combine(Date.from_ordinal(UNIX_EPOCH_DATE_ORDINAL + days), Time(hours, minutes, seconds)) if tz is None: return t if isinstance(tz, int): tz_offset_minutes, tz_offset_seconds = divmod(tz, 60) zone = FixedOffset(tz_offset_minutes) else: zone = timezone(tz) return zone.localize(t)
python
def hydrate_datetime(seconds, nanoseconds, tz=None): """ Hydrator for `DateTime` and `LocalDateTime` values. :param seconds: :param nanoseconds: :param tz: :return: datetime """ minutes, seconds = map(int, divmod(seconds, 60)) hours, minutes = map(int, divmod(minutes, 60)) days, hours = map(int, divmod(hours, 24)) seconds = (1000000000 * seconds + nanoseconds) / 1000000000 t = DateTime.combine(Date.from_ordinal(UNIX_EPOCH_DATE_ORDINAL + days), Time(hours, minutes, seconds)) if tz is None: return t if isinstance(tz, int): tz_offset_minutes, tz_offset_seconds = divmod(tz, 60) zone = FixedOffset(tz_offset_minutes) else: zone = timezone(tz) return zone.localize(t)
[ "def", "hydrate_datetime", "(", "seconds", ",", "nanoseconds", ",", "tz", "=", "None", ")", ":", "minutes", ",", "seconds", "=", "map", "(", "int", ",", "divmod", "(", "seconds", ",", "60", ")", ")", "hours", ",", "minutes", "=", "map", "(", "int", ",", "divmod", "(", "minutes", ",", "60", ")", ")", "days", ",", "hours", "=", "map", "(", "int", ",", "divmod", "(", "hours", ",", "24", ")", ")", "seconds", "=", "(", "1000000000", "*", "seconds", "+", "nanoseconds", ")", "/", "1000000000", "t", "=", "DateTime", ".", "combine", "(", "Date", ".", "from_ordinal", "(", "UNIX_EPOCH_DATE_ORDINAL", "+", "days", ")", ",", "Time", "(", "hours", ",", "minutes", ",", "seconds", ")", ")", "if", "tz", "is", "None", ":", "return", "t", "if", "isinstance", "(", "tz", ",", "int", ")", ":", "tz_offset_minutes", ",", "tz_offset_seconds", "=", "divmod", "(", "tz", ",", "60", ")", "zone", "=", "FixedOffset", "(", "tz_offset_minutes", ")", "else", ":", "zone", "=", "timezone", "(", "tz", ")", "return", "zone", ".", "localize", "(", "t", ")" ]
Hydrator for `DateTime` and `LocalDateTime` values. :param seconds: :param nanoseconds: :param tz: :return: datetime
[ "Hydrator", "for", "DateTime", "and", "LocalDateTime", "values", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/temporal.py#L100-L120
231,528
neo4j/neo4j-python-driver
neo4j/types/temporal.py
dehydrate_datetime
def dehydrate_datetime(value): """ Dehydrator for `datetime` values. :param value: :type value: datetime :return: """ def seconds_and_nanoseconds(dt): if isinstance(dt, datetime): dt = DateTime.from_native(dt) zone_epoch = DateTime(1970, 1, 1, tzinfo=dt.tzinfo) t = dt.to_clock_time() - zone_epoch.to_clock_time() return t.seconds, t.nanoseconds tz = value.tzinfo if tz is None: # without time zone value = utc.localize(value) seconds, nanoseconds = seconds_and_nanoseconds(value) return Structure(b"d", seconds, nanoseconds) elif hasattr(tz, "zone") and tz.zone: # with named time zone seconds, nanoseconds = seconds_and_nanoseconds(value) return Structure(b"f", seconds, nanoseconds, tz.zone) else: # with time offset seconds, nanoseconds = seconds_and_nanoseconds(value) return Structure(b"F", seconds, nanoseconds, tz.utcoffset(value).seconds)
python
def dehydrate_datetime(value): """ Dehydrator for `datetime` values. :param value: :type value: datetime :return: """ def seconds_and_nanoseconds(dt): if isinstance(dt, datetime): dt = DateTime.from_native(dt) zone_epoch = DateTime(1970, 1, 1, tzinfo=dt.tzinfo) t = dt.to_clock_time() - zone_epoch.to_clock_time() return t.seconds, t.nanoseconds tz = value.tzinfo if tz is None: # without time zone value = utc.localize(value) seconds, nanoseconds = seconds_and_nanoseconds(value) return Structure(b"d", seconds, nanoseconds) elif hasattr(tz, "zone") and tz.zone: # with named time zone seconds, nanoseconds = seconds_and_nanoseconds(value) return Structure(b"f", seconds, nanoseconds, tz.zone) else: # with time offset seconds, nanoseconds = seconds_and_nanoseconds(value) return Structure(b"F", seconds, nanoseconds, tz.utcoffset(value).seconds)
[ "def", "dehydrate_datetime", "(", "value", ")", ":", "def", "seconds_and_nanoseconds", "(", "dt", ")", ":", "if", "isinstance", "(", "dt", ",", "datetime", ")", ":", "dt", "=", "DateTime", ".", "from_native", "(", "dt", ")", "zone_epoch", "=", "DateTime", "(", "1970", ",", "1", ",", "1", ",", "tzinfo", "=", "dt", ".", "tzinfo", ")", "t", "=", "dt", ".", "to_clock_time", "(", ")", "-", "zone_epoch", ".", "to_clock_time", "(", ")", "return", "t", ".", "seconds", ",", "t", ".", "nanoseconds", "tz", "=", "value", ".", "tzinfo", "if", "tz", "is", "None", ":", "# without time zone", "value", "=", "utc", ".", "localize", "(", "value", ")", "seconds", ",", "nanoseconds", "=", "seconds_and_nanoseconds", "(", "value", ")", "return", "Structure", "(", "b\"d\"", ",", "seconds", ",", "nanoseconds", ")", "elif", "hasattr", "(", "tz", ",", "\"zone\"", ")", "and", "tz", ".", "zone", ":", "# with named time zone", "seconds", ",", "nanoseconds", "=", "seconds_and_nanoseconds", "(", "value", ")", "return", "Structure", "(", "b\"f\"", ",", "seconds", ",", "nanoseconds", ",", "tz", ".", "zone", ")", "else", ":", "# with time offset", "seconds", ",", "nanoseconds", "=", "seconds_and_nanoseconds", "(", "value", ")", "return", "Structure", "(", "b\"F\"", ",", "seconds", ",", "nanoseconds", ",", "tz", ".", "utcoffset", "(", "value", ")", ".", "seconds", ")" ]
Dehydrator for `datetime` values. :param value: :type value: datetime :return:
[ "Dehydrator", "for", "datetime", "values", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/temporal.py#L123-L151
231,529
neo4j/neo4j-python-driver
neo4j/types/temporal.py
hydrate_duration
def hydrate_duration(months, days, seconds, nanoseconds): """ Hydrator for `Duration` values. :param months: :param days: :param seconds: :param nanoseconds: :return: `duration` namedtuple """ return Duration(months=months, days=days, seconds=seconds, nanoseconds=nanoseconds)
python
def hydrate_duration(months, days, seconds, nanoseconds): """ Hydrator for `Duration` values. :param months: :param days: :param seconds: :param nanoseconds: :return: `duration` namedtuple """ return Duration(months=months, days=days, seconds=seconds, nanoseconds=nanoseconds)
[ "def", "hydrate_duration", "(", "months", ",", "days", ",", "seconds", ",", "nanoseconds", ")", ":", "return", "Duration", "(", "months", "=", "months", ",", "days", "=", "days", ",", "seconds", "=", "seconds", ",", "nanoseconds", "=", "nanoseconds", ")" ]
Hydrator for `Duration` values. :param months: :param days: :param seconds: :param nanoseconds: :return: `duration` namedtuple
[ "Hydrator", "for", "Duration", "values", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/temporal.py#L154-L163
231,530
neo4j/neo4j-python-driver
neo4j/types/temporal.py
dehydrate_duration
def dehydrate_duration(value): """ Dehydrator for `duration` values. :param value: :type value: Duration :return: """ return Structure(b"E", value.months, value.days, value.seconds, int(1000000000 * value.subseconds))
python
def dehydrate_duration(value): """ Dehydrator for `duration` values. :param value: :type value: Duration :return: """ return Structure(b"E", value.months, value.days, value.seconds, int(1000000000 * value.subseconds))
[ "def", "dehydrate_duration", "(", "value", ")", ":", "return", "Structure", "(", "b\"E\"", ",", "value", ".", "months", ",", "value", ".", "days", ",", "value", ".", "seconds", ",", "int", "(", "1000000000", "*", "value", ".", "subseconds", ")", ")" ]
Dehydrator for `duration` values. :param value: :type value: Duration :return:
[ "Dehydrator", "for", "duration", "values", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/temporal.py#L166-L173
231,531
neo4j/neo4j-python-driver
neo4j/types/temporal.py
dehydrate_timedelta
def dehydrate_timedelta(value): """ Dehydrator for `timedelta` values. :param value: :type value: timedelta :return: """ months = 0 days = value.days seconds = value.seconds nanoseconds = 1000 * value.microseconds return Structure(b"E", months, days, seconds, nanoseconds)
python
def dehydrate_timedelta(value): """ Dehydrator for `timedelta` values. :param value: :type value: timedelta :return: """ months = 0 days = value.days seconds = value.seconds nanoseconds = 1000 * value.microseconds return Structure(b"E", months, days, seconds, nanoseconds)
[ "def", "dehydrate_timedelta", "(", "value", ")", ":", "months", "=", "0", "days", "=", "value", ".", "days", "seconds", "=", "value", ".", "seconds", "nanoseconds", "=", "1000", "*", "value", ".", "microseconds", "return", "Structure", "(", "b\"E\"", ",", "months", ",", "days", ",", "seconds", ",", "nanoseconds", ")" ]
Dehydrator for `timedelta` values. :param value: :type value: timedelta :return:
[ "Dehydrator", "for", "timedelta", "values", "." ]
0c641e826765e86ff5454dae57c99521db8ca45c
https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/types/temporal.py#L176-L187
231,532
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_touch.py
_TouchKeywords.zoom
def zoom(self, locator, percent="200%", steps=1): """ Zooms in on an element a certain amount. """ driver = self._current_application() element = self._element_find(locator, True, True) driver.zoom(element=element, percent=percent, steps=steps)
python
def zoom(self, locator, percent="200%", steps=1): """ Zooms in on an element a certain amount. """ driver = self._current_application() element = self._element_find(locator, True, True) driver.zoom(element=element, percent=percent, steps=steps)
[ "def", "zoom", "(", "self", ",", "locator", ",", "percent", "=", "\"200%\"", ",", "steps", "=", "1", ")", ":", "driver", "=", "self", ".", "_current_application", "(", ")", "element", "=", "self", ".", "_element_find", "(", "locator", ",", "True", ",", "True", ")", "driver", ".", "zoom", "(", "element", "=", "element", ",", "percent", "=", "percent", ",", "steps", "=", "steps", ")" ]
Zooms in on an element a certain amount.
[ "Zooms", "in", "on", "an", "element", "a", "certain", "amount", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_touch.py#L15-L21
231,533
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_touch.py
_TouchKeywords.scroll
def scroll(self, start_locator, end_locator): """ Scrolls from one element to another Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements. """ el1 = self._element_find(start_locator, True, True) el2 = self._element_find(end_locator, True, True) driver = self._current_application() driver.scroll(el1, el2)
python
def scroll(self, start_locator, end_locator): """ Scrolls from one element to another Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements. """ el1 = self._element_find(start_locator, True, True) el2 = self._element_find(end_locator, True, True) driver = self._current_application() driver.scroll(el1, el2)
[ "def", "scroll", "(", "self", ",", "start_locator", ",", "end_locator", ")", ":", "el1", "=", "self", ".", "_element_find", "(", "start_locator", ",", "True", ",", "True", ")", "el2", "=", "self", ".", "_element_find", "(", "end_locator", ",", "True", ",", "True", ")", "driver", "=", "self", ".", "_current_application", "(", ")", "driver", ".", "scroll", "(", "el1", ",", "el2", ")" ]
Scrolls from one element to another Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements.
[ "Scrolls", "from", "one", "element", "to", "another", "Key", "attributes", "for", "arbitrary", "elements", "are", "id", "and", "name", ".", "See", "introduction", "for", "details", "about", "locating", "elements", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_touch.py#L85-L94
231,534
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_touch.py
_TouchKeywords.scroll_up
def scroll_up(self, locator): """Scrolls up to element""" driver = self._current_application() element = self._element_find(locator, True, True) driver.execute_script("mobile: scroll", {"direction": 'up', 'element': element.id})
python
def scroll_up(self, locator): """Scrolls up to element""" driver = self._current_application() element = self._element_find(locator, True, True) driver.execute_script("mobile: scroll", {"direction": 'up', 'element': element.id})
[ "def", "scroll_up", "(", "self", ",", "locator", ")", ":", "driver", "=", "self", ".", "_current_application", "(", ")", "element", "=", "self", ".", "_element_find", "(", "locator", ",", "True", ",", "True", ")", "driver", ".", "execute_script", "(", "\"mobile: scroll\"", ",", "{", "\"direction\"", ":", "'up'", ",", "'element'", ":", "element", ".", "id", "}", ")" ]
Scrolls up to element
[ "Scrolls", "up", "to", "element" ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_touch.py#L102-L106
231,535
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_touch.py
_TouchKeywords.long_press
def long_press(self, locator, duration=1000): """ Long press the element with optional duration """ driver = self._current_application() element = self._element_find(locator, True, True) action = TouchAction(driver) action.press(element).wait(duration).release().perform()
python
def long_press(self, locator, duration=1000): """ Long press the element with optional duration """ driver = self._current_application() element = self._element_find(locator, True, True) action = TouchAction(driver) action.press(element).wait(duration).release().perform()
[ "def", "long_press", "(", "self", ",", "locator", ",", "duration", "=", "1000", ")", ":", "driver", "=", "self", ".", "_current_application", "(", ")", "element", "=", "self", ".", "_element_find", "(", "locator", ",", "True", ",", "True", ")", "action", "=", "TouchAction", "(", "driver", ")", "action", ".", "press", "(", "element", ")", ".", "wait", "(", "duration", ")", ".", "release", "(", ")", ".", "perform", "(", ")" ]
Long press the element with optional duration
[ "Long", "press", "the", "element", "with", "optional", "duration" ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_touch.py#L108-L113
231,536
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_touch.py
_TouchKeywords.click_a_point
def click_a_point(self, x=0, y=0, duration=100): """ Click on a point""" self._info("Clicking on a point (%s,%s)." % (x,y)) driver = self._current_application() action = TouchAction(driver) try: action.press(x=float(x), y=float(y)).wait(float(duration)).release().perform() except: assert False, "Can't click on a point at (%s,%s)" % (x,y)
python
def click_a_point(self, x=0, y=0, duration=100): """ Click on a point""" self._info("Clicking on a point (%s,%s)." % (x,y)) driver = self._current_application() action = TouchAction(driver) try: action.press(x=float(x), y=float(y)).wait(float(duration)).release().perform() except: assert False, "Can't click on a point at (%s,%s)" % (x,y)
[ "def", "click_a_point", "(", "self", ",", "x", "=", "0", ",", "y", "=", "0", ",", "duration", "=", "100", ")", ":", "self", ".", "_info", "(", "\"Clicking on a point (%s,%s).\"", "%", "(", "x", ",", "y", ")", ")", "driver", "=", "self", ".", "_current_application", "(", ")", "action", "=", "TouchAction", "(", "driver", ")", "try", ":", "action", ".", "press", "(", "x", "=", "float", "(", "x", ")", ",", "y", "=", "float", "(", "y", ")", ")", ".", "wait", "(", "float", "(", "duration", ")", ")", ".", "release", "(", ")", ".", "perform", "(", ")", "except", ":", "assert", "False", ",", "\"Can't click on a point at (%s,%s)\"", "%", "(", "x", ",", "y", ")" ]
Click on a point
[ "Click", "on", "a", "point" ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_touch.py#L128-L136
231,537
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_touch.py
_TouchKeywords.click_element_at_coordinates
def click_element_at_coordinates(self, coordinate_X, coordinate_Y): """ click element at a certain coordinate """ self._info("Pressing at (%s, %s)." % (coordinate_X, coordinate_Y)) driver = self._current_application() action = TouchAction(driver) action.press(x=coordinate_X, y=coordinate_Y).release().perform()
python
def click_element_at_coordinates(self, coordinate_X, coordinate_Y): """ click element at a certain coordinate """ self._info("Pressing at (%s, %s)." % (coordinate_X, coordinate_Y)) driver = self._current_application() action = TouchAction(driver) action.press(x=coordinate_X, y=coordinate_Y).release().perform()
[ "def", "click_element_at_coordinates", "(", "self", ",", "coordinate_X", ",", "coordinate_Y", ")", ":", "self", ".", "_info", "(", "\"Pressing at (%s, %s).\"", "%", "(", "coordinate_X", ",", "coordinate_Y", ")", ")", "driver", "=", "self", ".", "_current_application", "(", ")", "action", "=", "TouchAction", "(", "driver", ")", "action", ".", "press", "(", "x", "=", "coordinate_X", ",", "y", "=", "coordinate_Y", ")", ".", "release", "(", ")", ".", "perform", "(", ")" ]
click element at a certain coordinate
[ "click", "element", "at", "a", "certain", "coordinate" ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_touch.py#L138-L143
231,538
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_waiting.py
_WaitingKeywords.wait_until_element_is_visible
def wait_until_element_is_visible(self, locator, timeout=None, error=None): """Waits until element specified with `locator` is visible. Fails if `timeout` expires before the element is visible. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Contains`, `Wait Until Page Contains Element`, `Wait For Condition` and BuiltIn keyword `Wait Until Keyword Succeeds`. """ def check_visibility(): visible = self._is_visible(locator) if visible: return elif visible is None: return error or "Element locator '%s' did not match any elements after %s" % (locator, self._format_timeout(timeout)) else: return error or "Element '%s' was not visible in %s" % (locator, self._format_timeout(timeout)) self._wait_until_no_error(timeout, check_visibility)
python
def wait_until_element_is_visible(self, locator, timeout=None, error=None): """Waits until element specified with `locator` is visible. Fails if `timeout` expires before the element is visible. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Contains`, `Wait Until Page Contains Element`, `Wait For Condition` and BuiltIn keyword `Wait Until Keyword Succeeds`. """ def check_visibility(): visible = self._is_visible(locator) if visible: return elif visible is None: return error or "Element locator '%s' did not match any elements after %s" % (locator, self._format_timeout(timeout)) else: return error or "Element '%s' was not visible in %s" % (locator, self._format_timeout(timeout)) self._wait_until_no_error(timeout, check_visibility)
[ "def", "wait_until_element_is_visible", "(", "self", ",", "locator", ",", "timeout", "=", "None", ",", "error", "=", "None", ")", ":", "def", "check_visibility", "(", ")", ":", "visible", "=", "self", ".", "_is_visible", "(", "locator", ")", "if", "visible", ":", "return", "elif", "visible", "is", "None", ":", "return", "error", "or", "\"Element locator '%s' did not match any elements after %s\"", "%", "(", "locator", ",", "self", ".", "_format_timeout", "(", "timeout", ")", ")", "else", ":", "return", "error", "or", "\"Element '%s' was not visible in %s\"", "%", "(", "locator", ",", "self", ".", "_format_timeout", "(", "timeout", ")", ")", "self", ".", "_wait_until_no_error", "(", "timeout", ",", "check_visibility", ")" ]
Waits until element specified with `locator` is visible. Fails if `timeout` expires before the element is visible. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Contains`, `Wait Until Page Contains Element`, `Wait For Condition` and BuiltIn keyword `Wait Until Keyword Succeeds`.
[ "Waits", "until", "element", "specified", "with", "locator", "is", "visible", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_waiting.py#L7-L28
231,539
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_waiting.py
_WaitingKeywords.wait_until_page_contains
def wait_until_page_contains(self, text, timeout=None, error=None): """Waits until `text` appears on current page. Fails if `timeout` expires before the text appears. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Does Not Contain`, `Wait Until Page Contains Element`, `Wait Until Page Does Not Contain Element` and BuiltIn keyword `Wait Until Keyword Succeeds`. """ if not error: error = "Text '%s' did not appear in <TIMEOUT>" % text self._wait_until(timeout, error, self._is_text_present, text)
python
def wait_until_page_contains(self, text, timeout=None, error=None): """Waits until `text` appears on current page. Fails if `timeout` expires before the text appears. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Does Not Contain`, `Wait Until Page Contains Element`, `Wait Until Page Does Not Contain Element` and BuiltIn keyword `Wait Until Keyword Succeeds`. """ if not error: error = "Text '%s' did not appear in <TIMEOUT>" % text self._wait_until(timeout, error, self._is_text_present, text)
[ "def", "wait_until_page_contains", "(", "self", ",", "text", ",", "timeout", "=", "None", ",", "error", "=", "None", ")", ":", "if", "not", "error", ":", "error", "=", "\"Text '%s' did not appear in <TIMEOUT>\"", "%", "text", "self", ".", "_wait_until", "(", "timeout", ",", "error", ",", "self", ".", "_is_text_present", ",", "text", ")" ]
Waits until `text` appears on current page. Fails if `timeout` expires before the text appears. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Does Not Contain`, `Wait Until Page Contains Element`, `Wait Until Page Does Not Contain Element` and BuiltIn keyword `Wait Until Keyword Succeeds`.
[ "Waits", "until", "text", "appears", "on", "current", "page", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_waiting.py#L30-L46
231,540
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_waiting.py
_WaitingKeywords.wait_until_page_does_not_contain
def wait_until_page_does_not_contain(self, text, timeout=None, error=None): """Waits until `text` disappears from current page. Fails if `timeout` expires before the `text` disappears. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Contains`, `Wait Until Page Contains Element`, `Wait Until Page Does Not Contain Element` and BuiltIn keyword `Wait Until Keyword Succeeds`. """ def check_present(): present = self._is_text_present(text) if not present: return else: return error or "Text '%s' did not disappear in %s" % (text, self._format_timeout(timeout)) self._wait_until_no_error(timeout, check_present)
python
def wait_until_page_does_not_contain(self, text, timeout=None, error=None): """Waits until `text` disappears from current page. Fails if `timeout` expires before the `text` disappears. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Contains`, `Wait Until Page Contains Element`, `Wait Until Page Does Not Contain Element` and BuiltIn keyword `Wait Until Keyword Succeeds`. """ def check_present(): present = self._is_text_present(text) if not present: return else: return error or "Text '%s' did not disappear in %s" % (text, self._format_timeout(timeout)) self._wait_until_no_error(timeout, check_present)
[ "def", "wait_until_page_does_not_contain", "(", "self", ",", "text", ",", "timeout", "=", "None", ",", "error", "=", "None", ")", ":", "def", "check_present", "(", ")", ":", "present", "=", "self", ".", "_is_text_present", "(", "text", ")", "if", "not", "present", ":", "return", "else", ":", "return", "error", "or", "\"Text '%s' did not disappear in %s\"", "%", "(", "text", ",", "self", ".", "_format_timeout", "(", "timeout", ")", ")", "self", ".", "_wait_until_no_error", "(", "timeout", ",", "check_present", ")" ]
Waits until `text` disappears from current page. Fails if `timeout` expires before the `text` disappears. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Contains`, `Wait Until Page Contains Element`, `Wait Until Page Does Not Contain Element` and BuiltIn keyword `Wait Until Keyword Succeeds`.
[ "Waits", "until", "text", "disappears", "from", "current", "page", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_waiting.py#L48-L70
231,541
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_waiting.py
_WaitingKeywords.wait_until_page_contains_element
def wait_until_page_contains_element(self, locator, timeout=None, error=None): """Waits until element specified with `locator` appears on current page. Fails if `timeout` expires before the element appears. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Contains`, `Wait Until Page Does Not Contain` `Wait Until Page Does Not Contain Element` and BuiltIn keyword `Wait Until Keyword Succeeds`. """ if not error: error = "Element '%s' did not appear in <TIMEOUT>" % locator self._wait_until(timeout, error, self._is_element_present, locator)
python
def wait_until_page_contains_element(self, locator, timeout=None, error=None): """Waits until element specified with `locator` appears on current page. Fails if `timeout` expires before the element appears. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Contains`, `Wait Until Page Does Not Contain` `Wait Until Page Does Not Contain Element` and BuiltIn keyword `Wait Until Keyword Succeeds`. """ if not error: error = "Element '%s' did not appear in <TIMEOUT>" % locator self._wait_until(timeout, error, self._is_element_present, locator)
[ "def", "wait_until_page_contains_element", "(", "self", ",", "locator", ",", "timeout", "=", "None", ",", "error", "=", "None", ")", ":", "if", "not", "error", ":", "error", "=", "\"Element '%s' did not appear in <TIMEOUT>\"", "%", "locator", "self", ".", "_wait_until", "(", "timeout", ",", "error", ",", "self", ".", "_is_element_present", ",", "locator", ")" ]
Waits until element specified with `locator` appears on current page. Fails if `timeout` expires before the element appears. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Contains`, `Wait Until Page Does Not Contain` `Wait Until Page Does Not Contain Element` and BuiltIn keyword `Wait Until Keyword Succeeds`.
[ "Waits", "until", "element", "specified", "with", "locator", "appears", "on", "current", "page", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_waiting.py#L72-L88
231,542
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_waiting.py
_WaitingKeywords.wait_until_page_does_not_contain_element
def wait_until_page_does_not_contain_element(self, locator, timeout=None, error=None): """Waits until element specified with `locator` disappears from current page. Fails if `timeout` expires before the element disappears. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Contains`, `Wait Until Page Does Not Contain`, `Wait Until Page Contains Element` and BuiltIn keyword `Wait Until Keyword Succeeds`. """ def check_present(): present = self._is_element_present(locator) if not present: return else: return error or "Element '%s' did not disappear in %s" % (locator, self._format_timeout(timeout)) self._wait_until_no_error(timeout, check_present)
python
def wait_until_page_does_not_contain_element(self, locator, timeout=None, error=None): """Waits until element specified with `locator` disappears from current page. Fails if `timeout` expires before the element disappears. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Contains`, `Wait Until Page Does Not Contain`, `Wait Until Page Contains Element` and BuiltIn keyword `Wait Until Keyword Succeeds`. """ def check_present(): present = self._is_element_present(locator) if not present: return else: return error or "Element '%s' did not disappear in %s" % (locator, self._format_timeout(timeout)) self._wait_until_no_error(timeout, check_present)
[ "def", "wait_until_page_does_not_contain_element", "(", "self", ",", "locator", ",", "timeout", "=", "None", ",", "error", "=", "None", ")", ":", "def", "check_present", "(", ")", ":", "present", "=", "self", ".", "_is_element_present", "(", "locator", ")", "if", "not", "present", ":", "return", "else", ":", "return", "error", "or", "\"Element '%s' did not disappear in %s\"", "%", "(", "locator", ",", "self", ".", "_format_timeout", "(", "timeout", ")", ")", "self", ".", "_wait_until_no_error", "(", "timeout", ",", "check_present", ")" ]
Waits until element specified with `locator` disappears from current page. Fails if `timeout` expires before the element disappears. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Contains`, `Wait Until Page Does Not Contain`, `Wait Until Page Contains Element` and BuiltIn keyword `Wait Until Keyword Succeeds`.
[ "Waits", "until", "element", "specified", "with", "locator", "disappears", "from", "current", "page", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_waiting.py#L90-L112
231,543
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_android_utils.py
_AndroidUtilsKeywords.set_network_connection_status
def set_network_connection_status(self, connectionStatus): """Sets the network connection Status. Android only. Possible values: | =Value= | =Alias= | =Data= | =Wifi= | =Airplane Mode= | | 0 | (None) | 0 | 0 | 0 | | 1 | (Airplane Mode) | 0 | 0 | 1 | | 2 | (Wifi only) | 0 | 1 | 0 | | 4 | (Data only) | 1 | 0 | 0 | | 6 | (All network on) | 1 | 1 | 0 | """ driver = self._current_application() return driver.set_network_connection(int(connectionStatus))
python
def set_network_connection_status(self, connectionStatus): """Sets the network connection Status. Android only. Possible values: | =Value= | =Alias= | =Data= | =Wifi= | =Airplane Mode= | | 0 | (None) | 0 | 0 | 0 | | 1 | (Airplane Mode) | 0 | 0 | 1 | | 2 | (Wifi only) | 0 | 1 | 0 | | 4 | (Data only) | 1 | 0 | 0 | | 6 | (All network on) | 1 | 1 | 0 | """ driver = self._current_application() return driver.set_network_connection(int(connectionStatus))
[ "def", "set_network_connection_status", "(", "self", ",", "connectionStatus", ")", ":", "driver", "=", "self", ".", "_current_application", "(", ")", "return", "driver", ".", "set_network_connection", "(", "int", "(", "connectionStatus", ")", ")" ]
Sets the network connection Status. Android only. Possible values: | =Value= | =Alias= | =Data= | =Wifi= | =Airplane Mode= | | 0 | (None) | 0 | 0 | 0 | | 1 | (Airplane Mode) | 0 | 0 | 1 | | 2 | (Wifi only) | 0 | 1 | 0 | | 4 | (Data only) | 1 | 0 | 0 | | 6 | (All network on) | 1 | 1 | 0 |
[ "Sets", "the", "network", "connection", "Status", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_android_utils.py#L21-L35
231,544
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_android_utils.py
_AndroidUtilsKeywords.pull_file
def pull_file(self, path, decode=False): """Retrieves the file at `path` and return it's content. Android only. - _path_ - the path to the file on the device - _decode_ - True/False decode the data (base64) before returning it (default=False) """ driver = self._current_application() theFile = driver.pull_file(path) if decode: theFile = base64.b64decode(theFile) return str(theFile)
python
def pull_file(self, path, decode=False): """Retrieves the file at `path` and return it's content. Android only. - _path_ - the path to the file on the device - _decode_ - True/False decode the data (base64) before returning it (default=False) """ driver = self._current_application() theFile = driver.pull_file(path) if decode: theFile = base64.b64decode(theFile) return str(theFile)
[ "def", "pull_file", "(", "self", ",", "path", ",", "decode", "=", "False", ")", ":", "driver", "=", "self", ".", "_current_application", "(", ")", "theFile", "=", "driver", ".", "pull_file", "(", "path", ")", "if", "decode", ":", "theFile", "=", "base64", ".", "b64decode", "(", "theFile", ")", "return", "str", "(", "theFile", ")" ]
Retrieves the file at `path` and return it's content. Android only. - _path_ - the path to the file on the device - _decode_ - True/False decode the data (base64) before returning it (default=False)
[ "Retrieves", "the", "file", "at", "path", "and", "return", "it", "s", "content", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_android_utils.py#L37-L49
231,545
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_android_utils.py
_AndroidUtilsKeywords.pull_folder
def pull_folder(self, path, decode=False): """Retrieves a folder at `path`. Returns the folder's contents zipped. Android only. - _path_ - the path to the folder on the device - _decode_ - True/False decode the data (base64) before returning it (default=False) """ driver = self._current_application() theFolder = driver.pull_folder(path) if decode: theFolder = base64.b64decode(theFolder) return theFolder
python
def pull_folder(self, path, decode=False): """Retrieves a folder at `path`. Returns the folder's contents zipped. Android only. - _path_ - the path to the folder on the device - _decode_ - True/False decode the data (base64) before returning it (default=False) """ driver = self._current_application() theFolder = driver.pull_folder(path) if decode: theFolder = base64.b64decode(theFolder) return theFolder
[ "def", "pull_folder", "(", "self", ",", "path", ",", "decode", "=", "False", ")", ":", "driver", "=", "self", ".", "_current_application", "(", ")", "theFolder", "=", "driver", ".", "pull_folder", "(", "path", ")", "if", "decode", ":", "theFolder", "=", "base64", ".", "b64decode", "(", "theFolder", ")", "return", "theFolder" ]
Retrieves a folder at `path`. Returns the folder's contents zipped. Android only. - _path_ - the path to the folder on the device - _decode_ - True/False decode the data (base64) before returning it (default=False)
[ "Retrieves", "a", "folder", "at", "path", ".", "Returns", "the", "folder", "s", "contents", "zipped", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_android_utils.py#L51-L63
231,546
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_android_utils.py
_AndroidUtilsKeywords.push_file
def push_file(self, path, data, encode=False): """Puts the data in the file specified as `path`. Android only. - _path_ - the path on the device - _data_ - data to be written to the file - _encode_ - True/False encode the data as base64 before writing it to the file (default=False) """ driver = self._current_application() data = to_bytes(data) if encode: data = base64.b64encode(data) driver.push_file(path, data)
python
def push_file(self, path, data, encode=False): """Puts the data in the file specified as `path`. Android only. - _path_ - the path on the device - _data_ - data to be written to the file - _encode_ - True/False encode the data as base64 before writing it to the file (default=False) """ driver = self._current_application() data = to_bytes(data) if encode: data = base64.b64encode(data) driver.push_file(path, data)
[ "def", "push_file", "(", "self", ",", "path", ",", "data", ",", "encode", "=", "False", ")", ":", "driver", "=", "self", ".", "_current_application", "(", ")", "data", "=", "to_bytes", "(", "data", ")", "if", "encode", ":", "data", "=", "base64", ".", "b64encode", "(", "data", ")", "driver", ".", "push_file", "(", "path", ",", "data", ")" ]
Puts the data in the file specified as `path`. Android only. - _path_ - the path on the device - _data_ - data to be written to the file - _encode_ - True/False encode the data as base64 before writing it to the file (default=False)
[ "Puts", "the", "data", "in", "the", "file", "specified", "as", "path", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_android_utils.py#L65-L78
231,547
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_android_utils.py
_AndroidUtilsKeywords.start_activity
def start_activity(self, appPackage, appActivity, **opts): """Opens an arbitrary activity during a test. If the activity belongs to another application, that application is started and the activity is opened. Android only. - _appPackage_ - The package containing the activity to start. - _appActivity_ - The activity to start. - _appWaitPackage_ - Begin automation after this package starts (optional). - _appWaitActivity_ - Begin automation after this activity starts (optional). - _intentAction_ - Intent to start (opt_ional). - _intentCategory_ - Intent category to start (optional). - _intentFlags_ - Flags to send to the intent (optional). - _optionalIntentArguments_ - Optional arguments to the intent (optional). - _stopAppOnReset_ - Should the app be stopped on reset (optional)? """ # Almost the same code as in appium's start activity, # just to keep the same keyword names as in open application arguments = { 'app_wait_package': 'appWaitPackage', 'app_wait_activity': 'appWaitActivity', 'intent_action': 'intentAction', 'intent_category': 'intentCategory', 'intent_flags': 'intentFlags', 'optional_intent_arguments': 'optionalIntentArguments', 'stop_app_on_reset': 'stopAppOnReset' } data = {} for key, value in arguments.items(): if value in opts: data[key] = opts[value] driver = self._current_application() driver.start_activity(app_package=appPackage, app_activity=appActivity, **data)
python
def start_activity(self, appPackage, appActivity, **opts): """Opens an arbitrary activity during a test. If the activity belongs to another application, that application is started and the activity is opened. Android only. - _appPackage_ - The package containing the activity to start. - _appActivity_ - The activity to start. - _appWaitPackage_ - Begin automation after this package starts (optional). - _appWaitActivity_ - Begin automation after this activity starts (optional). - _intentAction_ - Intent to start (opt_ional). - _intentCategory_ - Intent category to start (optional). - _intentFlags_ - Flags to send to the intent (optional). - _optionalIntentArguments_ - Optional arguments to the intent (optional). - _stopAppOnReset_ - Should the app be stopped on reset (optional)? """ # Almost the same code as in appium's start activity, # just to keep the same keyword names as in open application arguments = { 'app_wait_package': 'appWaitPackage', 'app_wait_activity': 'appWaitActivity', 'intent_action': 'intentAction', 'intent_category': 'intentCategory', 'intent_flags': 'intentFlags', 'optional_intent_arguments': 'optionalIntentArguments', 'stop_app_on_reset': 'stopAppOnReset' } data = {} for key, value in arguments.items(): if value in opts: data[key] = opts[value] driver = self._current_application() driver.start_activity(app_package=appPackage, app_activity=appActivity, **data)
[ "def", "start_activity", "(", "self", ",", "appPackage", ",", "appActivity", ",", "*", "*", "opts", ")", ":", "# Almost the same code as in appium's start activity,", "# just to keep the same keyword names as in open application", "arguments", "=", "{", "'app_wait_package'", ":", "'appWaitPackage'", ",", "'app_wait_activity'", ":", "'appWaitActivity'", ",", "'intent_action'", ":", "'intentAction'", ",", "'intent_category'", ":", "'intentCategory'", ",", "'intent_flags'", ":", "'intentFlags'", ",", "'optional_intent_arguments'", ":", "'optionalIntentArguments'", ",", "'stop_app_on_reset'", ":", "'stopAppOnReset'", "}", "data", "=", "{", "}", "for", "key", ",", "value", "in", "arguments", ".", "items", "(", ")", ":", "if", "value", "in", "opts", ":", "data", "[", "key", "]", "=", "opts", "[", "value", "]", "driver", "=", "self", ".", "_current_application", "(", ")", "driver", ".", "start_activity", "(", "app_package", "=", "appPackage", ",", "app_activity", "=", "appActivity", ",", "*", "*", "data", ")" ]
Opens an arbitrary activity during a test. If the activity belongs to another application, that application is started and the activity is opened. Android only. - _appPackage_ - The package containing the activity to start. - _appActivity_ - The activity to start. - _appWaitPackage_ - Begin automation after this package starts (optional). - _appWaitActivity_ - Begin automation after this activity starts (optional). - _intentAction_ - Intent to start (opt_ional). - _intentCategory_ - Intent category to start (optional). - _intentFlags_ - Flags to send to the intent (optional). - _optionalIntentArguments_ - Optional arguments to the intent (optional). - _stopAppOnReset_ - Should the app be stopped on reset (optional)?
[ "Opens", "an", "arbitrary", "activity", "during", "a", "test", ".", "If", "the", "activity", "belongs", "to", "another", "application", "that", "application", "is", "started", "and", "the", "activity", "is", "opened", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_android_utils.py#L89-L128
231,548
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_android_utils.py
_AndroidUtilsKeywords.install_app
def install_app(self, app_path, app_package): """ Install App via Appium Android only. - app_path - path to app - app_package - package of install app to verify """ driver = self._current_application() driver.install_app(app_path) return driver.is_app_installed(app_package)
python
def install_app(self, app_path, app_package): """ Install App via Appium Android only. - app_path - path to app - app_package - package of install app to verify """ driver = self._current_application() driver.install_app(app_path) return driver.is_app_installed(app_package)
[ "def", "install_app", "(", "self", ",", "app_path", ",", "app_package", ")", ":", "driver", "=", "self", ".", "_current_application", "(", ")", "driver", ".", "install_app", "(", "app_path", ")", "return", "driver", ".", "is_app_installed", "(", "app_package", ")" ]
Install App via Appium Android only. - app_path - path to app - app_package - package of install app to verify
[ "Install", "App", "via", "Appium", "Android", "only", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_android_utils.py#L148-L158
231,549
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.click_element
def click_element(self, locator): """Click element identified by `locator`. Key attributes for arbitrary elements are `index` and `name`. See `introduction` for details about locating elements. """ self._info("Clicking element '%s'." % locator) self._element_find(locator, True, True).click()
python
def click_element(self, locator): """Click element identified by `locator`. Key attributes for arbitrary elements are `index` and `name`. See `introduction` for details about locating elements. """ self._info("Clicking element '%s'." % locator) self._element_find(locator, True, True).click()
[ "def", "click_element", "(", "self", ",", "locator", ")", ":", "self", ".", "_info", "(", "\"Clicking element '%s'.\"", "%", "locator", ")", "self", ".", "_element_find", "(", "locator", ",", "True", ",", "True", ")", ".", "click", "(", ")" ]
Click element identified by `locator`. Key attributes for arbitrary elements are `index` and `name`. See `introduction` for details about locating elements.
[ "Click", "element", "identified", "by", "locator", ".", "Key", "attributes", "for", "arbitrary", "elements", "are", "index", "and", "name", ".", "See", "introduction", "for", "details", "about", "locating", "elements", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L35-L42
231,550
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.click_text
def click_text(self, text, exact_match=False): """Click text identified by ``text``. By default tries to click first text involves given ``text``, if you would like to click exactly matching text, then set ``exact_match`` to `True`. If there are multiple use of ``text`` and you do not want first one, use `locator` with `Get Web Elements` instead. """ self._element_find_by_text(text,exact_match).click()
python
def click_text(self, text, exact_match=False): """Click text identified by ``text``. By default tries to click first text involves given ``text``, if you would like to click exactly matching text, then set ``exact_match`` to `True`. If there are multiple use of ``text`` and you do not want first one, use `locator` with `Get Web Elements` instead. """ self._element_find_by_text(text,exact_match).click()
[ "def", "click_text", "(", "self", ",", "text", ",", "exact_match", "=", "False", ")", ":", "self", ".", "_element_find_by_text", "(", "text", ",", "exact_match", ")", ".", "click", "(", ")" ]
Click text identified by ``text``. By default tries to click first text involves given ``text``, if you would like to click exactly matching text, then set ``exact_match`` to `True`. If there are multiple use of ``text`` and you do not want first one, use `locator` with `Get Web Elements` instead.
[ "Click", "text", "identified", "by", "text", ".", "By", "default", "tries", "to", "click", "first", "text", "involves", "given", "text", "if", "you", "would", "like", "to", "click", "exactly", "matching", "text", "then", "set", "exact_match", "to", "True", ".", "If", "there", "are", "multiple", "use", "of", "text", "and", "you", "do", "not", "want", "first", "one", "use", "locator", "with", "Get", "Web", "Elements", "instead", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L52-L62
231,551
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.input_text
def input_text(self, locator, text): """Types the given `text` into text field identified by `locator`. See `introduction` for details about locating elements. """ self._info("Typing text '%s' into text field '%s'" % (text, locator)) self._element_input_text_by_locator(locator, text)
python
def input_text(self, locator, text): """Types the given `text` into text field identified by `locator`. See `introduction` for details about locating elements. """ self._info("Typing text '%s' into text field '%s'" % (text, locator)) self._element_input_text_by_locator(locator, text)
[ "def", "input_text", "(", "self", ",", "locator", ",", "text", ")", ":", "self", ".", "_info", "(", "\"Typing text '%s' into text field '%s'\"", "%", "(", "text", ",", "locator", ")", ")", "self", ".", "_element_input_text_by_locator", "(", "locator", ",", "text", ")" ]
Types the given `text` into text field identified by `locator`. See `introduction` for details about locating elements.
[ "Types", "the", "given", "text", "into", "text", "field", "identified", "by", "locator", ".", "See", "introduction", "for", "details", "about", "locating", "elements", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L64-L70
231,552
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.input_password
def input_password(self, locator, text): """Types the given password into text field identified by `locator`. Difference between this keyword and `Input Text` is that this keyword does not log the given password. See `introduction` for details about locating elements. """ self._info("Typing password into text field '%s'" % locator) self._element_input_text_by_locator(locator, text)
python
def input_password(self, locator, text): """Types the given password into text field identified by `locator`. Difference between this keyword and `Input Text` is that this keyword does not log the given password. See `introduction` for details about locating elements. """ self._info("Typing password into text field '%s'" % locator) self._element_input_text_by_locator(locator, text)
[ "def", "input_password", "(", "self", ",", "locator", ",", "text", ")", ":", "self", ".", "_info", "(", "\"Typing password into text field '%s'\"", "%", "locator", ")", "self", ".", "_element_input_text_by_locator", "(", "locator", ",", "text", ")" ]
Types the given password into text field identified by `locator`. Difference between this keyword and `Input Text` is that this keyword does not log the given password. See `introduction` for details about locating elements.
[ "Types", "the", "given", "password", "into", "text", "field", "identified", "by", "locator", ".", "Difference", "between", "this", "keyword", "and", "Input", "Text", "is", "that", "this", "keyword", "does", "not", "log", "the", "given", "password", ".", "See", "introduction", "for", "details", "about", "locating", "elements", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L72-L80
231,553
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.input_value
def input_value(self, locator, text): """Sets the given value into text field identified by `locator`. This is an IOS only keyword, input value makes use of set_value See `introduction` for details about locating elements. """ self._info("Setting text '%s' into text field '%s'" % (text, locator)) self._element_input_value_by_locator(locator, text)
python
def input_value(self, locator, text): """Sets the given value into text field identified by `locator`. This is an IOS only keyword, input value makes use of set_value See `introduction` for details about locating elements. """ self._info("Setting text '%s' into text field '%s'" % (text, locator)) self._element_input_value_by_locator(locator, text)
[ "def", "input_value", "(", "self", ",", "locator", ",", "text", ")", ":", "self", ".", "_info", "(", "\"Setting text '%s' into text field '%s'\"", "%", "(", "text", ",", "locator", ")", ")", "self", ".", "_element_input_value_by_locator", "(", "locator", ",", "text", ")" ]
Sets the given value into text field identified by `locator`. This is an IOS only keyword, input value makes use of set_value See `introduction` for details about locating elements.
[ "Sets", "the", "given", "value", "into", "text", "field", "identified", "by", "locator", ".", "This", "is", "an", "IOS", "only", "keyword", "input", "value", "makes", "use", "of", "set_value", "See", "introduction", "for", "details", "about", "locating", "elements", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L82-L88
231,554
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.page_should_contain_text
def page_should_contain_text(self, text, loglevel='INFO'): """Verifies that current page contains `text`. If this keyword fails, it automatically logs the page source using the log level specified with the optional `loglevel` argument. Giving `NONE` as level disables logging. """ if not self._is_text_present(text): self.log_source(loglevel) raise AssertionError("Page should have contained text '%s' " "but did not" % text) self._info("Current page contains text '%s'." % text)
python
def page_should_contain_text(self, text, loglevel='INFO'): """Verifies that current page contains `text`. If this keyword fails, it automatically logs the page source using the log level specified with the optional `loglevel` argument. Giving `NONE` as level disables logging. """ if not self._is_text_present(text): self.log_source(loglevel) raise AssertionError("Page should have contained text '%s' " "but did not" % text) self._info("Current page contains text '%s'." % text)
[ "def", "page_should_contain_text", "(", "self", ",", "text", ",", "loglevel", "=", "'INFO'", ")", ":", "if", "not", "self", ".", "_is_text_present", "(", "text", ")", ":", "self", ".", "log_source", "(", "loglevel", ")", "raise", "AssertionError", "(", "\"Page should have contained text '%s' \"", "\"but did not\"", "%", "text", ")", "self", ".", "_info", "(", "\"Current page contains text '%s'.\"", "%", "text", ")" ]
Verifies that current page contains `text`. If this keyword fails, it automatically logs the page source using the log level specified with the optional `loglevel` argument. Giving `NONE` as level disables logging.
[ "Verifies", "that", "current", "page", "contains", "text", ".", "If", "this", "keyword", "fails", "it", "automatically", "logs", "the", "page", "source", "using", "the", "log", "level", "specified", "with", "the", "optional", "loglevel", "argument", ".", "Giving", "NONE", "as", "level", "disables", "logging", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L97-L108
231,555
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.page_should_not_contain_text
def page_should_not_contain_text(self, text, loglevel='INFO'): """Verifies that current page not contains `text`. If this keyword fails, it automatically logs the page source using the log level specified with the optional `loglevel` argument. Giving `NONE` as level disables logging. """ if self._is_text_present(text): self.log_source(loglevel) raise AssertionError("Page should not have contained text '%s'" % text) self._info("Current page does not contains text '%s'." % text)
python
def page_should_not_contain_text(self, text, loglevel='INFO'): """Verifies that current page not contains `text`. If this keyword fails, it automatically logs the page source using the log level specified with the optional `loglevel` argument. Giving `NONE` as level disables logging. """ if self._is_text_present(text): self.log_source(loglevel) raise AssertionError("Page should not have contained text '%s'" % text) self._info("Current page does not contains text '%s'." % text)
[ "def", "page_should_not_contain_text", "(", "self", ",", "text", ",", "loglevel", "=", "'INFO'", ")", ":", "if", "self", ".", "_is_text_present", "(", "text", ")", ":", "self", ".", "log_source", "(", "loglevel", ")", "raise", "AssertionError", "(", "\"Page should not have contained text '%s'\"", "%", "text", ")", "self", ".", "_info", "(", "\"Current page does not contains text '%s'.\"", "%", "text", ")" ]
Verifies that current page not contains `text`. If this keyword fails, it automatically logs the page source using the log level specified with the optional `loglevel` argument. Giving `NONE` as level disables logging.
[ "Verifies", "that", "current", "page", "not", "contains", "text", ".", "If", "this", "keyword", "fails", "it", "automatically", "logs", "the", "page", "source", "using", "the", "log", "level", "specified", "with", "the", "optional", "loglevel", "argument", ".", "Giving", "NONE", "as", "level", "disables", "logging", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L110-L120
231,556
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.page_should_contain_element
def page_should_contain_element(self, locator, loglevel='INFO'): """Verifies that current page contains `locator` element. If this keyword fails, it automatically logs the page source using the log level specified with the optional `loglevel` argument. Giving `NONE` as level disables logging. """ if not self._is_element_present(locator): self.log_source(loglevel) raise AssertionError("Page should have contained element '%s' " "but did not" % locator) self._info("Current page contains element '%s'." % locator)
python
def page_should_contain_element(self, locator, loglevel='INFO'): """Verifies that current page contains `locator` element. If this keyword fails, it automatically logs the page source using the log level specified with the optional `loglevel` argument. Giving `NONE` as level disables logging. """ if not self._is_element_present(locator): self.log_source(loglevel) raise AssertionError("Page should have contained element '%s' " "but did not" % locator) self._info("Current page contains element '%s'." % locator)
[ "def", "page_should_contain_element", "(", "self", ",", "locator", ",", "loglevel", "=", "'INFO'", ")", ":", "if", "not", "self", ".", "_is_element_present", "(", "locator", ")", ":", "self", ".", "log_source", "(", "loglevel", ")", "raise", "AssertionError", "(", "\"Page should have contained element '%s' \"", "\"but did not\"", "%", "locator", ")", "self", ".", "_info", "(", "\"Current page contains element '%s'.\"", "%", "locator", ")" ]
Verifies that current page contains `locator` element. If this keyword fails, it automatically logs the page source using the log level specified with the optional `loglevel` argument. Giving `NONE` as level disables logging.
[ "Verifies", "that", "current", "page", "contains", "locator", "element", ".", "If", "this", "keyword", "fails", "it", "automatically", "logs", "the", "page", "source", "using", "the", "log", "level", "specified", "with", "the", "optional", "loglevel", "argument", ".", "Giving", "NONE", "as", "level", "disables", "logging", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L122-L133
231,557
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.page_should_not_contain_element
def page_should_not_contain_element(self, locator, loglevel='INFO'): """Verifies that current page not contains `locator` element. If this keyword fails, it automatically logs the page source using the log level specified with the optional `loglevel` argument. Giving `NONE` as level disables logging. """ if self._is_element_present(locator): self.log_source(loglevel) raise AssertionError("Page should not have contained element '%s'" % locator) self._info("Current page not contains element '%s'." % locator)
python
def page_should_not_contain_element(self, locator, loglevel='INFO'): """Verifies that current page not contains `locator` element. If this keyword fails, it automatically logs the page source using the log level specified with the optional `loglevel` argument. Giving `NONE` as level disables logging. """ if self._is_element_present(locator): self.log_source(loglevel) raise AssertionError("Page should not have contained element '%s'" % locator) self._info("Current page not contains element '%s'." % locator)
[ "def", "page_should_not_contain_element", "(", "self", ",", "locator", ",", "loglevel", "=", "'INFO'", ")", ":", "if", "self", ".", "_is_element_present", "(", "locator", ")", ":", "self", ".", "log_source", "(", "loglevel", ")", "raise", "AssertionError", "(", "\"Page should not have contained element '%s'\"", "%", "locator", ")", "self", ".", "_info", "(", "\"Current page not contains element '%s'.\"", "%", "locator", ")" ]
Verifies that current page not contains `locator` element. If this keyword fails, it automatically logs the page source using the log level specified with the optional `loglevel` argument. Giving `NONE` as level disables logging.
[ "Verifies", "that", "current", "page", "not", "contains", "locator", "element", ".", "If", "this", "keyword", "fails", "it", "automatically", "logs", "the", "page", "source", "using", "the", "log", "level", "specified", "with", "the", "optional", "loglevel", "argument", ".", "Giving", "NONE", "as", "level", "disables", "logging", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L135-L145
231,558
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.element_should_be_disabled
def element_should_be_disabled(self, locator, loglevel='INFO'): """Verifies that element identified with locator is disabled. Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements. """ if self._element_find(locator, True, True).is_enabled(): self.log_source(loglevel) raise AssertionError("Element '%s' should be disabled " "but did not" % locator) self._info("Element '%s' is disabled ." % locator)
python
def element_should_be_disabled(self, locator, loglevel='INFO'): """Verifies that element identified with locator is disabled. Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements. """ if self._element_find(locator, True, True).is_enabled(): self.log_source(loglevel) raise AssertionError("Element '%s' should be disabled " "but did not" % locator) self._info("Element '%s' is disabled ." % locator)
[ "def", "element_should_be_disabled", "(", "self", ",", "locator", ",", "loglevel", "=", "'INFO'", ")", ":", "if", "self", ".", "_element_find", "(", "locator", ",", "True", ",", "True", ")", ".", "is_enabled", "(", ")", ":", "self", ".", "log_source", "(", "loglevel", ")", "raise", "AssertionError", "(", "\"Element '%s' should be disabled \"", "\"but did not\"", "%", "locator", ")", "self", ".", "_info", "(", "\"Element '%s' is disabled .\"", "%", "locator", ")" ]
Verifies that element identified with locator is disabled. Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements.
[ "Verifies", "that", "element", "identified", "with", "locator", "is", "disabled", ".", "Key", "attributes", "for", "arbitrary", "elements", "are", "id", "and", "name", ".", "See", "introduction", "for", "details", "about", "locating", "elements", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L147-L157
231,559
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.element_should_be_visible
def element_should_be_visible(self, locator, loglevel='INFO'): """Verifies that element identified with locator is visible. Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements. New in AppiumLibrary 1.4.5 """ if not self._element_find(locator, True, True).is_displayed(): self.log_source(loglevel) raise AssertionError("Element '%s' should be visible " "but did not" % locator)
python
def element_should_be_visible(self, locator, loglevel='INFO'): """Verifies that element identified with locator is visible. Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements. New in AppiumLibrary 1.4.5 """ if not self._element_find(locator, True, True).is_displayed(): self.log_source(loglevel) raise AssertionError("Element '%s' should be visible " "but did not" % locator)
[ "def", "element_should_be_visible", "(", "self", ",", "locator", ",", "loglevel", "=", "'INFO'", ")", ":", "if", "not", "self", ".", "_element_find", "(", "locator", ",", "True", ",", "True", ")", ".", "is_displayed", "(", ")", ":", "self", ".", "log_source", "(", "loglevel", ")", "raise", "AssertionError", "(", "\"Element '%s' should be visible \"", "\"but did not\"", "%", "locator", ")" ]
Verifies that element identified with locator is visible. Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements. New in AppiumLibrary 1.4.5
[ "Verifies", "that", "element", "identified", "with", "locator", "is", "visible", ".", "Key", "attributes", "for", "arbitrary", "elements", "are", "id", "and", "name", ".", "See", "introduction", "for", "details", "about", "locating", "elements", ".", "New", "in", "AppiumLibrary", "1", ".", "4", ".", "5" ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L171-L182
231,560
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.element_text_should_be
def element_text_should_be(self, locator, expected, message=''): """Verifies element identified by ``locator`` exactly contains text ``expected``. In contrast to `Element Should Contain Text`, this keyword does not try a substring match but an exact match on the element identified by ``locator``. ``message`` can be used to override the default error message. New in AppiumLibrary 1.4. """ self._info("Verifying element '%s' contains exactly text '%s'." % (locator, expected)) element = self._element_find(locator, True, True) actual = element.text if expected != actual: if not message: message = "The text of element '%s' should have been '%s' but "\ "in fact it was '%s'." % (locator, expected, actual) raise AssertionError(message)
python
def element_text_should_be(self, locator, expected, message=''): """Verifies element identified by ``locator`` exactly contains text ``expected``. In contrast to `Element Should Contain Text`, this keyword does not try a substring match but an exact match on the element identified by ``locator``. ``message`` can be used to override the default error message. New in AppiumLibrary 1.4. """ self._info("Verifying element '%s' contains exactly text '%s'." % (locator, expected)) element = self._element_find(locator, True, True) actual = element.text if expected != actual: if not message: message = "The text of element '%s' should have been '%s' but "\ "in fact it was '%s'." % (locator, expected, actual) raise AssertionError(message)
[ "def", "element_text_should_be", "(", "self", ",", "locator", ",", "expected", ",", "message", "=", "''", ")", ":", "self", ".", "_info", "(", "\"Verifying element '%s' contains exactly text '%s'.\"", "%", "(", "locator", ",", "expected", ")", ")", "element", "=", "self", ".", "_element_find", "(", "locator", ",", "True", ",", "True", ")", "actual", "=", "element", ".", "text", "if", "expected", "!=", "actual", ":", "if", "not", "message", ":", "message", "=", "\"The text of element '%s' should have been '%s' but \"", "\"in fact it was '%s'.\"", "%", "(", "locator", ",", "expected", ",", "actual", ")", "raise", "AssertionError", "(", "message", ")" ]
Verifies element identified by ``locator`` exactly contains text ``expected``. In contrast to `Element Should Contain Text`, this keyword does not try a substring match but an exact match on the element identified by ``locator``. ``message`` can be used to override the default error message. New in AppiumLibrary 1.4.
[ "Verifies", "element", "identified", "by", "locator", "exactly", "contains", "text", "expected", ".", "In", "contrast", "to", "Element", "Should", "Contain", "Text", "this", "keyword", "does", "not", "try", "a", "substring", "match", "but", "an", "exact", "match", "on", "the", "element", "identified", "by", "locator", ".", "message", "can", "be", "used", "to", "override", "the", "default", "error", "message", ".", "New", "in", "AppiumLibrary", "1", ".", "4", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L312-L330
231,561
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.get_element_location
def get_element_location(self, locator): """Get element location Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements. """ element = self._element_find(locator, True, True) element_location = element.location self._info("Element '%s' location: %s " % (locator, element_location)) return element_location
python
def get_element_location(self, locator): """Get element location Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements. """ element = self._element_find(locator, True, True) element_location = element.location self._info("Element '%s' location: %s " % (locator, element_location)) return element_location
[ "def", "get_element_location", "(", "self", ",", "locator", ")", ":", "element", "=", "self", ".", "_element_find", "(", "locator", ",", "True", ",", "True", ")", "element_location", "=", "element", ".", "location", "self", ".", "_info", "(", "\"Element '%s' location: %s \"", "%", "(", "locator", ",", "element_location", ")", ")", "return", "element_location" ]
Get element location Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements.
[ "Get", "element", "location", "Key", "attributes", "for", "arbitrary", "elements", "are", "id", "and", "name", ".", "See", "introduction", "for", "details", "about", "locating", "elements", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L380-L389
231,562
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.get_element_size
def get_element_size(self, locator): """Get element size Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements. """ element = self._element_find(locator, True, True) element_size = element.size self._info("Element '%s' size: %s " % (locator, element_size)) return element_size
python
def get_element_size(self, locator): """Get element size Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements. """ element = self._element_find(locator, True, True) element_size = element.size self._info("Element '%s' size: %s " % (locator, element_size)) return element_size
[ "def", "get_element_size", "(", "self", ",", "locator", ")", ":", "element", "=", "self", ".", "_element_find", "(", "locator", ",", "True", ",", "True", ")", "element_size", "=", "element", ".", "size", "self", ".", "_info", "(", "\"Element '%s' size: %s \"", "%", "(", "locator", ",", "element_size", ")", ")", "return", "element_size" ]
Get element size Key attributes for arbitrary elements are `id` and `name`. See `introduction` for details about locating elements.
[ "Get", "element", "size", "Key", "attributes", "for", "arbitrary", "elements", "are", "id", "and", "name", ".", "See", "introduction", "for", "details", "about", "locating", "elements", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L391-L400
231,563
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_element.py
_ElementKeywords.text_should_be_visible
def text_should_be_visible(self, text, exact_match=False, loglevel='INFO'): """Verifies that element identified with text is visible. New in AppiumLibrary 1.4.5 """ if not self._element_find_by_text(text, exact_match).is_displayed(): self.log_source(loglevel) raise AssertionError("Text '%s' should be visible " "but did not" % text)
python
def text_should_be_visible(self, text, exact_match=False, loglevel='INFO'): """Verifies that element identified with text is visible. New in AppiumLibrary 1.4.5 """ if not self._element_find_by_text(text, exact_match).is_displayed(): self.log_source(loglevel) raise AssertionError("Text '%s' should be visible " "but did not" % text)
[ "def", "text_should_be_visible", "(", "self", ",", "text", ",", "exact_match", "=", "False", ",", "loglevel", "=", "'INFO'", ")", ":", "if", "not", "self", ".", "_element_find_by_text", "(", "text", ",", "exact_match", ")", ".", "is_displayed", "(", ")", ":", "self", ".", "log_source", "(", "loglevel", ")", "raise", "AssertionError", "(", "\"Text '%s' should be visible \"", "\"but did not\"", "%", "text", ")" ]
Verifies that element identified with text is visible. New in AppiumLibrary 1.4.5
[ "Verifies", "that", "element", "identified", "with", "text", "is", "visible", ".", "New", "in", "AppiumLibrary", "1", ".", "4", ".", "5" ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_element.py#L433-L441
231,564
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_applicationmanagement.py
_ApplicationManagementKeywords.close_application
def close_application(self): """Closes the current application and also close webdriver session.""" self._debug('Closing application with session id %s' % self._current_application().session_id) self._cache.close()
python
def close_application(self): """Closes the current application and also close webdriver session.""" self._debug('Closing application with session id %s' % self._current_application().session_id) self._cache.close()
[ "def", "close_application", "(", "self", ")", ":", "self", ".", "_debug", "(", "'Closing application with session id %s'", "%", "self", ".", "_current_application", "(", ")", ".", "session_id", ")", "self", ".", "_cache", ".", "close", "(", ")" ]
Closes the current application and also close webdriver session.
[ "Closes", "the", "current", "application", "and", "also", "close", "webdriver", "session", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_applicationmanagement.py#L20-L23
231,565
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_applicationmanagement.py
_ApplicationManagementKeywords.get_appium_sessionId
def get_appium_sessionId(self): """Returns the current session ID as a reference""" self._info("Appium Session ID: " + self._current_application().session_id) return self._current_application().session_id
python
def get_appium_sessionId(self): """Returns the current session ID as a reference""" self._info("Appium Session ID: " + self._current_application().session_id) return self._current_application().session_id
[ "def", "get_appium_sessionId", "(", "self", ")", ":", "self", ".", "_info", "(", "\"Appium Session ID: \"", "+", "self", ".", "_current_application", "(", ")", ".", "session_id", ")", "return", "self", ".", "_current_application", "(", ")", ".", "session_id" ]
Returns the current session ID as a reference
[ "Returns", "the", "current", "session", "ID", "as", "a", "reference" ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_applicationmanagement.py#L163-L166
231,566
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_applicationmanagement.py
_ApplicationManagementKeywords.lock
def lock(self, seconds=5): """ Lock the device for a certain period of time. iOS only. """ self._current_application().lock(robot.utils.timestr_to_secs(seconds))
python
def lock(self, seconds=5): """ Lock the device for a certain period of time. iOS only. """ self._current_application().lock(robot.utils.timestr_to_secs(seconds))
[ "def", "lock", "(", "self", ",", "seconds", "=", "5", ")", ":", "self", ".", "_current_application", "(", ")", ".", "lock", "(", "robot", ".", "utils", ".", "timestr_to_secs", "(", "seconds", ")", ")" ]
Lock the device for a certain period of time. iOS only.
[ "Lock", "the", "device", "for", "a", "certain", "period", "of", "time", ".", "iOS", "only", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_applicationmanagement.py#L221-L225
231,567
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_applicationmanagement.py
_ApplicationManagementKeywords.get_capability
def get_capability(self, capability_name): """ Return the desired capability value by desired capability name """ try: capability = self._current_application().capabilities[capability_name] except Exception as e: raise e return capability
python
def get_capability(self, capability_name): """ Return the desired capability value by desired capability name """ try: capability = self._current_application().capabilities[capability_name] except Exception as e: raise e return capability
[ "def", "get_capability", "(", "self", ",", "capability_name", ")", ":", "try", ":", "capability", "=", "self", ".", "_current_application", "(", ")", ".", "capabilities", "[", "capability_name", "]", "except", "Exception", "as", "e", ":", "raise", "e", "return", "capability" ]
Return the desired capability value by desired capability name
[ "Return", "the", "desired", "capability", "value", "by", "desired", "capability", "name" ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_applicationmanagement.py#L317-L325
231,568
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/locators/elementfinder.py
ElementFinder._find_by_android
def _find_by_android(self, browser, criteria, tag, constraints): """Find element matches by UI Automator.""" return self._filter_elements( browser.find_elements_by_android_uiautomator(criteria), tag, constraints)
python
def _find_by_android(self, browser, criteria, tag, constraints): """Find element matches by UI Automator.""" return self._filter_elements( browser.find_elements_by_android_uiautomator(criteria), tag, constraints)
[ "def", "_find_by_android", "(", "self", ",", "browser", ",", "criteria", ",", "tag", ",", "constraints", ")", ":", "return", "self", ".", "_filter_elements", "(", "browser", ".", "find_elements_by_android_uiautomator", "(", "criteria", ")", ",", "tag", ",", "constraints", ")" ]
Find element matches by UI Automator.
[ "Find", "element", "matches", "by", "UI", "Automator", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/locators/elementfinder.py#L98-L102
231,569
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/locators/elementfinder.py
ElementFinder._find_by_ios
def _find_by_ios(self, browser, criteria, tag, constraints): """Find element matches by UI Automation.""" return self._filter_elements( browser.find_elements_by_ios_uiautomation(criteria), tag, constraints)
python
def _find_by_ios(self, browser, criteria, tag, constraints): """Find element matches by UI Automation.""" return self._filter_elements( browser.find_elements_by_ios_uiautomation(criteria), tag, constraints)
[ "def", "_find_by_ios", "(", "self", ",", "browser", ",", "criteria", ",", "tag", ",", "constraints", ")", ":", "return", "self", ".", "_filter_elements", "(", "browser", ".", "find_elements_by_ios_uiautomation", "(", "criteria", ")", ",", "tag", ",", "constraints", ")" ]
Find element matches by UI Automation.
[ "Find", "element", "matches", "by", "UI", "Automation", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/locators/elementfinder.py#L104-L108
231,570
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/locators/elementfinder.py
ElementFinder._find_by_nsp
def _find_by_nsp(self, browser, criteria, tag, constraints): """Find element matches by iOSNsPredicateString.""" return self._filter_elements( browser.find_elements_by_ios_predicate(criteria), tag, constraints)
python
def _find_by_nsp(self, browser, criteria, tag, constraints): """Find element matches by iOSNsPredicateString.""" return self._filter_elements( browser.find_elements_by_ios_predicate(criteria), tag, constraints)
[ "def", "_find_by_nsp", "(", "self", ",", "browser", ",", "criteria", ",", "tag", ",", "constraints", ")", ":", "return", "self", ".", "_filter_elements", "(", "browser", ".", "find_elements_by_ios_predicate", "(", "criteria", ")", ",", "tag", ",", "constraints", ")" ]
Find element matches by iOSNsPredicateString.
[ "Find", "element", "matches", "by", "iOSNsPredicateString", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/locators/elementfinder.py#L110-L114
231,571
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/locators/elementfinder.py
ElementFinder._find_by_chain
def _find_by_chain(self, browser, criteria, tag, constraints): """Find element matches by iOSChainString.""" return self._filter_elements( browser.find_elements_by_ios_class_chain(criteria), tag, constraints)
python
def _find_by_chain(self, browser, criteria, tag, constraints): """Find element matches by iOSChainString.""" return self._filter_elements( browser.find_elements_by_ios_class_chain(criteria), tag, constraints)
[ "def", "_find_by_chain", "(", "self", ",", "browser", ",", "criteria", ",", "tag", ",", "constraints", ")", ":", "return", "self", ".", "_filter_elements", "(", "browser", ".", "find_elements_by_ios_class_chain", "(", "criteria", ")", ",", "tag", ",", "constraints", ")" ]
Find element matches by iOSChainString.
[ "Find", "element", "matches", "by", "iOSChainString", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/locators/elementfinder.py#L116-L120
231,572
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_keyevent.py
_KeyeventKeywords.press_keycode
def press_keycode(self, keycode, metastate=None): """Sends a press of keycode to the device. Android only. Possible keycodes & meta states can be found in http://developer.android.com/reference/android/view/KeyEvent.html Meta state describe the pressed state of key modifiers such as Shift, Ctrl & Alt keys. The Meta State is an integer in which each bit set to 1 represents a pressed meta key. For example - META_SHIFT_ON = 1 - META_ALT_ON = 2 | metastate=1 --> Shift is pressed | metastate=2 --> Alt is pressed | metastate=3 --> Shift+Alt is pressed - _keycode- - the keycode to be sent to the device - _metastate- - status of the meta keys """ driver = self._current_application() driver.press_keycode(keycode, metastate)
python
def press_keycode(self, keycode, metastate=None): """Sends a press of keycode to the device. Android only. Possible keycodes & meta states can be found in http://developer.android.com/reference/android/view/KeyEvent.html Meta state describe the pressed state of key modifiers such as Shift, Ctrl & Alt keys. The Meta State is an integer in which each bit set to 1 represents a pressed meta key. For example - META_SHIFT_ON = 1 - META_ALT_ON = 2 | metastate=1 --> Shift is pressed | metastate=2 --> Alt is pressed | metastate=3 --> Shift+Alt is pressed - _keycode- - the keycode to be sent to the device - _metastate- - status of the meta keys """ driver = self._current_application() driver.press_keycode(keycode, metastate)
[ "def", "press_keycode", "(", "self", ",", "keycode", ",", "metastate", "=", "None", ")", ":", "driver", "=", "self", ".", "_current_application", "(", ")", "driver", ".", "press_keycode", "(", "keycode", ",", "metastate", ")" ]
Sends a press of keycode to the device. Android only. Possible keycodes & meta states can be found in http://developer.android.com/reference/android/view/KeyEvent.html Meta state describe the pressed state of key modifiers such as Shift, Ctrl & Alt keys. The Meta State is an integer in which each bit set to 1 represents a pressed meta key. For example - META_SHIFT_ON = 1 - META_ALT_ON = 2 | metastate=1 --> Shift is pressed | metastate=2 --> Alt is pressed | metastate=3 --> Shift+Alt is pressed - _keycode- - the keycode to be sent to the device - _metastate- - status of the meta keys
[ "Sends", "a", "press", "of", "keycode", "to", "the", "device", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_keyevent.py#L9-L33
231,573
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_keyevent.py
_KeyeventKeywords.long_press_keycode
def long_press_keycode(self, keycode, metastate=None): """Sends a long press of keycode to the device. Android only. See `press keycode` for more details. """ driver = self._current_application() driver.long_press_keycode(int(keycode), metastate)
python
def long_press_keycode(self, keycode, metastate=None): """Sends a long press of keycode to the device. Android only. See `press keycode` for more details. """ driver = self._current_application() driver.long_press_keycode(int(keycode), metastate)
[ "def", "long_press_keycode", "(", "self", ",", "keycode", ",", "metastate", "=", "None", ")", ":", "driver", "=", "self", ".", "_current_application", "(", ")", "driver", ".", "long_press_keycode", "(", "int", "(", "keycode", ")", ",", "metastate", ")" ]
Sends a long press of keycode to the device. Android only. See `press keycode` for more details.
[ "Sends", "a", "long", "press", "of", "keycode", "to", "the", "device", "." ]
91c808cf0602af6be8135ac529fa488fded04a85
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_keyevent.py#L35-L43
231,574
amanusk/s-tui
s_tui/sources/rapl_read.py
rapl_read
def rapl_read(): """ Read power stats and return dictionary""" basenames = glob.glob('/sys/class/powercap/intel-rapl:*/') basenames = sorted(set({x for x in basenames})) pjoin = os.path.join ret = list() for path in basenames: name = None try: name = cat(pjoin(path, 'name'), fallback=None, binary=False) except (IOError, OSError, ValueError) as err: logging.warning("ignoring %r for file %r", (err, path), RuntimeWarning) continue if name: try: current = cat(pjoin(path, 'energy_uj')) max_reading = 0.0 ret.append(RaplStats(name, float(current), max_reading)) except (IOError, OSError, ValueError) as err: logging.warning("ignoring %r for file %r", (err, path), RuntimeWarning) return ret
python
def rapl_read(): """ Read power stats and return dictionary""" basenames = glob.glob('/sys/class/powercap/intel-rapl:*/') basenames = sorted(set({x for x in basenames})) pjoin = os.path.join ret = list() for path in basenames: name = None try: name = cat(pjoin(path, 'name'), fallback=None, binary=False) except (IOError, OSError, ValueError) as err: logging.warning("ignoring %r for file %r", (err, path), RuntimeWarning) continue if name: try: current = cat(pjoin(path, 'energy_uj')) max_reading = 0.0 ret.append(RaplStats(name, float(current), max_reading)) except (IOError, OSError, ValueError) as err: logging.warning("ignoring %r for file %r", (err, path), RuntimeWarning) return ret
[ "def", "rapl_read", "(", ")", ":", "basenames", "=", "glob", ".", "glob", "(", "'/sys/class/powercap/intel-rapl:*/'", ")", "basenames", "=", "sorted", "(", "set", "(", "{", "x", "for", "x", "in", "basenames", "}", ")", ")", "pjoin", "=", "os", ".", "path", ".", "join", "ret", "=", "list", "(", ")", "for", "path", "in", "basenames", ":", "name", "=", "None", "try", ":", "name", "=", "cat", "(", "pjoin", "(", "path", ",", "'name'", ")", ",", "fallback", "=", "None", ",", "binary", "=", "False", ")", "except", "(", "IOError", ",", "OSError", ",", "ValueError", ")", "as", "err", ":", "logging", ".", "warning", "(", "\"ignoring %r for file %r\"", ",", "(", "err", ",", "path", ")", ",", "RuntimeWarning", ")", "continue", "if", "name", ":", "try", ":", "current", "=", "cat", "(", "pjoin", "(", "path", ",", "'energy_uj'", ")", ")", "max_reading", "=", "0.0", "ret", ".", "append", "(", "RaplStats", "(", "name", ",", "float", "(", "current", ")", ",", "max_reading", ")", ")", "except", "(", "IOError", ",", "OSError", ",", "ValueError", ")", "as", "err", ":", "logging", ".", "warning", "(", "\"ignoring %r for file %r\"", ",", "(", "err", ",", "path", ")", ",", "RuntimeWarning", ")", "return", "ret" ]
Read power stats and return dictionary
[ "Read", "power", "stats", "and", "return", "dictionary" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sources/rapl_read.py#L35-L58
231,575
amanusk/s-tui
s_tui/sturwid/complex_bar_graph.py
ScalableBarGraph.calculate_bar_widths
def calculate_bar_widths(self, size, bardata): """ Return a list of bar widths, one for each bar in data. If self.bar_width is None this implementation will stretch the bars across the available space specified by maxcol. """ (maxcol, _) = size if self.bar_width is not None: return [self.bar_width] * min( len(bardata), int(maxcol / self.bar_width)) if len(bardata) >= maxcol: return [1] * maxcol widths = [] grow = maxcol remain = len(bardata) for _ in bardata: w = int(float(grow) / remain + 0.5) widths.append(w) grow -= w remain -= 1 return widths
python
def calculate_bar_widths(self, size, bardata): """ Return a list of bar widths, one for each bar in data. If self.bar_width is None this implementation will stretch the bars across the available space specified by maxcol. """ (maxcol, _) = size if self.bar_width is not None: return [self.bar_width] * min( len(bardata), int(maxcol / self.bar_width)) if len(bardata) >= maxcol: return [1] * maxcol widths = [] grow = maxcol remain = len(bardata) for _ in bardata: w = int(float(grow) / remain + 0.5) widths.append(w) grow -= w remain -= 1 return widths
[ "def", "calculate_bar_widths", "(", "self", ",", "size", ",", "bardata", ")", ":", "(", "maxcol", ",", "_", ")", "=", "size", "if", "self", ".", "bar_width", "is", "not", "None", ":", "return", "[", "self", ".", "bar_width", "]", "*", "min", "(", "len", "(", "bardata", ")", ",", "int", "(", "maxcol", "/", "self", ".", "bar_width", ")", ")", "if", "len", "(", "bardata", ")", ">=", "maxcol", ":", "return", "[", "1", "]", "*", "maxcol", "widths", "=", "[", "]", "grow", "=", "maxcol", "remain", "=", "len", "(", "bardata", ")", "for", "_", "in", "bardata", ":", "w", "=", "int", "(", "float", "(", "grow", ")", "/", "remain", "+", "0.5", ")", "widths", ".", "append", "(", "w", ")", "grow", "-=", "w", "remain", "-=", "1", "return", "widths" ]
Return a list of bar widths, one for each bar in data. If self.bar_width is None this implementation will stretch the bars across the available space specified by maxcol.
[ "Return", "a", "list", "of", "bar", "widths", "one", "for", "each", "bar", "in", "data", "." ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sturwid/complex_bar_graph.py#L43-L67
231,576
amanusk/s-tui
s_tui/sturwid/complex_bar_graph.py
LabeledBarGraphVector.set_visible_graphs
def set_visible_graphs(self, visible_graph_list=None): """Show a column of the graph selected for display""" if visible_graph_list is None: visible_graph_list = self.visible_graph_list vline = urwid.AttrWrap(urwid.SolidFill(u'|'), 'line') graph_vector_column_list = [] for state, graph, sub_title in zip(visible_graph_list, self.bar_graph_vector, self.sub_title_list): if state: text_w = urwid.Text(sub_title, align='center') sub_title_widget = urwid.ListBox([text_w]) graph_a = [('fixed', 1, sub_title_widget), ('weight', 1, graph)] graph_and_title = urwid.Pile(graph_a) graph_vector_column_list.append(('weight', 1, graph_and_title)) graph_vector_column_list.append(('fixed', 1, vline)) # if all sub graph are disabled if not graph_vector_column_list: self.visible_graph_list = visible_graph_list self.original_widget = urwid.Pile([]) return # remove the last vertical line separator graph_vector_column_list.pop() y_label_a = ('weight', 1, urwid.Columns(graph_vector_column_list)) y_label_and_graphs = [self.y_label, y_label_a] column_w = urwid.Columns(y_label_and_graphs, dividechars=1) y_label_and_graphs_widget = urwid.WidgetPlaceholder(column_w) init_widget = urwid.Pile([('fixed', 1, self.title), ('weight', 1, y_label_and_graphs_widget)]) self.visible_graph_list = visible_graph_list self.original_widget = init_widget
python
def set_visible_graphs(self, visible_graph_list=None): """Show a column of the graph selected for display""" if visible_graph_list is None: visible_graph_list = self.visible_graph_list vline = urwid.AttrWrap(urwid.SolidFill(u'|'), 'line') graph_vector_column_list = [] for state, graph, sub_title in zip(visible_graph_list, self.bar_graph_vector, self.sub_title_list): if state: text_w = urwid.Text(sub_title, align='center') sub_title_widget = urwid.ListBox([text_w]) graph_a = [('fixed', 1, sub_title_widget), ('weight', 1, graph)] graph_and_title = urwid.Pile(graph_a) graph_vector_column_list.append(('weight', 1, graph_and_title)) graph_vector_column_list.append(('fixed', 1, vline)) # if all sub graph are disabled if not graph_vector_column_list: self.visible_graph_list = visible_graph_list self.original_widget = urwid.Pile([]) return # remove the last vertical line separator graph_vector_column_list.pop() y_label_a = ('weight', 1, urwid.Columns(graph_vector_column_list)) y_label_and_graphs = [self.y_label, y_label_a] column_w = urwid.Columns(y_label_and_graphs, dividechars=1) y_label_and_graphs_widget = urwid.WidgetPlaceholder(column_w) init_widget = urwid.Pile([('fixed', 1, self.title), ('weight', 1, y_label_and_graphs_widget)]) self.visible_graph_list = visible_graph_list self.original_widget = init_widget
[ "def", "set_visible_graphs", "(", "self", ",", "visible_graph_list", "=", "None", ")", ":", "if", "visible_graph_list", "is", "None", ":", "visible_graph_list", "=", "self", ".", "visible_graph_list", "vline", "=", "urwid", ".", "AttrWrap", "(", "urwid", ".", "SolidFill", "(", "u'|'", ")", ",", "'line'", ")", "graph_vector_column_list", "=", "[", "]", "for", "state", ",", "graph", ",", "sub_title", "in", "zip", "(", "visible_graph_list", ",", "self", ".", "bar_graph_vector", ",", "self", ".", "sub_title_list", ")", ":", "if", "state", ":", "text_w", "=", "urwid", ".", "Text", "(", "sub_title", ",", "align", "=", "'center'", ")", "sub_title_widget", "=", "urwid", ".", "ListBox", "(", "[", "text_w", "]", ")", "graph_a", "=", "[", "(", "'fixed'", ",", "1", ",", "sub_title_widget", ")", ",", "(", "'weight'", ",", "1", ",", "graph", ")", "]", "graph_and_title", "=", "urwid", ".", "Pile", "(", "graph_a", ")", "graph_vector_column_list", ".", "append", "(", "(", "'weight'", ",", "1", ",", "graph_and_title", ")", ")", "graph_vector_column_list", ".", "append", "(", "(", "'fixed'", ",", "1", ",", "vline", ")", ")", "# if all sub graph are disabled", "if", "not", "graph_vector_column_list", ":", "self", ".", "visible_graph_list", "=", "visible_graph_list", "self", ".", "original_widget", "=", "urwid", ".", "Pile", "(", "[", "]", ")", "return", "# remove the last vertical line separator", "graph_vector_column_list", ".", "pop", "(", ")", "y_label_a", "=", "(", "'weight'", ",", "1", ",", "urwid", ".", "Columns", "(", "graph_vector_column_list", ")", ")", "y_label_and_graphs", "=", "[", "self", ".", "y_label", ",", "y_label_a", "]", "column_w", "=", "urwid", ".", "Columns", "(", "y_label_and_graphs", ",", "dividechars", "=", "1", ")", "y_label_and_graphs_widget", "=", "urwid", ".", "WidgetPlaceholder", "(", "column_w", ")", "init_widget", "=", "urwid", ".", "Pile", "(", "[", "(", "'fixed'", ",", "1", ",", "self", ".", "title", ")", ",", "(", "'weight'", ",", "1", ",", "y_label_and_graphs_widget", ")", "]", ")", "self", ".", "visible_graph_list", "=", "visible_graph_list", "self", ".", "original_widget", "=", "init_widget" ]
Show a column of the graph selected for display
[ "Show", "a", "column", "of", "the", "graph", "selected", "for", "display" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sturwid/complex_bar_graph.py#L135-L174
231,577
amanusk/s-tui
s_tui/helper_functions.py
get_processor_name
def get_processor_name(): """ Returns the processor name in the system """ if platform.system() == "Linux": with open("/proc/cpuinfo", "rb") as cpuinfo: all_info = cpuinfo.readlines() for line in all_info: if b'model name' in line: return re.sub(b'.*model name.*:', b'', line, 1) return platform.processor()
python
def get_processor_name(): """ Returns the processor name in the system """ if platform.system() == "Linux": with open("/proc/cpuinfo", "rb") as cpuinfo: all_info = cpuinfo.readlines() for line in all_info: if b'model name' in line: return re.sub(b'.*model name.*:', b'', line, 1) return platform.processor()
[ "def", "get_processor_name", "(", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "\"Linux\"", ":", "with", "open", "(", "\"/proc/cpuinfo\"", ",", "\"rb\"", ")", "as", "cpuinfo", ":", "all_info", "=", "cpuinfo", ".", "readlines", "(", ")", "for", "line", "in", "all_info", ":", "if", "b'model name'", "in", "line", ":", "return", "re", ".", "sub", "(", "b'.*model name.*:'", ",", "b''", ",", "line", ",", "1", ")", "return", "platform", ".", "processor", "(", ")" ]
Returns the processor name in the system
[ "Returns", "the", "processor", "name", "in", "the", "system" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/helper_functions.py#L47-L56
231,578
amanusk/s-tui
s_tui/helper_functions.py
kill_child_processes
def kill_child_processes(parent_proc): """ Kills a process and all its children """ logging.debug("Killing stress process") try: for proc in parent_proc.children(recursive=True): logging.debug('Killing %s', proc) proc.kill() parent_proc.kill() except AttributeError: logging.debug('No such process') logging.debug('Could not kill process')
python
def kill_child_processes(parent_proc): """ Kills a process and all its children """ logging.debug("Killing stress process") try: for proc in parent_proc.children(recursive=True): logging.debug('Killing %s', proc) proc.kill() parent_proc.kill() except AttributeError: logging.debug('No such process') logging.debug('Could not kill process')
[ "def", "kill_child_processes", "(", "parent_proc", ")", ":", "logging", ".", "debug", "(", "\"Killing stress process\"", ")", "try", ":", "for", "proc", "in", "parent_proc", ".", "children", "(", "recursive", "=", "True", ")", ":", "logging", ".", "debug", "(", "'Killing %s'", ",", "proc", ")", "proc", ".", "kill", "(", ")", "parent_proc", ".", "kill", "(", ")", "except", "AttributeError", ":", "logging", ".", "debug", "(", "'No such process'", ")", "logging", ".", "debug", "(", "'Could not kill process'", ")" ]
Kills a process and all its children
[ "Kills", "a", "process", "and", "all", "its", "children" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/helper_functions.py#L59-L69
231,579
amanusk/s-tui
s_tui/helper_functions.py
output_to_csv
def output_to_csv(sources, csv_writeable_file): """Print statistics to csv file""" file_exists = os.path.isfile(csv_writeable_file) with open(csv_writeable_file, 'a') as csvfile: csv_dict = OrderedDict() csv_dict.update({'Time': time.strftime("%Y-%m-%d_%H:%M:%S")}) summaries = [val for key, val in sources.items()] for summarie in summaries: csv_dict.update(summarie.source.get_sensors_summary()) fieldnames = [key for key, val in csv_dict.items()] writer = csv.DictWriter(csvfile, fieldnames=fieldnames) if not file_exists: writer.writeheader() # file doesn't exist yet, write a header writer.writerow(csv_dict)
python
def output_to_csv(sources, csv_writeable_file): """Print statistics to csv file""" file_exists = os.path.isfile(csv_writeable_file) with open(csv_writeable_file, 'a') as csvfile: csv_dict = OrderedDict() csv_dict.update({'Time': time.strftime("%Y-%m-%d_%H:%M:%S")}) summaries = [val for key, val in sources.items()] for summarie in summaries: csv_dict.update(summarie.source.get_sensors_summary()) fieldnames = [key for key, val in csv_dict.items()] writer = csv.DictWriter(csvfile, fieldnames=fieldnames) if not file_exists: writer.writeheader() # file doesn't exist yet, write a header writer.writerow(csv_dict)
[ "def", "output_to_csv", "(", "sources", ",", "csv_writeable_file", ")", ":", "file_exists", "=", "os", ".", "path", ".", "isfile", "(", "csv_writeable_file", ")", "with", "open", "(", "csv_writeable_file", ",", "'a'", ")", "as", "csvfile", ":", "csv_dict", "=", "OrderedDict", "(", ")", "csv_dict", ".", "update", "(", "{", "'Time'", ":", "time", ".", "strftime", "(", "\"%Y-%m-%d_%H:%M:%S\"", ")", "}", ")", "summaries", "=", "[", "val", "for", "key", ",", "val", "in", "sources", ".", "items", "(", ")", "]", "for", "summarie", "in", "summaries", ":", "csv_dict", ".", "update", "(", "summarie", ".", "source", ".", "get_sensors_summary", "(", ")", ")", "fieldnames", "=", "[", "key", "for", "key", ",", "val", "in", "csv_dict", ".", "items", "(", ")", "]", "writer", "=", "csv", ".", "DictWriter", "(", "csvfile", ",", "fieldnames", "=", "fieldnames", ")", "if", "not", "file_exists", ":", "writer", ".", "writeheader", "(", ")", "# file doesn't exist yet, write a header", "writer", ".", "writerow", "(", "csv_dict", ")" ]
Print statistics to csv file
[ "Print", "statistics", "to", "csv", "file" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/helper_functions.py#L72-L88
231,580
amanusk/s-tui
s_tui/helper_functions.py
output_to_terminal
def output_to_terminal(sources): """Print statistics to the terminal""" results = OrderedDict() for source in sources: if source.get_is_available(): source.update() results.update(source.get_summary()) for key, value in results.items(): sys.stdout.write(str(key) + ": " + str(value) + ", ") sys.stdout.write("\n") sys.exit()
python
def output_to_terminal(sources): """Print statistics to the terminal""" results = OrderedDict() for source in sources: if source.get_is_available(): source.update() results.update(source.get_summary()) for key, value in results.items(): sys.stdout.write(str(key) + ": " + str(value) + ", ") sys.stdout.write("\n") sys.exit()
[ "def", "output_to_terminal", "(", "sources", ")", ":", "results", "=", "OrderedDict", "(", ")", "for", "source", "in", "sources", ":", "if", "source", ".", "get_is_available", "(", ")", ":", "source", ".", "update", "(", ")", "results", ".", "update", "(", "source", ".", "get_summary", "(", ")", ")", "for", "key", ",", "value", "in", "results", ".", "items", "(", ")", ":", "sys", ".", "stdout", ".", "write", "(", "str", "(", "key", ")", "+", "\": \"", "+", "str", "(", "value", ")", "+", "\", \"", ")", "sys", ".", "stdout", ".", "write", "(", "\"\\n\"", ")", "sys", ".", "exit", "(", ")" ]
Print statistics to the terminal
[ "Print", "statistics", "to", "the", "terminal" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/helper_functions.py#L91-L101
231,581
amanusk/s-tui
s_tui/helper_functions.py
output_to_json
def output_to_json(sources): """Print statistics to the terminal in Json format""" results = OrderedDict() for source in sources: if source.get_is_available(): source.update() source_name = source.get_source_name() results[source_name] = source.get_sensors_summary() print(json.dumps(results, indent=4)) sys.exit()
python
def output_to_json(sources): """Print statistics to the terminal in Json format""" results = OrderedDict() for source in sources: if source.get_is_available(): source.update() source_name = source.get_source_name() results[source_name] = source.get_sensors_summary() print(json.dumps(results, indent=4)) sys.exit()
[ "def", "output_to_json", "(", "sources", ")", ":", "results", "=", "OrderedDict", "(", ")", "for", "source", "in", "sources", ":", "if", "source", ".", "get_is_available", "(", ")", ":", "source", ".", "update", "(", ")", "source_name", "=", "source", ".", "get_source_name", "(", ")", "results", "[", "source_name", "]", "=", "source", ".", "get_sensors_summary", "(", ")", "print", "(", "json", ".", "dumps", "(", "results", ",", "indent", "=", "4", ")", ")", "sys", ".", "exit", "(", ")" ]
Print statistics to the terminal in Json format
[ "Print", "statistics", "to", "the", "terminal", "in", "Json", "format" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/helper_functions.py#L104-L113
231,582
amanusk/s-tui
s_tui/helper_functions.py
make_user_config_dir
def make_user_config_dir(): """ Create the user s-tui config directory if it doesn't exist """ config_path = get_user_config_dir() if not user_config_dir_exists(): try: os.mkdir(config_path) os.mkdir(os.path.join(config_path, 'hooks.d')) except OSError: return None return config_path
python
def make_user_config_dir(): """ Create the user s-tui config directory if it doesn't exist """ config_path = get_user_config_dir() if not user_config_dir_exists(): try: os.mkdir(config_path) os.mkdir(os.path.join(config_path, 'hooks.d')) except OSError: return None return config_path
[ "def", "make_user_config_dir", "(", ")", ":", "config_path", "=", "get_user_config_dir", "(", ")", "if", "not", "user_config_dir_exists", "(", ")", ":", "try", ":", "os", ".", "mkdir", "(", "config_path", ")", "os", ".", "mkdir", "(", "os", ".", "path", ".", "join", "(", "config_path", ",", "'hooks.d'", ")", ")", "except", "OSError", ":", "return", "None", "return", "config_path" ]
Create the user s-tui config directory if it doesn't exist
[ "Create", "the", "user", "s", "-", "tui", "config", "directory", "if", "it", "doesn", "t", "exist" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/helper_functions.py#L157-L170
231,583
amanusk/s-tui
s_tui/sources/script_hook_loader.py
ScriptHookLoader.load_script
def load_script(self, source_name, timeoutMilliseconds=0): """ Return ScriptHook for source_name Source and with a ready timeout of timeoutMilliseconds """ script_path = os.path.join(self.scripts_dir_path, self._source_to_script_name(source_name)) if os.path.isfile(script_path): return ScriptHook(script_path, timeoutMilliseconds) return None
python
def load_script(self, source_name, timeoutMilliseconds=0): """ Return ScriptHook for source_name Source and with a ready timeout of timeoutMilliseconds """ script_path = os.path.join(self.scripts_dir_path, self._source_to_script_name(source_name)) if os.path.isfile(script_path): return ScriptHook(script_path, timeoutMilliseconds) return None
[ "def", "load_script", "(", "self", ",", "source_name", ",", "timeoutMilliseconds", "=", "0", ")", ":", "script_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "scripts_dir_path", ",", "self", ".", "_source_to_script_name", "(", "source_name", ")", ")", "if", "os", ".", "path", ".", "isfile", "(", "script_path", ")", ":", "return", "ScriptHook", "(", "script_path", ",", "timeoutMilliseconds", ")", "return", "None" ]
Return ScriptHook for source_name Source and with a ready timeout of timeoutMilliseconds
[ "Return", "ScriptHook", "for", "source_name", "Source", "and", "with", "a", "ready", "timeout", "of", "timeoutMilliseconds" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sources/script_hook_loader.py#L31-L42
231,584
amanusk/s-tui
s_tui/sources/source.py
Source.get_sensors_summary
def get_sensors_summary(self): """ This returns a dict of sensor of the source and their values """ sub_title_list = self.get_sensor_list() graph_vector_summary = OrderedDict() for graph_idx, graph_data in enumerate(self.last_measurement): val_str = str(round(graph_data, 1)) graph_vector_summary[sub_title_list[graph_idx]] = val_str return graph_vector_summary
python
def get_sensors_summary(self): """ This returns a dict of sensor of the source and their values """ sub_title_list = self.get_sensor_list() graph_vector_summary = OrderedDict() for graph_idx, graph_data in enumerate(self.last_measurement): val_str = str(round(graph_data, 1)) graph_vector_summary[sub_title_list[graph_idx]] = val_str return graph_vector_summary
[ "def", "get_sensors_summary", "(", "self", ")", ":", "sub_title_list", "=", "self", ".", "get_sensor_list", "(", ")", "graph_vector_summary", "=", "OrderedDict", "(", ")", "for", "graph_idx", ",", "graph_data", "in", "enumerate", "(", "self", ".", "last_measurement", ")", ":", "val_str", "=", "str", "(", "round", "(", "graph_data", ",", "1", ")", ")", "graph_vector_summary", "[", "sub_title_list", "[", "graph_idx", "]", "]", "=", "val_str", "return", "graph_vector_summary" ]
This returns a dict of sensor of the source and their values
[ "This", "returns", "a", "dict", "of", "sensor", "of", "the", "source", "and", "their", "values" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sources/source.py#L53-L62
231,585
amanusk/s-tui
s_tui/sources/source.py
Source.get_summary
def get_summary(self): """ Returns a dict of source name and sensors with their values """ graph_vector_summary = OrderedDict() graph_vector_summary[self.get_source_name()] = ( '[' + self.measurement_unit + ']') graph_vector_summary.update(self.get_sensors_summary()) return graph_vector_summary
python
def get_summary(self): """ Returns a dict of source name and sensors with their values """ graph_vector_summary = OrderedDict() graph_vector_summary[self.get_source_name()] = ( '[' + self.measurement_unit + ']') graph_vector_summary.update(self.get_sensors_summary()) return graph_vector_summary
[ "def", "get_summary", "(", "self", ")", ":", "graph_vector_summary", "=", "OrderedDict", "(", ")", "graph_vector_summary", "[", "self", ".", "get_source_name", "(", ")", "]", "=", "(", "'['", "+", "self", ".", "measurement_unit", "+", "']'", ")", "graph_vector_summary", ".", "update", "(", "self", ".", "get_sensors_summary", "(", ")", ")", "return", "graph_vector_summary" ]
Returns a dict of source name and sensors with their values
[ "Returns", "a", "dict", "of", "source", "name", "and", "sensors", "with", "their", "values" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sources/source.py#L64-L70
231,586
amanusk/s-tui
s_tui/sources/source.py
Source.eval_hooks
def eval_hooks(self): """ Evaluate the current state of this Source and invoke any attached hooks if they've been triggered """ logging.debug("Evaluating hooks") if self.get_edge_triggered(): logging.debug("Hook triggered") for hook in [h for h in self.edge_hooks if h.is_ready()]: logging.debug("Hook invoked") hook.invoke()
python
def eval_hooks(self): """ Evaluate the current state of this Source and invoke any attached hooks if they've been triggered """ logging.debug("Evaluating hooks") if self.get_edge_triggered(): logging.debug("Hook triggered") for hook in [h for h in self.edge_hooks if h.is_ready()]: logging.debug("Hook invoked") hook.invoke()
[ "def", "eval_hooks", "(", "self", ")", ":", "logging", ".", "debug", "(", "\"Evaluating hooks\"", ")", "if", "self", ".", "get_edge_triggered", "(", ")", ":", "logging", ".", "debug", "(", "\"Hook triggered\"", ")", "for", "hook", "in", "[", "h", "for", "h", "in", "self", ".", "edge_hooks", "if", "h", ".", "is_ready", "(", ")", "]", ":", "logging", ".", "debug", "(", "\"Hook invoked\"", ")", "hook", ".", "invoke", "(", ")" ]
Evaluate the current state of this Source and invoke any attached hooks if they've been triggered
[ "Evaluate", "the", "current", "state", "of", "this", "Source", "and", "invoke", "any", "attached", "hooks", "if", "they", "ve", "been", "triggered" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sources/source.py#L109-L119
231,587
amanusk/s-tui
s_tui/sources/hook.py
Hook.invoke
def invoke(self): """ Run callback, optionally passing a variable number of arguments `callback_args` """ # Don't sleep a hook if it has never run if self.timeout_milliseconds > 0: self.ready_time = ( datetime.now() + timedelta(milliseconds=self.timeout_milliseconds)) self.callback(self.callback_args)
python
def invoke(self): """ Run callback, optionally passing a variable number of arguments `callback_args` """ # Don't sleep a hook if it has never run if self.timeout_milliseconds > 0: self.ready_time = ( datetime.now() + timedelta(milliseconds=self.timeout_milliseconds)) self.callback(self.callback_args)
[ "def", "invoke", "(", "self", ")", ":", "# Don't sleep a hook if it has never run", "if", "self", ".", "timeout_milliseconds", ">", "0", ":", "self", ".", "ready_time", "=", "(", "datetime", ".", "now", "(", ")", "+", "timedelta", "(", "milliseconds", "=", "self", ".", "timeout_milliseconds", ")", ")", "self", ".", "callback", "(", "self", ".", "callback_args", ")" ]
Run callback, optionally passing a variable number of arguments `callback_args`
[ "Run", "callback", "optionally", "passing", "a", "variable", "number", "of", "arguments", "callback_args" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sources/hook.py#L42-L54
231,588
amanusk/s-tui
s_tui/sturwid/ui_elements.py
radio_button
def radio_button(g, l, fn): """ Inheriting radio button of urwid """ w = urwid.RadioButton(g, l, False, on_state_change=fn) w = urwid.AttrWrap(w, 'button normal', 'button select') return w
python
def radio_button(g, l, fn): """ Inheriting radio button of urwid """ w = urwid.RadioButton(g, l, False, on_state_change=fn) w = urwid.AttrWrap(w, 'button normal', 'button select') return w
[ "def", "radio_button", "(", "g", ",", "l", ",", "fn", ")", ":", "w", "=", "urwid", ".", "RadioButton", "(", "g", ",", "l", ",", "False", ",", "on_state_change", "=", "fn", ")", "w", "=", "urwid", ".", "AttrWrap", "(", "w", ",", "'button normal'", ",", "'button select'", ")", "return", "w" ]
Inheriting radio button of urwid
[ "Inheriting", "radio", "button", "of", "urwid" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/sturwid/ui_elements.py#L95-L99
231,589
amanusk/s-tui
s_tui/s_tui.py
StressController.start_stress
def start_stress(self, stress_cmd): """ Starts a new stress process with a given cmd """ with open(os.devnull, 'w') as dev_null: try: stress_proc = subprocess.Popen(stress_cmd, stdout=dev_null, stderr=dev_null) self.set_stress_process(psutil.Process(stress_proc.pid)) except OSError: logging.debug("Unable to start stress")
python
def start_stress(self, stress_cmd): """ Starts a new stress process with a given cmd """ with open(os.devnull, 'w') as dev_null: try: stress_proc = subprocess.Popen(stress_cmd, stdout=dev_null, stderr=dev_null) self.set_stress_process(psutil.Process(stress_proc.pid)) except OSError: logging.debug("Unable to start stress")
[ "def", "start_stress", "(", "self", ",", "stress_cmd", ")", ":", "with", "open", "(", "os", ".", "devnull", ",", "'w'", ")", "as", "dev_null", ":", "try", ":", "stress_proc", "=", "subprocess", ".", "Popen", "(", "stress_cmd", ",", "stdout", "=", "dev_null", ",", "stderr", "=", "dev_null", ")", "self", ".", "set_stress_process", "(", "psutil", ".", "Process", "(", "stress_proc", ".", "pid", ")", ")", "except", "OSError", ":", "logging", ".", "debug", "(", "\"Unable to start stress\"", ")" ]
Starts a new stress process with a given cmd
[ "Starts", "a", "new", "stress", "process", "with", "a", "given", "cmd" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L164-L172
231,590
amanusk/s-tui
s_tui/s_tui.py
GraphView.update_displayed_information
def update_displayed_information(self): """ Update all the graphs that are being displayed """ for source in self.controller.sources: source_name = source.get_source_name() if (any(self.graphs_menu.active_sensors[source_name]) or any(self.summary_menu.active_sensors[source_name])): source.update() for graph in self.visible_graphs.values(): graph.update() # update graph summery for summary in self.visible_summaries.values(): summary.update() # Only update clock if not is stress mode if self.controller.stress_conroller.get_current_mode() != 'Monitor': self.clock_view.set_text(seconds_to_text( (timeit.default_timer() - self.controller.stress_start_time)))
python
def update_displayed_information(self): """ Update all the graphs that are being displayed """ for source in self.controller.sources: source_name = source.get_source_name() if (any(self.graphs_menu.active_sensors[source_name]) or any(self.summary_menu.active_sensors[source_name])): source.update() for graph in self.visible_graphs.values(): graph.update() # update graph summery for summary in self.visible_summaries.values(): summary.update() # Only update clock if not is stress mode if self.controller.stress_conroller.get_current_mode() != 'Monitor': self.clock_view.set_text(seconds_to_text( (timeit.default_timer() - self.controller.stress_start_time)))
[ "def", "update_displayed_information", "(", "self", ")", ":", "for", "source", "in", "self", ".", "controller", ".", "sources", ":", "source_name", "=", "source", ".", "get_source_name", "(", ")", "if", "(", "any", "(", "self", ".", "graphs_menu", ".", "active_sensors", "[", "source_name", "]", ")", "or", "any", "(", "self", ".", "summary_menu", ".", "active_sensors", "[", "source_name", "]", ")", ")", ":", "source", ".", "update", "(", ")", "for", "graph", "in", "self", ".", "visible_graphs", ".", "values", "(", ")", ":", "graph", ".", "update", "(", ")", "# update graph summery", "for", "summary", "in", "self", ".", "visible_summaries", ".", "values", "(", ")", ":", "summary", ".", "update", "(", ")", "# Only update clock if not is stress mode", "if", "self", ".", "controller", ".", "stress_conroller", ".", "get_current_mode", "(", ")", "!=", "'Monitor'", ":", "self", ".", "clock_view", ".", "set_text", "(", "seconds_to_text", "(", "(", "timeit", ".", "default_timer", "(", ")", "-", "self", ".", "controller", ".", "stress_start_time", ")", ")", ")" ]
Update all the graphs that are being displayed
[ "Update", "all", "the", "graphs", "that", "are", "being", "displayed" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L235-L254
231,591
amanusk/s-tui
s_tui/s_tui.py
GraphView.on_reset_button
def on_reset_button(self, _): """Reset graph data and display empty graph""" for graph in self.visible_graphs.values(): graph.reset() for graph in self.graphs.values(): try: graph.source.reset() except NotImplementedError: pass # Reset clock self.clock_view.set_text(ZERO_TIME) self.update_displayed_information()
python
def on_reset_button(self, _): """Reset graph data and display empty graph""" for graph in self.visible_graphs.values(): graph.reset() for graph in self.graphs.values(): try: graph.source.reset() except NotImplementedError: pass # Reset clock self.clock_view.set_text(ZERO_TIME) self.update_displayed_information()
[ "def", "on_reset_button", "(", "self", ",", "_", ")", ":", "for", "graph", "in", "self", ".", "visible_graphs", ".", "values", "(", ")", ":", "graph", ".", "reset", "(", ")", "for", "graph", "in", "self", ".", "graphs", ".", "values", "(", ")", ":", "try", ":", "graph", ".", "source", ".", "reset", "(", ")", "except", "NotImplementedError", ":", "pass", "# Reset clock", "self", ".", "clock_view", ".", "set_text", "(", "ZERO_TIME", ")", "self", ".", "update_displayed_information", "(", ")" ]
Reset graph data and display empty graph
[ "Reset", "graph", "data", "and", "display", "empty", "graph" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L256-L268
231,592
amanusk/s-tui
s_tui/s_tui.py
GraphView.on_stress_menu_open
def on_stress_menu_open(self, widget): """Open stress options""" self.original_widget = urwid.Overlay(self.stress_menu.main_window, self.original_widget, ('relative', self.left_margin), self.stress_menu.get_size()[1], ('relative', self.top_margin), self.stress_menu.get_size()[0])
python
def on_stress_menu_open(self, widget): """Open stress options""" self.original_widget = urwid.Overlay(self.stress_menu.main_window, self.original_widget, ('relative', self.left_margin), self.stress_menu.get_size()[1], ('relative', self.top_margin), self.stress_menu.get_size()[0])
[ "def", "on_stress_menu_open", "(", "self", ",", "widget", ")", ":", "self", ".", "original_widget", "=", "urwid", ".", "Overlay", "(", "self", ".", "stress_menu", ".", "main_window", ",", "self", ".", "original_widget", ",", "(", "'relative'", ",", "self", ".", "left_margin", ")", ",", "self", ".", "stress_menu", ".", "get_size", "(", ")", "[", "1", "]", ",", "(", "'relative'", ",", "self", ".", "top_margin", ")", ",", "self", ".", "stress_menu", ".", "get_size", "(", ")", "[", "0", "]", ")" ]
Open stress options
[ "Open", "stress", "options" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L309-L316
231,593
amanusk/s-tui
s_tui/s_tui.py
GraphView.on_help_menu_open
def on_help_menu_open(self, widget): """Open Help menu""" self.original_widget = urwid.Overlay(self.help_menu.main_window, self.original_widget, ('relative', self.left_margin), self.help_menu.get_size()[1], ('relative', self.top_margin), self.help_menu.get_size()[0])
python
def on_help_menu_open(self, widget): """Open Help menu""" self.original_widget = urwid.Overlay(self.help_menu.main_window, self.original_widget, ('relative', self.left_margin), self.help_menu.get_size()[1], ('relative', self.top_margin), self.help_menu.get_size()[0])
[ "def", "on_help_menu_open", "(", "self", ",", "widget", ")", ":", "self", ".", "original_widget", "=", "urwid", ".", "Overlay", "(", "self", ".", "help_menu", ".", "main_window", ",", "self", ".", "original_widget", ",", "(", "'relative'", ",", "self", ".", "left_margin", ")", ",", "self", ".", "help_menu", ".", "get_size", "(", ")", "[", "1", "]", ",", "(", "'relative'", ",", "self", ".", "top_margin", ")", ",", "self", ".", "help_menu", ".", "get_size", "(", ")", "[", "0", "]", ")" ]
Open Help menu
[ "Open", "Help", "menu" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L318-L325
231,594
amanusk/s-tui
s_tui/s_tui.py
GraphView.on_about_menu_open
def on_about_menu_open(self, widget): """Open About menu""" self.original_widget = urwid.Overlay(self.about_menu.main_window, self.original_widget, ('relative', self.left_margin), self.about_menu.get_size()[1], ('relative', self.top_margin), self.about_menu.get_size()[0])
python
def on_about_menu_open(self, widget): """Open About menu""" self.original_widget = urwid.Overlay(self.about_menu.main_window, self.original_widget, ('relative', self.left_margin), self.about_menu.get_size()[1], ('relative', self.top_margin), self.about_menu.get_size()[0])
[ "def", "on_about_menu_open", "(", "self", ",", "widget", ")", ":", "self", ".", "original_widget", "=", "urwid", ".", "Overlay", "(", "self", ".", "about_menu", ".", "main_window", ",", "self", ".", "original_widget", ",", "(", "'relative'", ",", "self", ".", "left_margin", ")", ",", "self", ".", "about_menu", ".", "get_size", "(", ")", "[", "1", "]", ",", "(", "'relative'", ",", "self", ".", "top_margin", ")", ",", "self", ".", "about_menu", ".", "get_size", "(", ")", "[", "0", "]", ")" ]
Open About menu
[ "Open", "About", "menu" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L327-L334
231,595
amanusk/s-tui
s_tui/s_tui.py
GraphView.on_mode_button
def on_mode_button(self, my_button, state): """Notify the controller of a new mode setting.""" if state: # The new mode is the label of the button self.controller.set_mode(my_button.get_label())
python
def on_mode_button(self, my_button, state): """Notify the controller of a new mode setting.""" if state: # The new mode is the label of the button self.controller.set_mode(my_button.get_label())
[ "def", "on_mode_button", "(", "self", ",", "my_button", ",", "state", ")", ":", "if", "state", ":", "# The new mode is the label of the button", "self", ".", "controller", ".", "set_mode", "(", "my_button", ".", "get_label", "(", ")", ")" ]
Notify the controller of a new mode setting.
[ "Notify", "the", "controller", "of", "a", "new", "mode", "setting", "." ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L356-L360
231,596
amanusk/s-tui
s_tui/s_tui.py
GraphView.on_unicode_checkbox
def on_unicode_checkbox(self, w=None, state=False): """Enable smooth edges if utf-8 is supported""" logging.debug("unicode State is %s", state) # Update the controller to the state of the checkbox self.controller.smooth_graph_mode = state if state: self.hline = urwid.AttrWrap( urwid.SolidFill(u'\N{LOWER ONE QUARTER BLOCK}'), 'line') else: self.hline = urwid.AttrWrap(urwid.SolidFill(u' '), 'line') for graph in self.graphs.values(): graph.set_smooth_colors(state) self.show_graphs()
python
def on_unicode_checkbox(self, w=None, state=False): """Enable smooth edges if utf-8 is supported""" logging.debug("unicode State is %s", state) # Update the controller to the state of the checkbox self.controller.smooth_graph_mode = state if state: self.hline = urwid.AttrWrap( urwid.SolidFill(u'\N{LOWER ONE QUARTER BLOCK}'), 'line') else: self.hline = urwid.AttrWrap(urwid.SolidFill(u' '), 'line') for graph in self.graphs.values(): graph.set_smooth_colors(state) self.show_graphs()
[ "def", "on_unicode_checkbox", "(", "self", ",", "w", "=", "None", ",", "state", "=", "False", ")", ":", "logging", ".", "debug", "(", "\"unicode State is %s\"", ",", "state", ")", "# Update the controller to the state of the checkbox", "self", ".", "controller", ".", "smooth_graph_mode", "=", "state", "if", "state", ":", "self", ".", "hline", "=", "urwid", ".", "AttrWrap", "(", "urwid", ".", "SolidFill", "(", "u'\\N{LOWER ONE QUARTER BLOCK}'", ")", ",", "'line'", ")", "else", ":", "self", ".", "hline", "=", "urwid", ".", "AttrWrap", "(", "urwid", ".", "SolidFill", "(", "u' '", ")", ",", "'line'", ")", "for", "graph", "in", "self", ".", "graphs", ".", "values", "(", ")", ":", "graph", ".", "set_smooth_colors", "(", "state", ")", "self", ".", "show_graphs", "(", ")" ]
Enable smooth edges if utf-8 is supported
[ "Enable", "smooth", "edges", "if", "utf", "-", "8", "is", "supported" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L362-L377
231,597
amanusk/s-tui
s_tui/s_tui.py
GraphView._generate_graph_controls
def _generate_graph_controls(self): """ Display sidebar controls. i.e. buttons, and controls""" # setup mode radio buttons stress_modes = self.controller.stress_conroller.get_modes() group = [] for mode in stress_modes: self.mode_buttons.append(radio_button(group, mode, self.on_mode_button)) # Set default radio button to "Monitor" mode self.mode_buttons[0].set_state(True, do_callback=False) # Create list of buttons control_options = list() control_options.append(button('Graphs', self.on_graphs_menu_open)) control_options.append(button('Summaries', self.on_summary_menu_open)) if self.controller.stress_exe: control_options.append(button('Stress Options', self.on_stress_menu_open)) control_options.append(button("Reset", self.on_reset_button)) control_options.append(button('Help', self.on_help_menu_open)) control_options.append(button('About', self.on_about_menu_open)) control_options.append(button("Save Settings", self.on_save_settings)) control_options.append(button("Quit", self.on_exit_program)) # Create the menu animate_controls = urwid.GridFlow(control_options, 18, 2, 0, 'center') # Create smooth graph selection button default_smooth = self.controller.smooth_graph_mode if urwid.get_encoding_mode() == "utf8": unicode_checkbox = urwid.CheckBox( "UTF-8", state=default_smooth, on_state_change=self.on_unicode_checkbox) # Init the state of the graph accoding to the selected mode self.on_unicode_checkbox(state=default_smooth) else: unicode_checkbox = urwid.Text( "[N/A] UTF-8") install_stress_message = urwid.Text("") if not self.controller.stress_exe: install_stress_message = urwid.Text( ('button normal', u"(N/A) install stress")) controls = [urwid.Text(('bold text', u"Modes"), align="center")] controls += self.mode_buttons controls += [ install_stress_message, urwid.Text(('bold text', u"Stress Timer"), align="center"), self.clock_view, urwid.Divider(), urwid.Text(('bold text', u"Control Options"), align="center"), animate_controls, urwid.Divider(), urwid.Text(('bold text', u"Visual Options"), align="center"), unicode_checkbox, self.refresh_rate_ctrl, urwid.Divider(), urwid.Text(('bold text', u"Summaries"), align="center"), ] return controls
python
def _generate_graph_controls(self): """ Display sidebar controls. i.e. buttons, and controls""" # setup mode radio buttons stress_modes = self.controller.stress_conroller.get_modes() group = [] for mode in stress_modes: self.mode_buttons.append(radio_button(group, mode, self.on_mode_button)) # Set default radio button to "Monitor" mode self.mode_buttons[0].set_state(True, do_callback=False) # Create list of buttons control_options = list() control_options.append(button('Graphs', self.on_graphs_menu_open)) control_options.append(button('Summaries', self.on_summary_menu_open)) if self.controller.stress_exe: control_options.append(button('Stress Options', self.on_stress_menu_open)) control_options.append(button("Reset", self.on_reset_button)) control_options.append(button('Help', self.on_help_menu_open)) control_options.append(button('About', self.on_about_menu_open)) control_options.append(button("Save Settings", self.on_save_settings)) control_options.append(button("Quit", self.on_exit_program)) # Create the menu animate_controls = urwid.GridFlow(control_options, 18, 2, 0, 'center') # Create smooth graph selection button default_smooth = self.controller.smooth_graph_mode if urwid.get_encoding_mode() == "utf8": unicode_checkbox = urwid.CheckBox( "UTF-8", state=default_smooth, on_state_change=self.on_unicode_checkbox) # Init the state of the graph accoding to the selected mode self.on_unicode_checkbox(state=default_smooth) else: unicode_checkbox = urwid.Text( "[N/A] UTF-8") install_stress_message = urwid.Text("") if not self.controller.stress_exe: install_stress_message = urwid.Text( ('button normal', u"(N/A) install stress")) controls = [urwid.Text(('bold text', u"Modes"), align="center")] controls += self.mode_buttons controls += [ install_stress_message, urwid.Text(('bold text', u"Stress Timer"), align="center"), self.clock_view, urwid.Divider(), urwid.Text(('bold text', u"Control Options"), align="center"), animate_controls, urwid.Divider(), urwid.Text(('bold text', u"Visual Options"), align="center"), unicode_checkbox, self.refresh_rate_ctrl, urwid.Divider(), urwid.Text(('bold text', u"Summaries"), align="center"), ] return controls
[ "def", "_generate_graph_controls", "(", "self", ")", ":", "# setup mode radio buttons", "stress_modes", "=", "self", ".", "controller", ".", "stress_conroller", ".", "get_modes", "(", ")", "group", "=", "[", "]", "for", "mode", "in", "stress_modes", ":", "self", ".", "mode_buttons", ".", "append", "(", "radio_button", "(", "group", ",", "mode", ",", "self", ".", "on_mode_button", ")", ")", "# Set default radio button to \"Monitor\" mode", "self", ".", "mode_buttons", "[", "0", "]", ".", "set_state", "(", "True", ",", "do_callback", "=", "False", ")", "# Create list of buttons", "control_options", "=", "list", "(", ")", "control_options", ".", "append", "(", "button", "(", "'Graphs'", ",", "self", ".", "on_graphs_menu_open", ")", ")", "control_options", ".", "append", "(", "button", "(", "'Summaries'", ",", "self", ".", "on_summary_menu_open", ")", ")", "if", "self", ".", "controller", ".", "stress_exe", ":", "control_options", ".", "append", "(", "button", "(", "'Stress Options'", ",", "self", ".", "on_stress_menu_open", ")", ")", "control_options", ".", "append", "(", "button", "(", "\"Reset\"", ",", "self", ".", "on_reset_button", ")", ")", "control_options", ".", "append", "(", "button", "(", "'Help'", ",", "self", ".", "on_help_menu_open", ")", ")", "control_options", ".", "append", "(", "button", "(", "'About'", ",", "self", ".", "on_about_menu_open", ")", ")", "control_options", ".", "append", "(", "button", "(", "\"Save Settings\"", ",", "self", ".", "on_save_settings", ")", ")", "control_options", ".", "append", "(", "button", "(", "\"Quit\"", ",", "self", ".", "on_exit_program", ")", ")", "# Create the menu", "animate_controls", "=", "urwid", ".", "GridFlow", "(", "control_options", ",", "18", ",", "2", ",", "0", ",", "'center'", ")", "# Create smooth graph selection button", "default_smooth", "=", "self", ".", "controller", ".", "smooth_graph_mode", "if", "urwid", ".", "get_encoding_mode", "(", ")", "==", "\"utf8\"", ":", "unicode_checkbox", "=", "urwid", ".", "CheckBox", "(", "\"UTF-8\"", ",", "state", "=", "default_smooth", ",", "on_state_change", "=", "self", ".", "on_unicode_checkbox", ")", "# Init the state of the graph accoding to the selected mode", "self", ".", "on_unicode_checkbox", "(", "state", "=", "default_smooth", ")", "else", ":", "unicode_checkbox", "=", "urwid", ".", "Text", "(", "\"[N/A] UTF-8\"", ")", "install_stress_message", "=", "urwid", ".", "Text", "(", "\"\"", ")", "if", "not", "self", ".", "controller", ".", "stress_exe", ":", "install_stress_message", "=", "urwid", ".", "Text", "(", "(", "'button normal'", ",", "u\"(N/A) install stress\"", ")", ")", "controls", "=", "[", "urwid", ".", "Text", "(", "(", "'bold text'", ",", "u\"Modes\"", ")", ",", "align", "=", "\"center\"", ")", "]", "controls", "+=", "self", ".", "mode_buttons", "controls", "+=", "[", "install_stress_message", ",", "urwid", ".", "Text", "(", "(", "'bold text'", ",", "u\"Stress Timer\"", ")", ",", "align", "=", "\"center\"", ")", ",", "self", ".", "clock_view", ",", "urwid", ".", "Divider", "(", ")", ",", "urwid", ".", "Text", "(", "(", "'bold text'", ",", "u\"Control Options\"", ")", ",", "align", "=", "\"center\"", ")", ",", "animate_controls", ",", "urwid", ".", "Divider", "(", ")", ",", "urwid", ".", "Text", "(", "(", "'bold text'", ",", "u\"Visual Options\"", ")", ",", "align", "=", "\"center\"", ")", ",", "unicode_checkbox", ",", "self", ".", "refresh_rate_ctrl", ",", "urwid", ".", "Divider", "(", ")", ",", "urwid", ".", "Text", "(", "(", "'bold text'", ",", "u\"Summaries\"", ")", ",", "align", "=", "\"center\"", ")", ",", "]", "return", "controls" ]
Display sidebar controls. i.e. buttons, and controls
[ "Display", "sidebar", "controls", ".", "i", ".", "e", ".", "buttons", "and", "controls" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L387-L452
231,598
amanusk/s-tui
s_tui/s_tui.py
GraphView._generate_cpu_stats
def _generate_cpu_stats(): """Read and display processor name """ cpu_name = urwid.Text("CPU Name N/A", align="center") try: cpu_name = urwid.Text(get_processor_name().strip(), align="center") except OSError: logging.info("CPU name not available") return [urwid.Text(('bold text', "CPU Detected"), align="center"), cpu_name, urwid.Divider()]
python
def _generate_cpu_stats(): """Read and display processor name """ cpu_name = urwid.Text("CPU Name N/A", align="center") try: cpu_name = urwid.Text(get_processor_name().strip(), align="center") except OSError: logging.info("CPU name not available") return [urwid.Text(('bold text', "CPU Detected"), align="center"), cpu_name, urwid.Divider()]
[ "def", "_generate_cpu_stats", "(", ")", ":", "cpu_name", "=", "urwid", ".", "Text", "(", "\"CPU Name N/A\"", ",", "align", "=", "\"center\"", ")", "try", ":", "cpu_name", "=", "urwid", ".", "Text", "(", "get_processor_name", "(", ")", ".", "strip", "(", ")", ",", "align", "=", "\"center\"", ")", "except", "OSError", ":", "logging", ".", "info", "(", "\"CPU name not available\"", ")", "return", "[", "urwid", ".", "Text", "(", "(", "'bold text'", ",", "\"CPU Detected\"", ")", ",", "align", "=", "\"center\"", ")", ",", "cpu_name", ",", "urwid", ".", "Divider", "(", ")", "]" ]
Read and display processor name
[ "Read", "and", "display", "processor", "name" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L455-L463
231,599
amanusk/s-tui
s_tui/s_tui.py
GraphView.show_graphs
def show_graphs(self): """Show a pile of the graph selected for dislpay""" elements = itertools.chain.from_iterable( ([graph] for graph in self.visible_graphs.values())) self.graph_place_holder.original_widget = urwid.Pile(elements)
python
def show_graphs(self): """Show a pile of the graph selected for dislpay""" elements = itertools.chain.from_iterable( ([graph] for graph in self.visible_graphs.values())) self.graph_place_holder.original_widget = urwid.Pile(elements)
[ "def", "show_graphs", "(", "self", ")", ":", "elements", "=", "itertools", ".", "chain", ".", "from_iterable", "(", "(", "[", "graph", "]", "for", "graph", "in", "self", ".", "visible_graphs", ".", "values", "(", ")", ")", ")", "self", ".", "graph_place_holder", ".", "original_widget", "=", "urwid", ".", "Pile", "(", "elements", ")" ]
Show a pile of the graph selected for dislpay
[ "Show", "a", "pile", "of", "the", "graph", "selected", "for", "dislpay" ]
5e89d15081e716024db28ec03b1e3a7710330951
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L475-L480