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
226,800
MagicStack/asyncpg
asyncpg/cluster.py
Cluster.add_hba_entry
def add_hba_entry(self, *, type='host', database, user, address=None, auth_method, auth_options=None): """Add a record to pg_hba.conf.""" status = self.get_status() if status == 'not-initialized': raise ClusterError( 'cannot modify HBA records: c...
python
def add_hba_entry(self, *, type='host', database, user, address=None, auth_method, auth_options=None): """Add a record to pg_hba.conf.""" status = self.get_status() if status == 'not-initialized': raise ClusterError( 'cannot modify HBA records: c...
[ "def", "add_hba_entry", "(", "self", ",", "*", ",", "type", "=", "'host'", ",", "database", ",", "user", ",", "address", "=", "None", ",", "auth_method", ",", "auth_options", "=", "None", ")", ":", "status", "=", "self", ".", "get_status", "(", ")", ...
Add a record to pg_hba.conf.
[ "Add", "a", "record", "to", "pg_hba", ".", "conf", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/cluster.py#L339-L372
226,801
MagicStack/asyncpg
asyncpg/connection.py
connect
async def connect(dsn=None, *, host=None, port=None, user=None, password=None, passfile=None, database=None, loop=None, timeout=60, statement_cache_size=100, max_cached_statement_lifetime=300, ...
python
async def connect(dsn=None, *, host=None, port=None, user=None, password=None, passfile=None, database=None, loop=None, timeout=60, statement_cache_size=100, max_cached_statement_lifetime=300, ...
[ "async", "def", "connect", "(", "dsn", "=", "None", ",", "*", ",", "host", "=", "None", ",", "port", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "passfile", "=", "None", ",", "database", "=", "None", ",", "loop", "="...
r"""A coroutine to establish a connection to a PostgreSQL server. The connection parameters may be specified either as a connection URI in *dsn*, or as specific keyword arguments, or both. If both *dsn* and keyword arguments are specified, the latter override the corresponding values parsed from the co...
[ "r", "A", "coroutine", "to", "establish", "a", "connection", "to", "a", "PostgreSQL", "server", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L1494-L1688
226,802
MagicStack/asyncpg
asyncpg/connection.py
Connection.add_listener
async def add_listener(self, channel, callback): """Add a listener for Postgres notifications. :param str channel: Channel to listen on. :param callable callback: A callable receiving the following arguments: **connection**: a Connection the callback is registered with;...
python
async def add_listener(self, channel, callback): """Add a listener for Postgres notifications. :param str channel: Channel to listen on. :param callable callback: A callable receiving the following arguments: **connection**: a Connection the callback is registered with;...
[ "async", "def", "add_listener", "(", "self", ",", "channel", ",", "callback", ")", ":", "self", ".", "_check_open", "(", ")", "if", "channel", "not", "in", "self", ".", "_listeners", ":", "await", "self", ".", "fetch", "(", "'LISTEN {}'", ".", "format", ...
Add a listener for Postgres notifications. :param str channel: Channel to listen on. :param callable callback: A callable receiving the following arguments: **connection**: a Connection the callback is registered with; **pid**: PID of the Postgres server that sent t...
[ "Add", "a", "listener", "for", "Postgres", "notifications", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L126-L142
226,803
MagicStack/asyncpg
asyncpg/connection.py
Connection.remove_listener
async def remove_listener(self, channel, callback): """Remove a listening callback on the specified channel.""" if self.is_closed(): return if channel not in self._listeners: return if callback not in self._listeners[channel]: return self._list...
python
async def remove_listener(self, channel, callback): """Remove a listening callback on the specified channel.""" if self.is_closed(): return if channel not in self._listeners: return if callback not in self._listeners[channel]: return self._list...
[ "async", "def", "remove_listener", "(", "self", ",", "channel", ",", "callback", ")", ":", "if", "self", ".", "is_closed", "(", ")", ":", "return", "if", "channel", "not", "in", "self", ".", "_listeners", ":", "return", "if", "callback", "not", "in", "...
Remove a listening callback on the specified channel.
[ "Remove", "a", "listening", "callback", "on", "the", "specified", "channel", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L144-L155
226,804
MagicStack/asyncpg
asyncpg/connection.py
Connection.add_log_listener
def add_log_listener(self, callback): """Add a listener for Postgres log messages. It will be called when asyncronous NoticeResponse is received from the connection. Possible message types are: WARNING, NOTICE, DEBUG, INFO, or LOG. :param callable callback: A calla...
python
def add_log_listener(self, callback): """Add a listener for Postgres log messages. It will be called when asyncronous NoticeResponse is received from the connection. Possible message types are: WARNING, NOTICE, DEBUG, INFO, or LOG. :param callable callback: A calla...
[ "def", "add_log_listener", "(", "self", ",", "callback", ")", ":", "if", "self", ".", "is_closed", "(", ")", ":", "raise", "exceptions", ".", "InterfaceError", "(", "'connection is closed'", ")", "self", ".", "_log_listeners", ".", "add", "(", "callback", ")...
Add a listener for Postgres log messages. It will be called when asyncronous NoticeResponse is received from the connection. Possible message types are: WARNING, NOTICE, DEBUG, INFO, or LOG. :param callable callback: A callable receiving the following arguments: ...
[ "Add", "a", "listener", "for", "Postgres", "log", "messages", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L157-L173
226,805
MagicStack/asyncpg
asyncpg/connection.py
Connection.copy_from_table
async def copy_from_table(self, table_name, *, output, columns=None, schema_name=None, timeout=None, format=None, oids=None, delimiter=None, null=None, header=None, quote=None, escape=None, force_quot...
python
async def copy_from_table(self, table_name, *, output, columns=None, schema_name=None, timeout=None, format=None, oids=None, delimiter=None, null=None, header=None, quote=None, escape=None, force_quot...
[ "async", "def", "copy_from_table", "(", "self", ",", "table_name", ",", "*", ",", "output", ",", "columns", "=", "None", ",", "schema_name", "=", "None", ",", "timeout", "=", "None", ",", "format", "=", "None", ",", "oids", "=", "None", ",", "delimiter...
Copy table contents to a file or file-like object. :param str table_name: The name of the table to copy data from. :param output: A :term:`path-like object <python:path-like object>`, or a :term:`file-like object <python:file-like object>`, or a :term:`c...
[ "Copy", "table", "contents", "to", "a", "file", "or", "file", "-", "like", "object", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L460-L530
226,806
MagicStack/asyncpg
asyncpg/connection.py
Connection.copy_from_query
async def copy_from_query(self, query, *args, output, timeout=None, format=None, oids=None, delimiter=None, null=None, header=None, quote=None, escape=None, force_quote=None, encoding=None): "...
python
async def copy_from_query(self, query, *args, output, timeout=None, format=None, oids=None, delimiter=None, null=None, header=None, quote=None, escape=None, force_quote=None, encoding=None): "...
[ "async", "def", "copy_from_query", "(", "self", ",", "query", ",", "*", "args", ",", "output", ",", "timeout", "=", "None", ",", "format", "=", "None", ",", "oids", "=", "None", ",", "delimiter", "=", "None", ",", "null", "=", "None", ",", "header", ...
Copy the results of a query to a file or file-like object. :param str query: The query to copy the results of. :param args: Query arguments. :param output: A :term:`path-like object <python:path-like object>`, or a :term:`file-like object <pytho...
[ "Copy", "the", "results", "of", "a", "query", "to", "a", "file", "or", "file", "-", "like", "object", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L532-L592
226,807
MagicStack/asyncpg
asyncpg/connection.py
Connection.copy_to_table
async def copy_to_table(self, table_name, *, source, columns=None, schema_name=None, timeout=None, format=None, oids=None, freeze=None, delimiter=None, null=None, header=None, quote=None, escape=None, force_q...
python
async def copy_to_table(self, table_name, *, source, columns=None, schema_name=None, timeout=None, format=None, oids=None, freeze=None, delimiter=None, null=None, header=None, quote=None, escape=None, force_q...
[ "async", "def", "copy_to_table", "(", "self", ",", "table_name", ",", "*", ",", "source", ",", "columns", "=", "None", ",", "schema_name", "=", "None", ",", "timeout", "=", "None", ",", "format", "=", "None", ",", "oids", "=", "None", ",", "freeze", ...
Copy data to the specified table. :param str table_name: The name of the table to copy data to. :param source: A :term:`path-like object <python:path-like object>`, or a :term:`file-like object <python:file-like object>`, or an :term:`asynchronous iterab...
[ "Copy", "data", "to", "the", "specified", "table", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L594-L667
226,808
MagicStack/asyncpg
asyncpg/connection.py
Connection.copy_records_to_table
async def copy_records_to_table(self, table_name, *, records, columns=None, schema_name=None, timeout=None): """Copy a list of records to the specified table using binary COPY. :param str table_name: The name of the tab...
python
async def copy_records_to_table(self, table_name, *, records, columns=None, schema_name=None, timeout=None): """Copy a list of records to the specified table using binary COPY. :param str table_name: The name of the tab...
[ "async", "def", "copy_records_to_table", "(", "self", ",", "table_name", ",", "*", ",", "records", ",", "columns", "=", "None", ",", "schema_name", "=", "None", ",", "timeout", "=", "None", ")", ":", "tabname", "=", "utils", ".", "_quote_ident", "(", "ta...
Copy a list of records to the specified table using binary COPY. :param str table_name: The name of the table to copy data to. :param records: An iterable returning row tuples to copy into the table. :param list columns: An optional list of column names to ...
[ "Copy", "a", "list", "of", "records", "to", "the", "specified", "table", "using", "binary", "COPY", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L669-L732
226,809
MagicStack/asyncpg
asyncpg/connection.py
Connection.set_builtin_type_codec
async def set_builtin_type_codec(self, typename, *, schema='public', codec_name, format=None): """Set a builtin codec for the specified scalar data type. This method has two uses. The first is to register a builtin codec...
python
async def set_builtin_type_codec(self, typename, *, schema='public', codec_name, format=None): """Set a builtin codec for the specified scalar data type. This method has two uses. The first is to register a builtin codec...
[ "async", "def", "set_builtin_type_codec", "(", "self", ",", "typename", ",", "*", ",", "schema", "=", "'public'", ",", "codec_name", ",", "format", "=", "None", ")", ":", "self", ".", "_check_open", "(", ")", "typeinfo", "=", "await", "self", ".", "fetch...
Set a builtin codec for the specified scalar data type. This method has two uses. The first is to register a builtin codec for an extension type without a stable OID, such as 'hstore'. The second use is to declare that an extension type or a user-defined type is wire-compatible with a ...
[ "Set", "a", "builtin", "codec", "for", "the", "specified", "scalar", "data", "type", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L1007-L1061
226,810
MagicStack/asyncpg
asyncpg/connection.py
Connection.close
async def close(self, *, timeout=None): """Close the connection gracefully. :param float timeout: Optional timeout value in seconds. .. versionchanged:: 0.14.0 Added the *timeout* parameter. """ try: if not self.is_closed(): aw...
python
async def close(self, *, timeout=None): """Close the connection gracefully. :param float timeout: Optional timeout value in seconds. .. versionchanged:: 0.14.0 Added the *timeout* parameter. """ try: if not self.is_closed(): aw...
[ "async", "def", "close", "(", "self", ",", "*", ",", "timeout", "=", "None", ")", ":", "try", ":", "if", "not", "self", ".", "is_closed", "(", ")", ":", "await", "self", ".", "_protocol", ".", "close", "(", "timeout", ")", "except", "Exception", ":...
Close the connection gracefully. :param float timeout: Optional timeout value in seconds. .. versionchanged:: 0.14.0 Added the *timeout* parameter.
[ "Close", "the", "connection", "gracefully", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L1071-L1088
226,811
MagicStack/asyncpg
asyncpg/pool.py
create_pool
def create_pool(dsn=None, *, min_size=10, max_size=10, max_queries=50000, max_inactive_connection_lifetime=300.0, setup=None, init=None, loop=None, connection_class=connection.Connection, ...
python
def create_pool(dsn=None, *, min_size=10, max_size=10, max_queries=50000, max_inactive_connection_lifetime=300.0, setup=None, init=None, loop=None, connection_class=connection.Connection, ...
[ "def", "create_pool", "(", "dsn", "=", "None", ",", "*", ",", "min_size", "=", "10", ",", "max_size", "=", "10", ",", "max_queries", "=", "50000", ",", "max_inactive_connection_lifetime", "=", "300.0", ",", "setup", "=", "None", ",", "init", "=", "None",...
r"""Create a connection pool. Can be used either with an ``async with`` block: .. code-block:: python async with asyncpg.create_pool(user='postgres', command_timeout=60) as pool: async with pool.acquire() as con: await con.fetch('SELE...
[ "r", "Create", "a", "connection", "pool", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/pool.py#L778-L889
226,812
MagicStack/asyncpg
asyncpg/pool.py
PoolConnectionHolder._release
def _release(self): """Release this connection holder.""" if self._in_use is None: # The holder is not checked out. return if not self._in_use.done(): self._in_use.set_result(None) self._in_use = None # Deinitialize the connection proxy. All...
python
def _release(self): """Release this connection holder.""" if self._in_use is None: # The holder is not checked out. return if not self._in_use.done(): self._in_use.set_result(None) self._in_use = None # Deinitialize the connection proxy. All...
[ "def", "_release", "(", "self", ")", ":", "if", "self", ".", "_in_use", "is", "None", ":", "# The holder is not checked out.", "return", "if", "not", "self", ".", "_in_use", ".", "done", "(", ")", ":", "self", ".", "_in_use", ".", "set_result", "(", "Non...
Release this connection holder.
[ "Release", "this", "connection", "holder", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/pool.py#L276-L293
226,813
MagicStack/asyncpg
asyncpg/pool.py
Pool.set_connect_args
def set_connect_args(self, dsn=None, **connect_kwargs): r"""Set the new connection arguments for this pool. The new connection arguments will be used for all subsequent new connection attempts. Existing connections will remain until they expire. Use :meth:`Pool.expire_connections() ...
python
def set_connect_args(self, dsn=None, **connect_kwargs): r"""Set the new connection arguments for this pool. The new connection arguments will be used for all subsequent new connection attempts. Existing connections will remain until they expire. Use :meth:`Pool.expire_connections() ...
[ "def", "set_connect_args", "(", "self", ",", "dsn", "=", "None", ",", "*", "*", "connect_kwargs", ")", ":", "self", ".", "_connect_args", "=", "[", "dsn", "]", "self", ".", "_connect_kwargs", "=", "connect_kwargs", "self", ".", "_working_addr", "=", "None"...
r"""Set the new connection arguments for this pool. The new connection arguments will be used for all subsequent new connection attempts. Existing connections will remain until they expire. Use :meth:`Pool.expire_connections() <asyncpg.pool.Pool.expire_connections>` to expedite the con...
[ "r", "Set", "the", "new", "connection", "arguments", "for", "this", "pool", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/pool.py#L429-L454
226,814
MagicStack/asyncpg
asyncpg/pool.py
Pool.release
async def release(self, connection, *, timeout=None): """Release a database connection back to the pool. :param Connection connection: A :class:`~asyncpg.connection.Connection` object to release. :param float timeout: A timeout for releasing the connection. If not speci...
python
async def release(self, connection, *, timeout=None): """Release a database connection back to the pool. :param Connection connection: A :class:`~asyncpg.connection.Connection` object to release. :param float timeout: A timeout for releasing the connection. If not speci...
[ "async", "def", "release", "(", "self", ",", "connection", ",", "*", ",", "timeout", "=", "None", ")", ":", "if", "(", "type", "(", "connection", ")", "is", "not", "PoolConnectionProxy", "or", "connection", ".", "_holder", ".", "_pool", "is", "not", "s...
Release a database connection back to the pool. :param Connection connection: A :class:`~asyncpg.connection.Connection` object to release. :param float timeout: A timeout for releasing the connection. If not specified, defaults to the timeout provided in the corresp...
[ "Release", "a", "database", "connection", "back", "to", "the", "pool", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/pool.py#L609-L645
226,815
MagicStack/asyncpg
asyncpg/pool.py
Pool.close
async def close(self): """Attempt to gracefully close all connections in the pool. Wait until all pool connections are released, close them and shut down the pool. If any error (including cancellation) occurs in ``close()`` the pool will terminate by calling :meth:`Pool.termina...
python
async def close(self): """Attempt to gracefully close all connections in the pool. Wait until all pool connections are released, close them and shut down the pool. If any error (including cancellation) occurs in ``close()`` the pool will terminate by calling :meth:`Pool.termina...
[ "async", "def", "close", "(", "self", ")", ":", "if", "self", ".", "_closed", ":", "return", "self", ".", "_check_init", "(", ")", "self", ".", "_closing", "=", "True", "warning_callback", "=", "None", "try", ":", "warning_callback", "=", "self", ".", ...
Attempt to gracefully close all connections in the pool. Wait until all pool connections are released, close them and shut down the pool. If any error (including cancellation) occurs in ``close()`` the pool will terminate by calling :meth:`Pool.terminate() <pool.Pool.terminate>`. ...
[ "Attempt", "to", "gracefully", "close", "all", "connections", "in", "the", "pool", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/pool.py#L647-L690
226,816
MagicStack/asyncpg
asyncpg/pool.py
Pool.terminate
def terminate(self): """Terminate all connections in the pool.""" if self._closed: return self._check_init() for ch in self._holders: ch.terminate() self._closed = True
python
def terminate(self): """Terminate all connections in the pool.""" if self._closed: return self._check_init() for ch in self._holders: ch.terminate() self._closed = True
[ "def", "terminate", "(", "self", ")", ":", "if", "self", ".", "_closed", ":", "return", "self", ".", "_check_init", "(", ")", "for", "ch", "in", "self", ".", "_holders", ":", "ch", ".", "terminate", "(", ")", "self", ".", "_closed", "=", "True" ]
Terminate all connections in the pool.
[ "Terminate", "all", "connections", "in", "the", "pool", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/pool.py#L698-L705
226,817
MagicStack/asyncpg
asyncpg/transaction.py
Transaction.start
async def start(self): """Enter the transaction or savepoint block.""" self.__check_state_base('start') if self._state is TransactionState.STARTED: raise apg_errors.InterfaceError( 'cannot start; the transaction is already started') con = self._connection ...
python
async def start(self): """Enter the transaction or savepoint block.""" self.__check_state_base('start') if self._state is TransactionState.STARTED: raise apg_errors.InterfaceError( 'cannot start; the transaction is already started') con = self._connection ...
[ "async", "def", "start", "(", "self", ")", ":", "self", ".", "__check_state_base", "(", "'start'", ")", "if", "self", ".", "_state", "is", "TransactionState", ".", "STARTED", ":", "raise", "apg_errors", ".", "InterfaceError", "(", "'cannot start; the transaction...
Enter the transaction or savepoint block.
[ "Enter", "the", "transaction", "or", "savepoint", "block", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/transaction.py#L96-L143
226,818
MagicStack/asyncpg
asyncpg/prepared_stmt.py
PreparedStatement.get_statusmsg
def get_statusmsg(self) -> str: """Return the status of the executed command. Example:: stmt = await connection.prepare('CREATE TABLE mytab (a int)') await stmt.fetch() assert stmt.get_statusmsg() == "CREATE TABLE" """ if self._last_status is None: ...
python
def get_statusmsg(self) -> str: """Return the status of the executed command. Example:: stmt = await connection.prepare('CREATE TABLE mytab (a int)') await stmt.fetch() assert stmt.get_statusmsg() == "CREATE TABLE" """ if self._last_status is None: ...
[ "def", "get_statusmsg", "(", "self", ")", "->", "str", ":", "if", "self", ".", "_last_status", "is", "None", ":", "return", "self", ".", "_last_status", "return", "self", ".", "_last_status", ".", "decode", "(", ")" ]
Return the status of the executed command. Example:: stmt = await connection.prepare('CREATE TABLE mytab (a int)') await stmt.fetch() assert stmt.get_statusmsg() == "CREATE TABLE"
[ "Return", "the", "status", "of", "the", "executed", "command", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/prepared_stmt.py#L39-L50
226,819
MagicStack/asyncpg
asyncpg/prepared_stmt.py
PreparedStatement.explain
async def explain(self, *args, analyze=False): """Return the execution plan of the statement. :param args: Query arguments. :param analyze: If ``True``, the statement will be executed and the run time statitics added to the return value. :return: An object repre...
python
async def explain(self, *args, analyze=False): """Return the execution plan of the statement. :param args: Query arguments. :param analyze: If ``True``, the statement will be executed and the run time statitics added to the return value. :return: An object repre...
[ "async", "def", "explain", "(", "self", ",", "*", "args", ",", "analyze", "=", "False", ")", ":", "query", "=", "'EXPLAIN (FORMAT JSON, VERBOSE'", "if", "analyze", ":", "query", "+=", "', ANALYZE) '", "else", ":", "query", "+=", "') '", "query", "+=", "sel...
Return the execution plan of the statement. :param args: Query arguments. :param analyze: If ``True``, the statement will be executed and the run time statitics added to the return value. :return: An object representing the execution plan. This value i...
[ "Return", "the", "execution", "plan", "of", "the", "statement", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/prepared_stmt.py#L111-L150
226,820
MagicStack/asyncpg
asyncpg/prepared_stmt.py
PreparedStatement.fetchval
async def fetchval(self, *args, column=0, timeout=None): """Execute the statement and return a value in the first row. :param args: Query arguments. :param int column: Numeric index within the record of the value to return (defaults to 0). :param float timeout...
python
async def fetchval(self, *args, column=0, timeout=None): """Execute the statement and return a value in the first row. :param args: Query arguments. :param int column: Numeric index within the record of the value to return (defaults to 0). :param float timeout...
[ "async", "def", "fetchval", "(", "self", ",", "*", "args", ",", "column", "=", "0", ",", "timeout", "=", "None", ")", ":", "data", "=", "await", "self", ".", "__bind_execute", "(", "args", ",", "1", ",", "timeout", ")", "if", "not", "data", ":", ...
Execute the statement and return a value in the first row. :param args: Query arguments. :param int column: Numeric index within the record of the value to return (defaults to 0). :param float timeout: Optional timeout value in seconds. If ...
[ "Execute", "the", "statement", "and", "return", "a", "value", "in", "the", "first", "row", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/prepared_stmt.py#L166-L182
226,821
MagicStack/asyncpg
asyncpg/prepared_stmt.py
PreparedStatement.fetchrow
async def fetchrow(self, *args, timeout=None): """Execute the statement and return the first row. :param str query: Query text :param args: Query arguments :param float timeout: Optional timeout value in seconds. :return: The first row as a :class:`Record` instance. """...
python
async def fetchrow(self, *args, timeout=None): """Execute the statement and return the first row. :param str query: Query text :param args: Query arguments :param float timeout: Optional timeout value in seconds. :return: The first row as a :class:`Record` instance. """...
[ "async", "def", "fetchrow", "(", "self", ",", "*", "args", ",", "timeout", "=", "None", ")", ":", "data", "=", "await", "self", ".", "__bind_execute", "(", "args", ",", "1", ",", "timeout", ")", "if", "not", "data", ":", "return", "None", "return", ...
Execute the statement and return the first row. :param str query: Query text :param args: Query arguments :param float timeout: Optional timeout value in seconds. :return: The first row as a :class:`Record` instance.
[ "Execute", "the", "statement", "and", "return", "the", "first", "row", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/prepared_stmt.py#L185-L197
226,822
MagicStack/asyncpg
asyncpg/connect_utils.py
_read_password_from_pgpass
def _read_password_from_pgpass( *, passfile: typing.Optional[pathlib.Path], hosts: typing.List[str], ports: typing.List[int], database: str, user: str): """Parse the pgpass file and return the matching password. :return: Password string, if found, ``None`` otherw...
python
def _read_password_from_pgpass( *, passfile: typing.Optional[pathlib.Path], hosts: typing.List[str], ports: typing.List[int], database: str, user: str): """Parse the pgpass file and return the matching password. :return: Password string, if found, ``None`` otherw...
[ "def", "_read_password_from_pgpass", "(", "*", ",", "passfile", ":", "typing", ".", "Optional", "[", "pathlib", ".", "Path", "]", ",", "hosts", ":", "typing", ".", "List", "[", "str", "]", ",", "ports", ":", "typing", ".", "List", "[", "int", "]", ",...
Parse the pgpass file and return the matching password. :return: Password string, if found, ``None`` otherwise.
[ "Parse", "the", "pgpass", "file", "and", "return", "the", "matching", "password", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connect_utils.py#L105-L139
226,823
MagicStack/asyncpg
asyncpg/utils.py
_mogrify
async def _mogrify(conn, query, args): """Safely inline arguments to query text.""" # Introspect the target query for argument types and # build a list of safely-quoted fully-qualified type names. ps = await conn.prepare(query) paramtypes = [] for t in ps.get_parameters(): if t.name.ends...
python
async def _mogrify(conn, query, args): """Safely inline arguments to query text.""" # Introspect the target query for argument types and # build a list of safely-quoted fully-qualified type names. ps = await conn.prepare(query) paramtypes = [] for t in ps.get_parameters(): if t.name.ends...
[ "async", "def", "_mogrify", "(", "conn", ",", "query", ",", "args", ")", ":", "# Introspect the target query for argument types and", "# build a list of safely-quoted fully-qualified type names.", "ps", "=", "await", "conn", ".", "prepare", "(", "query", ")", "paramtypes"...
Safely inline arguments to query text.
[ "Safely", "inline", "arguments", "to", "query", "text", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/utils.py#L19-L45
226,824
jrfonseca/gprof2dot
gprof2dot.py
Event.aggregate
def aggregate(self, val1, val2): """Aggregate two event values.""" assert val1 is not None assert val2 is not None return self._aggregator(val1, val2)
python
def aggregate(self, val1, val2): """Aggregate two event values.""" assert val1 is not None assert val2 is not None return self._aggregator(val1, val2)
[ "def", "aggregate", "(", "self", ",", "val1", ",", "val2", ")", ":", "assert", "val1", "is", "not", "None", "assert", "val2", "is", "not", "None", "return", "self", ".", "_aggregator", "(", "val1", ",", "val2", ")" ]
Aggregate two event values.
[ "Aggregate", "two", "event", "values", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L121-L125
226,825
jrfonseca/gprof2dot
gprof2dot.py
Function.stripped_name
def stripped_name(self): """Remove extraneous information from C++ demangled function names.""" name = self.name # Strip function parameters from name by recursively removing paired parenthesis while True: name, n = self._parenthesis_re.subn('', name) if not n: ...
python
def stripped_name(self): """Remove extraneous information from C++ demangled function names.""" name = self.name # Strip function parameters from name by recursively removing paired parenthesis while True: name, n = self._parenthesis_re.subn('', name) if not n: ...
[ "def", "stripped_name", "(", "self", ")", ":", "name", "=", "self", ".", "name", "# Strip function parameters from name by recursively removing paired parenthesis", "while", "True", ":", "name", ",", "n", "=", "self", ".", "_parenthesis_re", ".", "subn", "(", "''", ...
Remove extraneous information from C++ demangled function names.
[ "Remove", "extraneous", "information", "from", "C", "++", "demangled", "function", "names", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L244-L264
226,826
jrfonseca/gprof2dot
gprof2dot.py
Profile.validate
def validate(self): """Validate the edges.""" for function in compat_itervalues(self.functions): for callee_id in compat_keys(function.calls): assert function.calls[callee_id].callee_id == callee_id if callee_id not in self.functions: sys....
python
def validate(self): """Validate the edges.""" for function in compat_itervalues(self.functions): for callee_id in compat_keys(function.calls): assert function.calls[callee_id].callee_id == callee_id if callee_id not in self.functions: sys....
[ "def", "validate", "(", "self", ")", ":", "for", "function", "in", "compat_itervalues", "(", "self", ".", "functions", ")", ":", "for", "callee_id", "in", "compat_keys", "(", "function", ".", "calls", ")", ":", "assert", "function", ".", "calls", "[", "c...
Validate the edges.
[ "Validate", "the", "edges", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L305-L313
226,827
jrfonseca/gprof2dot
gprof2dot.py
Profile.find_cycles
def find_cycles(self): """Find cycles using Tarjan's strongly connected components algorithm.""" # Apply the Tarjan's algorithm successively until all functions are visited stack = [] data = {} order = 0 for function in compat_itervalues(self.functions): orde...
python
def find_cycles(self): """Find cycles using Tarjan's strongly connected components algorithm.""" # Apply the Tarjan's algorithm successively until all functions are visited stack = [] data = {} order = 0 for function in compat_itervalues(self.functions): orde...
[ "def", "find_cycles", "(", "self", ")", ":", "# Apply the Tarjan's algorithm successively until all functions are visited", "stack", "=", "[", "]", "data", "=", "{", "}", "order", "=", "0", "for", "function", "in", "compat_itervalues", "(", "self", ".", "functions",...
Find cycles using Tarjan's strongly connected components algorithm.
[ "Find", "cycles", "using", "Tarjan", "s", "strongly", "connected", "components", "algorithm", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L315-L333
226,828
jrfonseca/gprof2dot
gprof2dot.py
Profile._tarjan
def _tarjan(self, function, order, stack, data): """Tarjan's strongly connected components algorithm. See also: - http://en.wikipedia.org/wiki/Tarjan's_strongly_connected_components_algorithm """ try: func_data = data[function.id] return order ex...
python
def _tarjan(self, function, order, stack, data): """Tarjan's strongly connected components algorithm. See also: - http://en.wikipedia.org/wiki/Tarjan's_strongly_connected_components_algorithm """ try: func_data = data[function.id] return order ex...
[ "def", "_tarjan", "(", "self", ",", "function", ",", "order", ",", "stack", ",", "data", ")", ":", "try", ":", "func_data", "=", "data", "[", "function", ".", "id", "]", "return", "order", "except", "KeyError", ":", "func_data", "=", "self", ".", "_T...
Tarjan's strongly connected components algorithm. See also: - http://en.wikipedia.org/wiki/Tarjan's_strongly_connected_components_algorithm
[ "Tarjan", "s", "strongly", "connected", "components", "algorithm", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L402-L441
226,829
jrfonseca/gprof2dot
gprof2dot.py
Profile.integrate
def integrate(self, outevent, inevent): """Propagate function time ratio along the function calls. Must be called after finding the cycles. See also: - http://citeseer.ist.psu.edu/graham82gprof.html """ # Sanity checking assert outevent not in self for ...
python
def integrate(self, outevent, inevent): """Propagate function time ratio along the function calls. Must be called after finding the cycles. See also: - http://citeseer.ist.psu.edu/graham82gprof.html """ # Sanity checking assert outevent not in self for ...
[ "def", "integrate", "(", "self", ",", "outevent", ",", "inevent", ")", ":", "# Sanity checking", "assert", "outevent", "not", "in", "self", "for", "function", "in", "compat_itervalues", "(", "self", ".", "functions", ")", ":", "assert", "outevent", "not", "i...
Propagate function time ratio along the function calls. Must be called after finding the cycles. See also: - http://citeseer.ist.psu.edu/graham82gprof.html
[ "Propagate", "function", "time", "ratio", "along", "the", "function", "calls", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L484-L515
226,830
jrfonseca/gprof2dot
gprof2dot.py
Profile._rank_cycle_function
def _rank_cycle_function(self, cycle, function, ranks): """Dijkstra's shortest paths algorithm. See also: - http://en.wikipedia.org/wiki/Dijkstra's_algorithm """ import heapq Q = [] Qd = {} p = {} visited = set([function]) ranks[function...
python
def _rank_cycle_function(self, cycle, function, ranks): """Dijkstra's shortest paths algorithm. See also: - http://en.wikipedia.org/wiki/Dijkstra's_algorithm """ import heapq Q = [] Qd = {} p = {} visited = set([function]) ranks[function...
[ "def", "_rank_cycle_function", "(", "self", ",", "cycle", ",", "function", ",", "ranks", ")", ":", "import", "heapq", "Q", "=", "[", "]", "Qd", "=", "{", "}", "p", "=", "{", "}", "visited", "=", "set", "(", "[", "function", "]", ")", "ranks", "["...
Dijkstra's shortest paths algorithm. See also: - http://en.wikipedia.org/wiki/Dijkstra's_algorithm
[ "Dijkstra", "s", "shortest", "paths", "algorithm", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L582-L629
226,831
jrfonseca/gprof2dot
gprof2dot.py
Profile.aggregate
def aggregate(self, event): """Aggregate an event for the whole profile.""" total = event.null() for function in compat_itervalues(self.functions): try: total = event.aggregate(total, function[event]) except UndefinedEvent: return ...
python
def aggregate(self, event): """Aggregate an event for the whole profile.""" total = event.null() for function in compat_itervalues(self.functions): try: total = event.aggregate(total, function[event]) except UndefinedEvent: return ...
[ "def", "aggregate", "(", "self", ",", "event", ")", ":", "total", "=", "event", ".", "null", "(", ")", "for", "function", "in", "compat_itervalues", "(", "self", ".", "functions", ")", ":", "try", ":", "total", "=", "event", ".", "aggregate", "(", "t...
Aggregate an event for the whole profile.
[ "Aggregate", "an", "event", "for", "the", "whole", "profile", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L668-L677
226,832
jrfonseca/gprof2dot
gprof2dot.py
Profile.prune
def prune(self, node_thres, edge_thres, paths, color_nodes_by_selftime): """Prune the profile""" # compute the prune ratios for function in compat_itervalues(self.functions): try: function.weight = function[TOTAL_TIME_RATIO] except UndefinedEvent: ...
python
def prune(self, node_thres, edge_thres, paths, color_nodes_by_selftime): """Prune the profile""" # compute the prune ratios for function in compat_itervalues(self.functions): try: function.weight = function[TOTAL_TIME_RATIO] except UndefinedEvent: ...
[ "def", "prune", "(", "self", ",", "node_thres", ",", "edge_thres", ",", "paths", ",", "color_nodes_by_selftime", ")", ":", "# compute the prune ratios", "for", "function", "in", "compat_itervalues", "(", "self", ".", "functions", ")", ":", "try", ":", "function"...
Prune the profile
[ "Prune", "the", "profile" ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L692-L751
226,833
jrfonseca/gprof2dot
gprof2dot.py
GprofParser.translate
def translate(self, mo): """Extract a structure from a match object, while translating the types in the process.""" attrs = {} groupdict = mo.groupdict() for name, value in compat_iteritems(groupdict): if value is None: value = None elif self._int_...
python
def translate(self, mo): """Extract a structure from a match object, while translating the types in the process.""" attrs = {} groupdict = mo.groupdict() for name, value in compat_iteritems(groupdict): if value is None: value = None elif self._int_...
[ "def", "translate", "(", "self", ",", "mo", ")", ":", "attrs", "=", "{", "}", "groupdict", "=", "mo", ".", "groupdict", "(", ")", "for", "name", ",", "value", "in", "compat_iteritems", "(", "groupdict", ")", ":", "if", "value", "is", "None", ":", "...
Extract a structure from a match object, while translating the types in the process.
[ "Extract", "a", "structure", "from", "a", "match", "object", "while", "translating", "the", "types", "in", "the", "process", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L1114-L1126
226,834
jrfonseca/gprof2dot
gprof2dot.py
AXEParser.parse_cg
def parse_cg(self): """Parse the call graph.""" # skip call graph header line = self.readline() while self._cg_header_re.match(line): line = self.readline() # process call graph entries entry_lines = [] # An EOF in readline terminates the program wit...
python
def parse_cg(self): """Parse the call graph.""" # skip call graph header line = self.readline() while self._cg_header_re.match(line): line = self.readline() # process call graph entries entry_lines = [] # An EOF in readline terminates the program wit...
[ "def", "parse_cg", "(", "self", ")", ":", "# skip call graph header", "line", "=", "self", ".", "readline", "(", ")", "while", "self", ".", "_cg_header_re", ".", "match", "(", "line", ")", ":", "line", "=", "self", ".", "readline", "(", ")", "# process c...
Parse the call graph.
[ "Parse", "the", "call", "graph", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L1541-L1558
226,835
jrfonseca/gprof2dot
gprof2dot.py
Theme.hsl_to_rgb
def hsl_to_rgb(self, h, s, l): """Convert a color from HSL color-model to RGB. See also: - http://www.w3.org/TR/css3-color/#hsl-color """ h = h % 1.0 s = min(max(s, 0.0), 1.0) l = min(max(l, 0.0), 1.0) if l <= 0.5: m2 = l*(s + 1.0) e...
python
def hsl_to_rgb(self, h, s, l): """Convert a color from HSL color-model to RGB. See also: - http://www.w3.org/TR/css3-color/#hsl-color """ h = h % 1.0 s = min(max(s, 0.0), 1.0) l = min(max(l, 0.0), 1.0) if l <= 0.5: m2 = l*(s + 1.0) e...
[ "def", "hsl_to_rgb", "(", "self", ",", "h", ",", "s", ",", "l", ")", ":", "h", "=", "h", "%", "1.0", "s", "=", "min", "(", "max", "(", "s", ",", "0.0", ")", ",", "1.0", ")", "l", "=", "min", "(", "max", "(", "l", ",", "0.0", ")", ",", ...
Convert a color from HSL color-model to RGB. See also: - http://www.w3.org/TR/css3-color/#hsl-color
[ "Convert", "a", "color", "from", "HSL", "color", "-", "model", "to", "RGB", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L2863-L2888
226,836
jrfonseca/gprof2dot
gprof2dot.py
DotWriter.wrap_function_name
def wrap_function_name(self, name): """Split the function name on multiple lines.""" if len(name) > 32: ratio = 2.0/3.0 height = max(int(len(name)/(1.0 - ratio) + 0.5), 1) width = max(len(name)/height, 32) # TODO: break lines in symbols name =...
python
def wrap_function_name(self, name): """Split the function name on multiple lines.""" if len(name) > 32: ratio = 2.0/3.0 height = max(int(len(name)/(1.0 - ratio) + 0.5), 1) width = max(len(name)/height, 32) # TODO: break lines in symbols name =...
[ "def", "wrap_function_name", "(", "self", ",", "name", ")", ":", "if", "len", "(", "name", ")", ">", "32", ":", "ratio", "=", "2.0", "/", "3.0", "height", "=", "max", "(", "int", "(", "len", "(", "name", ")", "/", "(", "1.0", "-", "ratio", ")",...
Split the function name on multiple lines.
[ "Split", "the", "function", "name", "on", "multiple", "lines", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L2974-L2989
226,837
danielhrisca/asammdf
asammdf/blocks/utils.py
matlab_compatible
def matlab_compatible(name): """ make a channel name compatible with Matlab variable naming Parameters ---------- name : str channel name Returns ------- compatible_name : str channel name compatible with Matlab """ compatible_name = [ch if ch in ALLOWED_MATLAB_CH...
python
def matlab_compatible(name): """ make a channel name compatible with Matlab variable naming Parameters ---------- name : str channel name Returns ------- compatible_name : str channel name compatible with Matlab """ compatible_name = [ch if ch in ALLOWED_MATLAB_CH...
[ "def", "matlab_compatible", "(", "name", ")", ":", "compatible_name", "=", "[", "ch", "if", "ch", "in", "ALLOWED_MATLAB_CHARS", "else", "\"_\"", "for", "ch", "in", "name", "]", "compatible_name", "=", "\"\"", ".", "join", "(", "compatible_name", ")", "if", ...
make a channel name compatible with Matlab variable naming Parameters ---------- name : str channel name Returns ------- compatible_name : str channel name compatible with Matlab
[ "make", "a", "channel", "name", "compatible", "with", "Matlab", "variable", "naming" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L149-L172
226,838
danielhrisca/asammdf
asammdf/blocks/utils.py
get_text_v3
def get_text_v3(address, stream, mapped=False): """ faster way to extract strings from mdf versions 2 and 3 TextBlock Parameters ---------- address : int TextBlock address stream : handle file IO handle Returns ------- text : str unicode string """ if ...
python
def get_text_v3(address, stream, mapped=False): """ faster way to extract strings from mdf versions 2 and 3 TextBlock Parameters ---------- address : int TextBlock address stream : handle file IO handle Returns ------- text : str unicode string """ if ...
[ "def", "get_text_v3", "(", "address", ",", "stream", ",", "mapped", "=", "False", ")", ":", "if", "address", "==", "0", ":", "return", "\"\"", "if", "mapped", ":", "size", ",", "=", "UINT16_uf", "(", "stream", ",", "address", "+", "2", ")", "text_byt...
faster way to extract strings from mdf versions 2 and 3 TextBlock Parameters ---------- address : int TextBlock address stream : handle file IO handle Returns ------- text : str unicode string
[ "faster", "way", "to", "extract", "strings", "from", "mdf", "versions", "2", "and", "3", "TextBlock" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L175-L219
226,839
danielhrisca/asammdf
asammdf/blocks/utils.py
get_text_v4
def get_text_v4(address, stream, mapped=False): """ faster way to extract strings from mdf version 4 TextBlock Parameters ---------- address : int TextBlock address stream : handle file IO handle Returns ------- text : str unicode string """ if address...
python
def get_text_v4(address, stream, mapped=False): """ faster way to extract strings from mdf version 4 TextBlock Parameters ---------- address : int TextBlock address stream : handle file IO handle Returns ------- text : str unicode string """ if address...
[ "def", "get_text_v4", "(", "address", ",", "stream", ",", "mapped", "=", "False", ")", ":", "if", "address", "==", "0", ":", "return", "\"\"", "if", "mapped", ":", "size", ",", "_", "=", "TWO_UINT64_uf", "(", "stream", ",", "address", "+", "8", ")", ...
faster way to extract strings from mdf version 4 TextBlock Parameters ---------- address : int TextBlock address stream : handle file IO handle Returns ------- text : str unicode string
[ "faster", "way", "to", "extract", "strings", "from", "mdf", "version", "4", "TextBlock" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L222-L266
226,840
danielhrisca/asammdf
asammdf/blocks/utils.py
get_fmt_v3
def get_fmt_v3(data_type, size): """convert mdf versions 2 and 3 channel data type to numpy dtype format string Parameters ---------- data_type : int mdf channel data type size : int data bit size Returns ------- fmt : str numpy compatible data type format st...
python
def get_fmt_v3(data_type, size): """convert mdf versions 2 and 3 channel data type to numpy dtype format string Parameters ---------- data_type : int mdf channel data type size : int data bit size Returns ------- fmt : str numpy compatible data type format st...
[ "def", "get_fmt_v3", "(", "data_type", ",", "size", ")", ":", "if", "data_type", "in", "{", "v3c", ".", "DATA_TYPE_STRING", ",", "v3c", ".", "DATA_TYPE_BYTEARRAY", "}", ":", "size", "=", "size", "//", "8", "if", "data_type", "==", "v3c", ".", "DATA_TYPE_...
convert mdf versions 2 and 3 channel data type to numpy dtype format string Parameters ---------- data_type : int mdf channel data type size : int data bit size Returns ------- fmt : str numpy compatible data type format string
[ "convert", "mdf", "versions", "2", "and", "3", "channel", "data", "type", "to", "numpy", "dtype", "format", "string" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L273-L330
226,841
danielhrisca/asammdf
asammdf/blocks/utils.py
get_fmt_v4
def get_fmt_v4(data_type, size, channel_type=v4c.CHANNEL_TYPE_VALUE): """convert mdf version 4 channel data type to numpy dtype format string Parameters ---------- data_type : int mdf channel data type size : int data bit size channel_type: int mdf channel type Retu...
python
def get_fmt_v4(data_type, size, channel_type=v4c.CHANNEL_TYPE_VALUE): """convert mdf version 4 channel data type to numpy dtype format string Parameters ---------- data_type : int mdf channel data type size : int data bit size channel_type: int mdf channel type Retu...
[ "def", "get_fmt_v4", "(", "data_type", ",", "size", ",", "channel_type", "=", "v4c", ".", "CHANNEL_TYPE_VALUE", ")", ":", "if", "data_type", "in", "v4c", ".", "NON_SCALAR_TYPES", ":", "size", "=", "size", "//", "8", "if", "data_type", "==", "v4c", ".", "...
convert mdf version 4 channel data type to numpy dtype format string Parameters ---------- data_type : int mdf channel data type size : int data bit size channel_type: int mdf channel type Returns ------- fmt : str numpy compatible data type format strin...
[ "convert", "mdf", "version", "4", "channel", "data", "type", "to", "numpy", "dtype", "format", "string" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L333-L409
226,842
danielhrisca/asammdf
asammdf/blocks/utils.py
fmt_to_datatype_v3
def fmt_to_datatype_v3(fmt, shape, array=False): """convert numpy dtype format string to mdf versions 2 and 3 channel data type and size Parameters ---------- fmt : numpy.dtype numpy data type shape : tuple numpy array shape array : bool disambiguate between bytearra...
python
def fmt_to_datatype_v3(fmt, shape, array=False): """convert numpy dtype format string to mdf versions 2 and 3 channel data type and size Parameters ---------- fmt : numpy.dtype numpy data type shape : tuple numpy array shape array : bool disambiguate between bytearra...
[ "def", "fmt_to_datatype_v3", "(", "fmt", ",", "shape", ",", "array", "=", "False", ")", ":", "size", "=", "fmt", ".", "itemsize", "*", "8", "if", "not", "array", "and", "shape", "[", "1", ":", "]", "and", "fmt", ".", "itemsize", "==", "1", "and", ...
convert numpy dtype format string to mdf versions 2 and 3 channel data type and size Parameters ---------- fmt : numpy.dtype numpy data type shape : tuple numpy array shape array : bool disambiguate between bytearray and channel array Returns ------- data_ty...
[ "convert", "numpy", "dtype", "format", "string", "to", "mdf", "versions", "2", "and", "3", "channel", "data", "type", "and", "size" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L412-L469
226,843
danielhrisca/asammdf
asammdf/blocks/utils.py
info_to_datatype_v4
def info_to_datatype_v4(signed, little_endian): """map CAN signal to MDF integer types Parameters ---------- signed : bool signal is flagged as signed in the CAN database little_endian : bool signal is flagged as little endian (Intel) in the CAN database Returns ------- ...
python
def info_to_datatype_v4(signed, little_endian): """map CAN signal to MDF integer types Parameters ---------- signed : bool signal is flagged as signed in the CAN database little_endian : bool signal is flagged as little endian (Intel) in the CAN database Returns ------- ...
[ "def", "info_to_datatype_v4", "(", "signed", ",", "little_endian", ")", ":", "if", "signed", ":", "if", "little_endian", ":", "datatype", "=", "v4c", ".", "DATA_TYPE_SIGNED_INTEL", "else", ":", "datatype", "=", "v4c", ".", "DATA_TYPE_SIGNED_MOTOROLA", "else", ":...
map CAN signal to MDF integer types Parameters ---------- signed : bool signal is flagged as signed in the CAN database little_endian : bool signal is flagged as little endian (Intel) in the CAN database Returns ------- datatype : int integer code for MDF channel da...
[ "map", "CAN", "signal", "to", "MDF", "integer", "types" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L472-L500
226,844
danielhrisca/asammdf
asammdf/blocks/utils.py
fmt_to_datatype_v4
def fmt_to_datatype_v4(fmt, shape, array=False): """convert numpy dtype format string to mdf version 4 channel data type and size Parameters ---------- fmt : numpy.dtype numpy data type shape : tuple numpy array shape array : bool disambiguate between bytearray and c...
python
def fmt_to_datatype_v4(fmt, shape, array=False): """convert numpy dtype format string to mdf version 4 channel data type and size Parameters ---------- fmt : numpy.dtype numpy data type shape : tuple numpy array shape array : bool disambiguate between bytearray and c...
[ "def", "fmt_to_datatype_v4", "(", "fmt", ",", "shape", ",", "array", "=", "False", ")", ":", "size", "=", "fmt", ".", "itemsize", "*", "8", "if", "not", "array", "and", "shape", "[", "1", ":", "]", "and", "fmt", ".", "itemsize", "==", "1", "and", ...
convert numpy dtype format string to mdf version 4 channel data type and size Parameters ---------- fmt : numpy.dtype numpy data type shape : tuple numpy array shape array : bool disambiguate between bytearray and channel array Returns ------- data_type, siz...
[ "convert", "numpy", "dtype", "format", "string", "to", "mdf", "version", "4", "channel", "data", "type", "and", "size" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L503-L555
226,845
danielhrisca/asammdf
asammdf/blocks/utils.py
debug_channel
def debug_channel(mdf, group, channel, dependency, file=None): """ use this to print debug information in case of errors Parameters ---------- mdf : MDF source MDF object group : dict group channel : Channel channel object dependency : ChannelDependency chann...
python
def debug_channel(mdf, group, channel, dependency, file=None): """ use this to print debug information in case of errors Parameters ---------- mdf : MDF source MDF object group : dict group channel : Channel channel object dependency : ChannelDependency chann...
[ "def", "debug_channel", "(", "mdf", ",", "group", ",", "channel", ",", "dependency", ",", "file", "=", "None", ")", ":", "print", "(", "\"MDF\"", ",", "\"=\"", "*", "76", ",", "file", "=", "file", ")", "print", "(", "\"name:\"", ",", "mdf", ".", "n...
use this to print debug information in case of errors Parameters ---------- mdf : MDF source MDF object group : dict group channel : Channel channel object dependency : ChannelDependency channel dependency object
[ "use", "this", "to", "print", "debug", "information", "in", "case", "of", "errors" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L594-L643
226,846
danielhrisca/asammdf
asammdf/blocks/utils.py
count_channel_groups
def count_channel_groups(stream, include_channels=False): """ count all channel groups as fast as possible. This is used to provide reliable progress information when loading a file using the GUI Parameters ---------- stream : file handle opened file handle include_channels : bool ...
python
def count_channel_groups(stream, include_channels=False): """ count all channel groups as fast as possible. This is used to provide reliable progress information when loading a file using the GUI Parameters ---------- stream : file handle opened file handle include_channels : bool ...
[ "def", "count_channel_groups", "(", "stream", ",", "include_channels", "=", "False", ")", ":", "count", "=", "0", "ch_count", "=", "0", "stream", ".", "seek", "(", "64", ")", "blk_id", "=", "stream", ".", "read", "(", "2", ")", "if", "blk_id", "==", ...
count all channel groups as fast as possible. This is used to provide reliable progress information when loading a file using the GUI Parameters ---------- stream : file handle opened file handle include_channels : bool also count channels Returns ------- count : int ...
[ "count", "all", "channel", "groups", "as", "fast", "as", "possible", ".", "This", "is", "used", "to", "provide", "reliable", "progress", "information", "when", "loading", "a", "file", "using", "the", "GUI" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L646-L720
226,847
danielhrisca/asammdf
asammdf/blocks/utils.py
validate_version_argument
def validate_version_argument(version, hint=4): """ validate the version argument against the supported MDF versions. The default version used depends on the hint MDF major revision Parameters ---------- version : str requested MDF version hint : int MDF revision hint Retur...
python
def validate_version_argument(version, hint=4): """ validate the version argument against the supported MDF versions. The default version used depends on the hint MDF major revision Parameters ---------- version : str requested MDF version hint : int MDF revision hint Retur...
[ "def", "validate_version_argument", "(", "version", ",", "hint", "=", "4", ")", ":", "if", "version", "not", "in", "SUPPORTED_VERSIONS", ":", "if", "hint", "==", "2", ":", "valid_version", "=", "\"2.14\"", "elif", "hint", "==", "3", ":", "valid_version", "...
validate the version argument against the supported MDF versions. The default version used depends on the hint MDF major revision Parameters ---------- version : str requested MDF version hint : int MDF revision hint Returns ------- valid_version : str valid ver...
[ "validate", "the", "version", "argument", "against", "the", "supported", "MDF", "versions", ".", "The", "default", "version", "used", "depends", "on", "the", "hint", "MDF", "major", "revision" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L723-L756
226,848
danielhrisca/asammdf
asammdf/blocks/utils.py
cut_video_stream
def cut_video_stream(stream, start, end, fmt): """ cut video stream from `start` to `end` time Parameters ---------- stream : bytes video file content start : float start time end : float end time Returns ------- result : bytes content of cut video ...
python
def cut_video_stream(stream, start, end, fmt): """ cut video stream from `start` to `end` time Parameters ---------- stream : bytes video file content start : float start time end : float end time Returns ------- result : bytes content of cut video ...
[ "def", "cut_video_stream", "(", "stream", ",", "start", ",", "end", ",", "fmt", ")", ":", "with", "TemporaryDirectory", "(", ")", "as", "tmp", ":", "in_file", "=", "Path", "(", "tmp", ")", "/", "f\"in{fmt}\"", "out_file", "=", "Path", "(", "tmp", ")", ...
cut video stream from `start` to `end` time Parameters ---------- stream : bytes video file content start : float start time end : float end time Returns ------- result : bytes content of cut video
[ "cut", "video", "stream", "from", "start", "to", "end", "time" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L878-L926
226,849
danielhrisca/asammdf
asammdf/blocks/utils.py
components
def components(channel, channel_name, unique_names, prefix="", master=None): """ yield pandas Series and unique name based on the ndarray object Parameters ---------- channel : numpy.ndarray channel to be used foir Series channel_name : str channel name unique_names : UniqueDB ...
python
def components(channel, channel_name, unique_names, prefix="", master=None): """ yield pandas Series and unique name based on the ndarray object Parameters ---------- channel : numpy.ndarray channel to be used foir Series channel_name : str channel name unique_names : UniqueDB ...
[ "def", "components", "(", "channel", ",", "channel_name", ",", "unique_names", ",", "prefix", "=", "\"\"", ",", "master", "=", "None", ")", ":", "names", "=", "channel", ".", "dtype", ".", "names", "# channel arrays", "if", "names", "[", "0", "]", "==", ...
yield pandas Series and unique name based on the ndarray object Parameters ---------- channel : numpy.ndarray channel to be used foir Series channel_name : str channel name unique_names : UniqueDB unique names object prefix : str prefix used in case of nested rec...
[ "yield", "pandas", "Series", "and", "unique", "name", "based", "on", "the", "ndarray", "object" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L1035-L1104
226,850
danielhrisca/asammdf
asammdf/blocks/utils.py
master_using_raster
def master_using_raster(mdf, raster, endpoint=False): """ get single master based on the raster Parameters ---------- mdf : asammdf.MDF measurement object raster : float new raster endpoint=False : bool include maximum time stamp in the new master Returns ------...
python
def master_using_raster(mdf, raster, endpoint=False): """ get single master based on the raster Parameters ---------- mdf : asammdf.MDF measurement object raster : float new raster endpoint=False : bool include maximum time stamp in the new master Returns ------...
[ "def", "master_using_raster", "(", "mdf", ",", "raster", ",", "endpoint", "=", "False", ")", ":", "if", "not", "raster", ":", "master", "=", "np", ".", "array", "(", "[", "]", ",", "dtype", "=", "'<f8'", ")", "else", ":", "t_min", "=", "[", "]", ...
get single master based on the raster Parameters ---------- mdf : asammdf.MDF measurement object raster : float new raster endpoint=False : bool include maximum time stamp in the new master Returns ------- master : np.array new master
[ "get", "single", "master", "based", "on", "the", "raster" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L1178-L1237
226,851
danielhrisca/asammdf
asammdf/blocks/utils.py
ChannelsDB.add
def add(self, channel_name, entry): """ add name to channels database and check if it contains a source path Parameters ---------- channel_name : str name that needs to be added to the database entry : tuple (group index, channel index) pair ...
python
def add(self, channel_name, entry): """ add name to channels database and check if it contains a source path Parameters ---------- channel_name : str name that needs to be added to the database entry : tuple (group index, channel index) pair ...
[ "def", "add", "(", "self", ",", "channel_name", ",", "entry", ")", ":", "if", "channel_name", ":", "if", "channel_name", "not", "in", "self", ":", "self", "[", "channel_name", "]", "=", "[", "entry", "]", "else", ":", "self", "[", "channel_name", "]", ...
add name to channels database and check if it contains a source path Parameters ---------- channel_name : str name that needs to be added to the database entry : tuple (group index, channel index) pair
[ "add", "name", "to", "channels", "database", "and", "check", "if", "it", "contains", "a", "source", "path" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L768-L792
226,852
danielhrisca/asammdf
asammdf/blocks/utils.py
UniqueDB.get_unique_name
def get_unique_name(self, name): """ returns an available unique name Parameters ---------- name : str name to be made unique Returns ------- unique_name : str new unique name """ if name not in self._db: sel...
python
def get_unique_name(self, name): """ returns an available unique name Parameters ---------- name : str name to be made unique Returns ------- unique_name : str new unique name """ if name not in self._db: sel...
[ "def", "get_unique_name", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "_db", ":", "self", ".", "_db", "[", "name", "]", "=", "0", "return", "name", "else", ":", "index", "=", "self", ".", "_db", "[", "name", "]", ...
returns an available unique name Parameters ---------- name : str name to be made unique Returns ------- unique_name : str new unique name
[ "returns", "an", "available", "unique", "name" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L854-L875
226,853
danielhrisca/asammdf
asammdf/mdf.py
MDF.iter_get
def iter_get( self, name=None, group=None, index=None, raster=None, samples_only=False, raw=False, ): """ iterator over a channel This is usefull in case of large files with a small number of channels. If the *raster* keyword argument...
python
def iter_get( self, name=None, group=None, index=None, raster=None, samples_only=False, raw=False, ): """ iterator over a channel This is usefull in case of large files with a small number of channels. If the *raster* keyword argument...
[ "def", "iter_get", "(", "self", ",", "name", "=", "None", ",", "group", "=", "None", ",", "index", "=", "None", ",", "raster", "=", "None", ",", "samples_only", "=", "False", ",", "raw", "=", "False", ",", ")", ":", "gp_nr", ",", "ch_nr", "=", "s...
iterator over a channel This is usefull in case of large files with a small number of channels. If the *raster* keyword argument is not *None* the output is interpolated accordingly Parameters ---------- name : string name of channel group : int ...
[ "iterator", "over", "a", "channel" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/mdf.py#L1770-L1818
226,854
danielhrisca/asammdf
asammdf/mdf.py
MDF.whereis
def whereis(self, channel): """ get ocurrences of channel name in the file Parameters ---------- channel : str channel name string Returns ------- ocurrences : tuple Examples -------- >>> mdf = MDF(file_name) >>> mdf...
python
def whereis(self, channel): """ get ocurrences of channel name in the file Parameters ---------- channel : str channel name string Returns ------- ocurrences : tuple Examples -------- >>> mdf = MDF(file_name) >>> mdf...
[ "def", "whereis", "(", "self", ",", "channel", ")", ":", "if", "channel", "in", "self", ":", "return", "tuple", "(", "self", ".", "channels_db", "[", "channel", "]", ")", "else", ":", "return", "tuple", "(", ")" ]
get ocurrences of channel name in the file Parameters ---------- channel : str channel name string Returns ------- ocurrences : tuple Examples -------- >>> mdf = MDF(file_name) >>> mdf.whereis('VehicleSpeed') # "VehicleSpeed...
[ "get", "ocurrences", "of", "channel", "name", "in", "the", "file" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/mdf.py#L2966-L2991
226,855
danielhrisca/asammdf
asammdf/blocks/mdf_v4.py
MDF4.get_invalidation_bits
def get_invalidation_bits(self, group_index, channel, fragment): """ get invalidation indexes for the channel Parameters ---------- group_index : int group index channel : Channel channel object fragment : (bytes, int) (fragment bytes,...
python
def get_invalidation_bits(self, group_index, channel, fragment): """ get invalidation indexes for the channel Parameters ---------- group_index : int group index channel : Channel channel object fragment : (bytes, int) (fragment bytes,...
[ "def", "get_invalidation_bits", "(", "self", ",", "group_index", ",", "channel", ",", "fragment", ")", ":", "group", "=", "self", ".", "groups", "[", "group_index", "]", "dtypes", "=", "group", ".", "types", "data_bytes", ",", "offset", ",", "_count", "=",...
get invalidation indexes for the channel Parameters ---------- group_index : int group index channel : Channel channel object fragment : (bytes, int) (fragment bytes, fragment offset) Returns ------- invalidation_bits ...
[ "get", "invalidation", "indexes", "for", "the", "channel" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/mdf_v4.py#L2182-L2227
226,856
danielhrisca/asammdf
asammdf/blocks/mdf_v4.py
MDF4.configure
def configure( self, *, read_fragment_size=None, write_fragment_size=None, use_display_names=None, single_bit_uint_as_bool=None, integer_interpolation=None, ): """ configure MDF parameters Parameters ---------- read_fragment_si...
python
def configure( self, *, read_fragment_size=None, write_fragment_size=None, use_display_names=None, single_bit_uint_as_bool=None, integer_interpolation=None, ): """ configure MDF parameters Parameters ---------- read_fragment_si...
[ "def", "configure", "(", "self", ",", "*", ",", "read_fragment_size", "=", "None", ",", "write_fragment_size", "=", "None", ",", "use_display_names", "=", "None", ",", "single_bit_uint_as_bool", "=", "None", ",", "integer_interpolation", "=", "None", ",", ")", ...
configure MDF parameters Parameters ---------- read_fragment_size : int size hint of split data blocks, default 8MB; if the initial size is smaller, then no data list is used. The actual split size depends on the data groups' records size write_fragme...
[ "configure", "MDF", "parameters" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/mdf_v4.py#L2229-L2276
226,857
danielhrisca/asammdf
asammdf/blocks/mdf_v4.py
MDF4.extract_attachment
def extract_attachment(self, address=None, index=None): """ extract attachment data by original address or by index. If it is an embedded attachment, then this method creates the new file according to the attachment file name information Parameters ---------- address : i...
python
def extract_attachment(self, address=None, index=None): """ extract attachment data by original address or by index. If it is an embedded attachment, then this method creates the new file according to the attachment file name information Parameters ---------- address : i...
[ "def", "extract_attachment", "(", "self", ",", "address", "=", "None", ",", "index", "=", "None", ")", ":", "if", "address", "is", "None", "and", "index", "is", "None", ":", "return", "b\"\"", ",", "Path", "(", "\"\"", ")", "if", "address", "is", "no...
extract attachment data by original address or by index. If it is an embedded attachment, then this method creates the new file according to the attachment file name information Parameters ---------- address : int attachment index; default *None* index : int ...
[ "extract", "attachment", "data", "by", "original", "address", "or", "by", "index", ".", "If", "it", "is", "an", "embedded", "attachment", "then", "this", "method", "creates", "the", "new", "file", "according", "to", "the", "attachment", "file", "name", "info...
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/mdf_v4.py#L3567-L3637
226,858
danielhrisca/asammdf
asammdf/blocks/mdf_v4.py
MDF4.get_channel_name
def get_channel_name(self, group, index): """Gets channel name. Parameters ---------- group : int 0-based group index index : int 0-based channel index Returns ------- name : str found channel name """ ...
python
def get_channel_name(self, group, index): """Gets channel name. Parameters ---------- group : int 0-based group index index : int 0-based channel index Returns ------- name : str found channel name """ ...
[ "def", "get_channel_name", "(", "self", ",", "group", ",", "index", ")", ":", "gp_nr", ",", "ch_nr", "=", "self", ".", "_validate_channel_selection", "(", "None", ",", "group", ",", "index", ")", "return", "self", ".", "groups", "[", "gp_nr", "]", ".", ...
Gets channel name. Parameters ---------- group : int 0-based group index index : int 0-based channel index Returns ------- name : str found channel name
[ "Gets", "channel", "name", "." ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/mdf_v4.py#L5803-L5821
226,859
danielhrisca/asammdf
asammdf/blocks/mdf_v4.py
MDF4.get_channel_unit
def get_channel_unit(self, name=None, group=None, index=None): """Gets channel unit. Channel can be specified in two ways: * using the first positional argument *name* * if there are multiple occurrences for this channel then the *group* and *index* arguments can be ...
python
def get_channel_unit(self, name=None, group=None, index=None): """Gets channel unit. Channel can be specified in two ways: * using the first positional argument *name* * if there are multiple occurrences for this channel then the *group* and *index* arguments can be ...
[ "def", "get_channel_unit", "(", "self", ",", "name", "=", "None", ",", "group", "=", "None", ",", "index", "=", "None", ")", ":", "gp_nr", ",", "ch_nr", "=", "self", ".", "_validate_channel_selection", "(", "name", ",", "group", ",", "index", ")", "grp...
Gets channel unit. Channel can be specified in two ways: * using the first positional argument *name* * if there are multiple occurrences for this channel then the *group* and *index* arguments can be used to select a specific group. * if there are ...
[ "Gets", "channel", "unit", "." ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/mdf_v4.py#L5835-L5881
226,860
danielhrisca/asammdf
asammdf/blocks/mdf_v4.py
MDF4.get_channel_comment
def get_channel_comment(self, name=None, group=None, index=None): """Gets channel comment. Channel can be specified in two ways: * using the first positional argument *name* * if there are multiple occurrences for this channel then the *group* and *index* arguments c...
python
def get_channel_comment(self, name=None, group=None, index=None): """Gets channel comment. Channel can be specified in two ways: * using the first positional argument *name* * if there are multiple occurrences for this channel then the *group* and *index* arguments c...
[ "def", "get_channel_comment", "(", "self", ",", "name", "=", "None", ",", "group", "=", "None", ",", "index", "=", "None", ")", ":", "gp_nr", ",", "ch_nr", "=", "self", ".", "_validate_channel_selection", "(", "name", ",", "group", ",", "index", ")", "...
Gets channel comment. Channel can be specified in two ways: * using the first positional argument *name* * if there are multiple occurrences for this channel then the *group* and *index* arguments can be used to select a specific group. * if there a...
[ "Gets", "channel", "comment", "." ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/mdf_v4.py#L5883-L5925
226,861
danielhrisca/asammdf
benchmarks/bench.py
_cmd_line_parser
def _cmd_line_parser(): ''' return a command line parser. It is used when generating the documentation ''' parser = argparse.ArgumentParser() parser.add_argument('--path', help=('path to test files, ' 'if not provided the script folder is used')...
python
def _cmd_line_parser(): ''' return a command line parser. It is used when generating the documentation ''' parser = argparse.ArgumentParser() parser.add_argument('--path', help=('path to test files, ' 'if not provided the script folder is used')...
[ "def", "_cmd_line_parser", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'--path'", ",", "help", "=", "(", "'path to test files, '", "'if not provided the script folder is used'", ")", ")", "parser", ...
return a command line parser. It is used when generating the documentation
[ "return", "a", "command", "line", "parser", ".", "It", "is", "used", "when", "generating", "the", "documentation" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/benchmarks/bench.py#L1100-L1118
226,862
danielhrisca/asammdf
benchmarks/bench.py
MyList.append
def append(self, item): """ append item and print it to stdout """ print(item) super(MyList, self).append(item)
python
def append(self, item): """ append item and print it to stdout """ print(item) super(MyList, self).append(item)
[ "def", "append", "(", "self", ",", "item", ")", ":", "print", "(", "item", ")", "super", "(", "MyList", ",", "self", ")", ".", "append", "(", "item", ")" ]
append item and print it to stdout
[ "append", "item", "and", "print", "it", "to", "stdout" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/benchmarks/bench.py#L42-L45
226,863
danielhrisca/asammdf
benchmarks/bench.py
MyList.extend
def extend(self, items): """ extend items and print them to stdout using the new line separator """ print('\n'.join(items)) super(MyList, self).extend(items)
python
def extend(self, items): """ extend items and print them to stdout using the new line separator """ print('\n'.join(items)) super(MyList, self).extend(items)
[ "def", "extend", "(", "self", ",", "items", ")", ":", "print", "(", "'\\n'", ".", "join", "(", "items", ")", ")", "super", "(", "MyList", ",", "self", ")", ".", "extend", "(", "items", ")" ]
extend items and print them to stdout using the new line separator
[ "extend", "items", "and", "print", "them", "to", "stdout", "using", "the", "new", "line", "separator" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/benchmarks/bench.py#L47-L52
226,864
danielhrisca/asammdf
asammdf/signal.py
Signal.extend
def extend(self, other): """ extend signal with samples from another signal Parameters ---------- other : Signal Returns ------- signal : Signal new extended *Signal* """ if len(self.timestamps): last_stamp = self.timesta...
python
def extend(self, other): """ extend signal with samples from another signal Parameters ---------- other : Signal Returns ------- signal : Signal new extended *Signal* """ if len(self.timestamps): last_stamp = self.timesta...
[ "def", "extend", "(", "self", ",", "other", ")", ":", "if", "len", "(", "self", ".", "timestamps", ")", ":", "last_stamp", "=", "self", ".", "timestamps", "[", "-", "1", "]", "else", ":", "last_stamp", "=", "0", "if", "len", "(", "other", ")", ":...
extend signal with samples from another signal Parameters ---------- other : Signal Returns ------- signal : Signal new extended *Signal*
[ "extend", "signal", "with", "samples", "from", "another", "signal" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/signal.py#L670-L729
226,865
danielhrisca/asammdf
asammdf/signal.py
Signal.physical
def physical(self): """ get the physical samples values Returns ------- phys : Signal new *Signal* with physical values """ if not self.raw or self.conversion is None: samples = self.samples.copy() else: samples = sel...
python
def physical(self): """ get the physical samples values Returns ------- phys : Signal new *Signal* with physical values """ if not self.raw or self.conversion is None: samples = self.samples.copy() else: samples = sel...
[ "def", "physical", "(", "self", ")", ":", "if", "not", "self", ".", "raw", "or", "self", ".", "conversion", "is", "None", ":", "samples", "=", "self", ".", "samples", ".", "copy", "(", ")", "else", ":", "samples", "=", "self", ".", "conversion", "....
get the physical samples values Returns ------- phys : Signal new *Signal* with physical values
[ "get", "the", "physical", "samples", "values" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/signal.py#L1094-L1124
226,866
danielhrisca/asammdf
asammdf/blocks/v4_blocks.py
AttachmentBlock.extract
def extract(self): """extract attachment data Returns ------- data : bytes """ if self.flags & v4c.FLAG_AT_EMBEDDED: if self.flags & v4c.FLAG_AT_COMPRESSED_EMBEDDED: data = decompress(self.embedded_data) else: data ...
python
def extract(self): """extract attachment data Returns ------- data : bytes """ if self.flags & v4c.FLAG_AT_EMBEDDED: if self.flags & v4c.FLAG_AT_COMPRESSED_EMBEDDED: data = decompress(self.embedded_data) else: data ...
[ "def", "extract", "(", "self", ")", ":", "if", "self", ".", "flags", "&", "v4c", ".", "FLAG_AT_EMBEDDED", ":", "if", "self", ".", "flags", "&", "v4c", ".", "FLAG_AT_COMPRESSED_EMBEDDED", ":", "data", "=", "decompress", "(", "self", ".", "embedded_data", ...
extract attachment data Returns ------- data : bytes
[ "extract", "attachment", "data" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/v4_blocks.py#L236-L260
226,867
danielhrisca/asammdf
asammdf/blocks/v4_blocks.py
HeaderBlock.start_time
def start_time(self): """ getter and setter the measurement start timestamp Returns ------- timestamp : datetime.datetime start timestamp """ timestamp = self.abs_time / 10 ** 9 if self.time_flags & v4c.FLAG_HD_LOCAL_TIME: timestamp = da...
python
def start_time(self): """ getter and setter the measurement start timestamp Returns ------- timestamp : datetime.datetime start timestamp """ timestamp = self.abs_time / 10 ** 9 if self.time_flags & v4c.FLAG_HD_LOCAL_TIME: timestamp = da...
[ "def", "start_time", "(", "self", ")", ":", "timestamp", "=", "self", ".", "abs_time", "/", "10", "**", "9", "if", "self", ".", "time_flags", "&", "v4c", ".", "FLAG_HD_LOCAL_TIME", ":", "timestamp", "=", "datetime", ".", "fromtimestamp", "(", "timestamp", ...
getter and setter the measurement start timestamp Returns ------- timestamp : datetime.datetime start timestamp
[ "getter", "and", "setter", "the", "measurement", "start", "timestamp" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/v4_blocks.py#L4366-L4382
226,868
danielhrisca/asammdf
asammdf/blocks/mdf_v3.py
MDF3._prepare_record
def _prepare_record(self, group): """ compute record dtype and parents dict for this group Parameters ---------- group : dict MDF group dict Returns ------- parents, dtypes : dict, numpy.dtype mapping of channels to records fields, record...
python
def _prepare_record(self, group): """ compute record dtype and parents dict for this group Parameters ---------- group : dict MDF group dict Returns ------- parents, dtypes : dict, numpy.dtype mapping of channels to records fields, record...
[ "def", "_prepare_record", "(", "self", ",", "group", ")", ":", "parents", ",", "dtypes", "=", "group", ".", "parents", ",", "group", ".", "types", "if", "parents", "is", "None", ":", "if", "group", ".", "data_location", "==", "v23c", ".", "LOCATION_ORIGI...
compute record dtype and parents dict for this group Parameters ---------- group : dict MDF group dict Returns ------- parents, dtypes : dict, numpy.dtype mapping of channels to records fields, records fiels dtype
[ "compute", "record", "dtype", "and", "parents", "dict", "for", "this", "group" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/mdf_v3.py#L346-L475
226,869
danielhrisca/asammdf
asammdf/blocks/mdf_v3.py
MDF3.close
def close(self): """ if the MDF was created with memory='minimum' and new channels have been appended, then this must be called just before the object is not used anymore to clean-up the temporary file """ if self._tempfile is not None: self._tempfile.close() ...
python
def close(self): """ if the MDF was created with memory='minimum' and new channels have been appended, then this must be called just before the object is not used anymore to clean-up the temporary file """ if self._tempfile is not None: self._tempfile.close() ...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_tempfile", "is", "not", "None", ":", "self", ".", "_tempfile", ".", "close", "(", ")", "if", "self", ".", "_file", "is", "not", "None", "and", "not", "self", ".", "_from_filelike", ":", "s...
if the MDF was created with memory='minimum' and new channels have been appended, then this must be called just before the object is not used anymore to clean-up the temporary file
[ "if", "the", "MDF", "was", "created", "with", "memory", "=", "minimum", "and", "new", "channels", "have", "been", "appended", "then", "this", "must", "be", "called", "just", "before", "the", "object", "is", "not", "used", "anymore", "to", "clean", "-", "...
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/mdf_v3.py#L2114-L2123
226,870
danielhrisca/asammdf
asammdf/blocks/mdf_v3.py
MDF3.iter_get_triggers
def iter_get_triggers(self): """ generator that yields triggers Returns ------- trigger_info : dict trigger information with the following keys: * comment : trigger comment * time : trigger time * pre_time : trigger pre time ...
python
def iter_get_triggers(self): """ generator that yields triggers Returns ------- trigger_info : dict trigger information with the following keys: * comment : trigger comment * time : trigger time * pre_time : trigger pre time ...
[ "def", "iter_get_triggers", "(", "self", ")", ":", "for", "i", ",", "gp", "in", "enumerate", "(", "self", ".", "groups", ")", ":", "trigger", "=", "gp", ".", "trigger", "if", "trigger", ":", "for", "j", "in", "range", "(", "trigger", "[", "\"trigger_...
generator that yields triggers Returns ------- trigger_info : dict trigger information with the following keys: * comment : trigger comment * time : trigger time * pre_time : trigger pre time * post_time : trigger post...
[ "generator", "that", "yields", "triggers" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/mdf_v3.py#L3069-L3097
226,871
danielhrisca/asammdf
asammdf/gui/widgets/formated_axis.py
FormatedAxis.setLabel
def setLabel(self, text=None, units=None, unitPrefix=None, **args): """ overwrites pyqtgraph setLabel """ show_label = False if text is not None: self.labelText = text show_label = True if units is not None: self.labelUnits = units ...
python
def setLabel(self, text=None, units=None, unitPrefix=None, **args): """ overwrites pyqtgraph setLabel """ show_label = False if text is not None: self.labelText = text show_label = True if units is not None: self.labelUnits = units ...
[ "def", "setLabel", "(", "self", ",", "text", "=", "None", ",", "units", "=", "None", ",", "unitPrefix", "=", "None", ",", "*", "*", "args", ")", ":", "show_label", "=", "False", "if", "text", "is", "not", "None", ":", "self", ".", "labelText", "=",...
overwrites pyqtgraph setLabel
[ "overwrites", "pyqtgraph", "setLabel" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/gui/widgets/formated_axis.py#L52-L72
226,872
bernardopires/django-tenant-schemas
tenant_schemas/utils.py
clean_tenant_url
def clean_tenant_url(url_string): """ Removes the TENANT_TOKEN from a particular string """ if hasattr(settings, 'PUBLIC_SCHEMA_URLCONF'): if (settings.PUBLIC_SCHEMA_URLCONF and url_string.startswith(settings.PUBLIC_SCHEMA_URLCONF)): url_string = url_string[len(settin...
python
def clean_tenant_url(url_string): """ Removes the TENANT_TOKEN from a particular string """ if hasattr(settings, 'PUBLIC_SCHEMA_URLCONF'): if (settings.PUBLIC_SCHEMA_URLCONF and url_string.startswith(settings.PUBLIC_SCHEMA_URLCONF)): url_string = url_string[len(settin...
[ "def", "clean_tenant_url", "(", "url_string", ")", ":", "if", "hasattr", "(", "settings", ",", "'PUBLIC_SCHEMA_URLCONF'", ")", ":", "if", "(", "settings", ".", "PUBLIC_SCHEMA_URLCONF", "and", "url_string", ".", "startswith", "(", "settings", ".", "PUBLIC_SCHEMA_UR...
Removes the TENANT_TOKEN from a particular string
[ "Removes", "the", "TENANT_TOKEN", "from", "a", "particular", "string" ]
75faf00834e1fb7ed017949bfb54531f6329a8dd
https://github.com/bernardopires/django-tenant-schemas/blob/75faf00834e1fb7ed017949bfb54531f6329a8dd/tenant_schemas/utils.py#L53-L61
226,873
bernardopires/django-tenant-schemas
tenant_schemas/utils.py
app_labels
def app_labels(apps_list): """ Returns a list of app labels of the given apps_list, now properly handles new Django 1.7+ application registry. https://docs.djangoproject.com/en/1.8/ref/applications/#django.apps.AppConfig.label """ if AppConfig is None: return [app.split('.')[-1] for ap...
python
def app_labels(apps_list): """ Returns a list of app labels of the given apps_list, now properly handles new Django 1.7+ application registry. https://docs.djangoproject.com/en/1.8/ref/applications/#django.apps.AppConfig.label """ if AppConfig is None: return [app.split('.')[-1] for ap...
[ "def", "app_labels", "(", "apps_list", ")", ":", "if", "AppConfig", "is", "None", ":", "return", "[", "app", ".", "split", "(", "'.'", ")", "[", "-", "1", "]", "for", "app", "in", "apps_list", "]", "return", "[", "AppConfig", ".", "create", "(", "a...
Returns a list of app labels of the given apps_list, now properly handles new Django 1.7+ application registry. https://docs.djangoproject.com/en/1.8/ref/applications/#django.apps.AppConfig.label
[ "Returns", "a", "list", "of", "app", "labels", "of", "the", "given", "apps_list", "now", "properly", "handles", "new", "Django", "1", ".", "7", "+", "application", "registry", "." ]
75faf00834e1fb7ed017949bfb54531f6329a8dd
https://github.com/bernardopires/django-tenant-schemas/blob/75faf00834e1fb7ed017949bfb54531f6329a8dd/tenant_schemas/utils.py#L109-L118
226,874
bernardopires/django-tenant-schemas
tenant_schemas/storage.py
TenantStorageMixin.path
def path(self, name): """ Look for files in subdirectory of MEDIA_ROOT using the tenant's domain_url value as the specifier. """ if name is None: name = '' try: location = safe_join(self.location, connection.tenant.domain_url) except Attrib...
python
def path(self, name): """ Look for files in subdirectory of MEDIA_ROOT using the tenant's domain_url value as the specifier. """ if name is None: name = '' try: location = safe_join(self.location, connection.tenant.domain_url) except Attrib...
[ "def", "path", "(", "self", ",", "name", ")", ":", "if", "name", "is", "None", ":", "name", "=", "''", "try", ":", "location", "=", "safe_join", "(", "self", ".", "location", ",", "connection", ".", "tenant", ".", "domain_url", ")", "except", "Attrib...
Look for files in subdirectory of MEDIA_ROOT using the tenant's domain_url value as the specifier.
[ "Look", "for", "files", "in", "subdirectory", "of", "MEDIA_ROOT", "using", "the", "tenant", "s", "domain_url", "value", "as", "the", "specifier", "." ]
75faf00834e1fb7ed017949bfb54531f6329a8dd
https://github.com/bernardopires/django-tenant-schemas/blob/75faf00834e1fb7ed017949bfb54531f6329a8dd/tenant_schemas/storage.py#L27-L43
226,875
bernardopires/django-tenant-schemas
tenant_schemas/management/commands/tenant_command.py
Command.run_from_argv
def run_from_argv(self, argv): """ Changes the option_list to use the options from the wrapped command. Adds schema parameter to specify which schema will be used when executing the wrapped command. """ # load the command object. try: app_name = get_co...
python
def run_from_argv(self, argv): """ Changes the option_list to use the options from the wrapped command. Adds schema parameter to specify which schema will be used when executing the wrapped command. """ # load the command object. try: app_name = get_co...
[ "def", "run_from_argv", "(", "self", ",", "argv", ")", ":", "# load the command object.", "try", ":", "app_name", "=", "get_commands", "(", ")", "[", "argv", "[", "2", "]", "]", "except", "KeyError", ":", "raise", "CommandError", "(", "\"Unknown command: %r\""...
Changes the option_list to use the options from the wrapped command. Adds schema parameter to specify which schema will be used when executing the wrapped command.
[ "Changes", "the", "option_list", "to", "use", "the", "options", "from", "the", "wrapped", "command", ".", "Adds", "schema", "parameter", "to", "specify", "which", "schema", "will", "be", "used", "when", "executing", "the", "wrapped", "command", "." ]
75faf00834e1fb7ed017949bfb54531f6329a8dd
https://github.com/bernardopires/django-tenant-schemas/blob/75faf00834e1fb7ed017949bfb54531f6329a8dd/tenant_schemas/management/commands/tenant_command.py#L11-L38
226,876
bernardopires/django-tenant-schemas
tenant_schemas/management/commands/__init__.py
BaseTenantCommand.handle
def handle(self, *args, **options): """ Iterates a command over all registered schemata. """ if options['schema_name']: # only run on a particular schema connection.set_schema_to_public() self.execute_command(get_tenant_model().objects.get(schema_name=...
python
def handle(self, *args, **options): """ Iterates a command over all registered schemata. """ if options['schema_name']: # only run on a particular schema connection.set_schema_to_public() self.execute_command(get_tenant_model().objects.get(schema_name=...
[ "def", "handle", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "if", "options", "[", "'schema_name'", "]", ":", "# only run on a particular schema", "connection", ".", "set_schema_to_public", "(", ")", "self", ".", "execute_command", "(", ...
Iterates a command over all registered schemata.
[ "Iterates", "a", "command", "over", "all", "registered", "schemata", "." ]
75faf00834e1fb7ed017949bfb54531f6329a8dd
https://github.com/bernardopires/django-tenant-schemas/blob/75faf00834e1fb7ed017949bfb54531f6329a8dd/tenant_schemas/management/commands/__init__.py#L69-L81
226,877
bernardopires/django-tenant-schemas
tenant_schemas/postgresql_backend/base.py
DatabaseWrapper._cursor
def _cursor(self, name=None): """ Here it happens. We hope every Django db operation using PostgreSQL must go through this to get the cursor handle. We change the path. """ if name: # Only supported and required by Django 1.11 (server-side cursor) cursor =...
python
def _cursor(self, name=None): """ Here it happens. We hope every Django db operation using PostgreSQL must go through this to get the cursor handle. We change the path. """ if name: # Only supported and required by Django 1.11 (server-side cursor) cursor =...
[ "def", "_cursor", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", ":", "# Only supported and required by Django 1.11 (server-side cursor)", "cursor", "=", "super", "(", "DatabaseWrapper", ",", "self", ")", ".", "_cursor", "(", "name", "=", "name",...
Here it happens. We hope every Django db operation using PostgreSQL must go through this to get the cursor handle. We change the path.
[ "Here", "it", "happens", ".", "We", "hope", "every", "Django", "db", "operation", "using", "PostgreSQL", "must", "go", "through", "this", "to", "get", "the", "cursor", "handle", ".", "We", "change", "the", "path", "." ]
75faf00834e1fb7ed017949bfb54531f6329a8dd
https://github.com/bernardopires/django-tenant-schemas/blob/75faf00834e1fb7ed017949bfb54531f6329a8dd/tenant_schemas/postgresql_backend/base.py#L112-L166
226,878
bernardopires/django-tenant-schemas
tenant_schemas/apps.py
best_practice
def best_practice(app_configs, **kwargs): """ Test for configuration recommendations. These are best practices, they avoid hard to find bugs and unexpected behaviour. """ if app_configs is None: app_configs = apps.get_app_configs() # Take the app_configs and turn them into *old style* a...
python
def best_practice(app_configs, **kwargs): """ Test for configuration recommendations. These are best practices, they avoid hard to find bugs and unexpected behaviour. """ if app_configs is None: app_configs = apps.get_app_configs() # Take the app_configs and turn them into *old style* a...
[ "def", "best_practice", "(", "app_configs", ",", "*", "*", "kwargs", ")", ":", "if", "app_configs", "is", "None", ":", "app_configs", "=", "apps", ".", "get_app_configs", "(", ")", "# Take the app_configs and turn them into *old style* application names.", "# This is wh...
Test for configuration recommendations. These are best practices, they avoid hard to find bugs and unexpected behaviour.
[ "Test", "for", "configuration", "recommendations", ".", "These", "are", "best", "practices", "they", "avoid", "hard", "to", "find", "bugs", "and", "unexpected", "behaviour", "." ]
75faf00834e1fb7ed017949bfb54531f6329a8dd
https://github.com/bernardopires/django-tenant-schemas/blob/75faf00834e1fb7ed017949bfb54531f6329a8dd/tenant_schemas/apps.py#L14-L104
226,879
google/openhtf
openhtf/plugs/device_wrapping.py
short_repr
def short_repr(obj, max_len=40): """Returns a short, term-friendly string representation of the object. Args: obj: An object for which to return a string representation. max_len: Maximum length of the returned string. Longer reprs will be turned into a brief descriptive string giving the type and l...
python
def short_repr(obj, max_len=40): """Returns a short, term-friendly string representation of the object. Args: obj: An object for which to return a string representation. max_len: Maximum length of the returned string. Longer reprs will be turned into a brief descriptive string giving the type and l...
[ "def", "short_repr", "(", "obj", ",", "max_len", "=", "40", ")", ":", "obj_repr", "=", "repr", "(", "obj", ")", "if", "len", "(", "obj_repr", ")", "<=", "max_len", ":", "return", "obj_repr", "return", "'<{} of length {}>'", ".", "format", "(", "type", ...
Returns a short, term-friendly string representation of the object. Args: obj: An object for which to return a string representation. max_len: Maximum length of the returned string. Longer reprs will be turned into a brief descriptive string giving the type and length of obj.
[ "Returns", "a", "short", "term", "-", "friendly", "string", "representation", "of", "the", "object", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/device_wrapping.py#L29-L40
226,880
google/openhtf
openhtf/core/measurements.py
measures
def measures(*measurements, **kwargs): """Decorator-maker used to declare measurements for phases. See the measurements module docstring for examples of usage. Args: measurements: Measurement objects to declare, or a string name from which to create a Measurement. kwargs: Keyword arguments to pa...
python
def measures(*measurements, **kwargs): """Decorator-maker used to declare measurements for phases. See the measurements module docstring for examples of usage. Args: measurements: Measurement objects to declare, or a string name from which to create a Measurement. kwargs: Keyword arguments to pa...
[ "def", "measures", "(", "*", "measurements", ",", "*", "*", "kwargs", ")", ":", "def", "_maybe_make", "(", "meas", ")", ":", "\"\"\"Turn strings into Measurement objects if necessary.\"\"\"", "if", "isinstance", "(", "meas", ",", "Measurement", ")", ":", "return",...
Decorator-maker used to declare measurements for phases. See the measurements module docstring for examples of usage. Args: measurements: Measurement objects to declare, or a string name from which to create a Measurement. kwargs: Keyword arguments to pass to Measurement constructor if we're ...
[ "Decorator", "-", "maker", "used", "to", "declare", "measurements", "for", "phases", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L614-L662
226,881
google/openhtf
openhtf/core/measurements.py
Measurement.set_notification_callback
def set_notification_callback(self, notification_cb): """Set the notifier we'll call when measurements are set.""" self._notification_cb = notification_cb if not notification_cb and self.dimensions: self.measured_value.notify_value_set = None return self
python
def set_notification_callback(self, notification_cb): """Set the notifier we'll call when measurements are set.""" self._notification_cb = notification_cb if not notification_cb and self.dimensions: self.measured_value.notify_value_set = None return self
[ "def", "set_notification_callback", "(", "self", ",", "notification_cb", ")", ":", "self", ".", "_notification_cb", "=", "notification_cb", "if", "not", "notification_cb", "and", "self", ".", "dimensions", ":", "self", ".", "measured_value", ".", "notify_value_set",...
Set the notifier we'll call when measurements are set.
[ "Set", "the", "notifier", "we", "ll", "call", "when", "measurements", "are", "set", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L171-L176
226,882
google/openhtf
openhtf/core/measurements.py
Measurement._maybe_make_unit_desc
def _maybe_make_unit_desc(self, unit_desc): """Return the UnitDescriptor or convert a string to one.""" if isinstance(unit_desc, str) or unit_desc is None: unit_desc = units.Unit(unit_desc) if not isinstance(unit_desc, units.UnitDescriptor): raise TypeError('Invalid units for measurement %s: %s'...
python
def _maybe_make_unit_desc(self, unit_desc): """Return the UnitDescriptor or convert a string to one.""" if isinstance(unit_desc, str) or unit_desc is None: unit_desc = units.Unit(unit_desc) if not isinstance(unit_desc, units.UnitDescriptor): raise TypeError('Invalid units for measurement %s: %s'...
[ "def", "_maybe_make_unit_desc", "(", "self", ",", "unit_desc", ")", ":", "if", "isinstance", "(", "unit_desc", ",", "str", ")", "or", "unit_desc", "is", "None", ":", "unit_desc", "=", "units", ".", "Unit", "(", "unit_desc", ")", "if", "not", "isinstance", ...
Return the UnitDescriptor or convert a string to one.
[ "Return", "the", "UnitDescriptor", "or", "convert", "a", "string", "to", "one", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L191-L198
226,883
google/openhtf
openhtf/core/measurements.py
Measurement._maybe_make_dimension
def _maybe_make_dimension(self, dimension): """Return a `measurements.Dimension` instance.""" # For backwards compatibility the argument can be either a Dimension, a # string or a `units.UnitDescriptor`. if isinstance(dimension, Dimension): return dimension if isinstance(dimension, units.UnitD...
python
def _maybe_make_dimension(self, dimension): """Return a `measurements.Dimension` instance.""" # For backwards compatibility the argument can be either a Dimension, a # string or a `units.UnitDescriptor`. if isinstance(dimension, Dimension): return dimension if isinstance(dimension, units.UnitD...
[ "def", "_maybe_make_dimension", "(", "self", ",", "dimension", ")", ":", "# For backwards compatibility the argument can be either a Dimension, a", "# string or a `units.UnitDescriptor`.", "if", "isinstance", "(", "dimension", ",", "Dimension", ")", ":", "return", "dimension", ...
Return a `measurements.Dimension` instance.
[ "Return", "a", "measurements", ".", "Dimension", "instance", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L200-L211
226,884
google/openhtf
openhtf/core/measurements.py
Measurement.with_dimensions
def with_dimensions(self, *dimensions): """Declare dimensions for this Measurement, returns self for chaining.""" self.dimensions = tuple( self._maybe_make_dimension(dim) for dim in dimensions) self._cached = None return self
python
def with_dimensions(self, *dimensions): """Declare dimensions for this Measurement, returns self for chaining.""" self.dimensions = tuple( self._maybe_make_dimension(dim) for dim in dimensions) self._cached = None return self
[ "def", "with_dimensions", "(", "self", ",", "*", "dimensions", ")", ":", "self", ".", "dimensions", "=", "tuple", "(", "self", ".", "_maybe_make_dimension", "(", "dim", ")", "for", "dim", "in", "dimensions", ")", "self", ".", "_cached", "=", "None", "ret...
Declare dimensions for this Measurement, returns self for chaining.
[ "Declare", "dimensions", "for", "this", "Measurement", "returns", "self", "for", "chaining", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L218-L223
226,885
google/openhtf
openhtf/core/measurements.py
Measurement.with_validator
def with_validator(self, validator): """Add a validator callback to this Measurement, chainable.""" if not callable(validator): raise ValueError('Validator must be callable', validator) self.validators.append(validator) self._cached = None return self
python
def with_validator(self, validator): """Add a validator callback to this Measurement, chainable.""" if not callable(validator): raise ValueError('Validator must be callable', validator) self.validators.append(validator) self._cached = None return self
[ "def", "with_validator", "(", "self", ",", "validator", ")", ":", "if", "not", "callable", "(", "validator", ")", ":", "raise", "ValueError", "(", "'Validator must be callable'", ",", "validator", ")", "self", ".", "validators", ".", "append", "(", "validator"...
Add a validator callback to this Measurement, chainable.
[ "Add", "a", "validator", "callback", "to", "this", "Measurement", "chainable", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L225-L231
226,886
google/openhtf
openhtf/core/measurements.py
Measurement.with_args
def with_args(self, **kwargs): """String substitution for names and docstrings.""" validators = [ validator.with_args(**kwargs) if hasattr(validator, 'with_args') else validator for validator in self.validators ] return mutablerecords.CopyRecord( self, name=util.format_st...
python
def with_args(self, **kwargs): """String substitution for names and docstrings.""" validators = [ validator.with_args(**kwargs) if hasattr(validator, 'with_args') else validator for validator in self.validators ] return mutablerecords.CopyRecord( self, name=util.format_st...
[ "def", "with_args", "(", "self", ",", "*", "*", "kwargs", ")", ":", "validators", "=", "[", "validator", ".", "with_args", "(", "*", "*", "kwargs", ")", "if", "hasattr", "(", "validator", ",", "'with_args'", ")", "else", "validator", "for", "validator", ...
String substitution for names and docstrings.
[ "String", "substitution", "for", "names", "and", "docstrings", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L233-L245
226,887
google/openhtf
openhtf/core/measurements.py
Measurement.validate
def validate(self): """Validate this measurement and update its 'outcome' field.""" # PASS if all our validators return True, otherwise FAIL. try: if all(v(self.measured_value.value) for v in self.validators): self.outcome = Outcome.PASS else: self.outcome = Outcome.FAIL re...
python
def validate(self): """Validate this measurement and update its 'outcome' field.""" # PASS if all our validators return True, otherwise FAIL. try: if all(v(self.measured_value.value) for v in self.validators): self.outcome = Outcome.PASS else: self.outcome = Outcome.FAIL re...
[ "def", "validate", "(", "self", ")", ":", "# PASS if all our validators return True, otherwise FAIL.", "try", ":", "if", "all", "(", "v", "(", "self", ".", "measured_value", ".", "value", ")", "for", "v", "in", "self", ".", "validators", ")", ":", "self", "....
Validate this measurement and update its 'outcome' field.
[ "Validate", "this", "measurement", "and", "update", "its", "outcome", "field", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L260-L276
226,888
google/openhtf
openhtf/core/measurements.py
Measurement.as_base_types
def as_base_types(self): """Convert this measurement to a dict of basic types.""" if not self._cached: # Create the single cache file the first time this is called. self._cached = { 'name': self.name, 'outcome': self.outcome.name, } if self.validators: self._c...
python
def as_base_types(self): """Convert this measurement to a dict of basic types.""" if not self._cached: # Create the single cache file the first time this is called. self._cached = { 'name': self.name, 'outcome': self.outcome.name, } if self.validators: self._c...
[ "def", "as_base_types", "(", "self", ")", ":", "if", "not", "self", ".", "_cached", ":", "# Create the single cache file the first time this is called.", "self", ".", "_cached", "=", "{", "'name'", ":", "self", ".", "name", ",", "'outcome'", ":", "self", ".", ...
Convert this measurement to a dict of basic types.
[ "Convert", "this", "measurement", "to", "a", "dict", "of", "basic", "types", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L278-L297
226,889
google/openhtf
openhtf/core/measurements.py
Measurement.to_dataframe
def to_dataframe(self, columns=None): """Convert a multi-dim to a pandas dataframe.""" if not isinstance(self.measured_value, DimensionedMeasuredValue): raise TypeError( 'Only a dimensioned measurement can be converted to a DataFrame') if columns is None: columns = [d.name for d in self...
python
def to_dataframe(self, columns=None): """Convert a multi-dim to a pandas dataframe.""" if not isinstance(self.measured_value, DimensionedMeasuredValue): raise TypeError( 'Only a dimensioned measurement can be converted to a DataFrame') if columns is None: columns = [d.name for d in self...
[ "def", "to_dataframe", "(", "self", ",", "columns", "=", "None", ")", ":", "if", "not", "isinstance", "(", "self", ".", "measured_value", ",", "DimensionedMeasuredValue", ")", ":", "raise", "TypeError", "(", "'Only a dimensioned measurement can be converted to a DataF...
Convert a multi-dim to a pandas dataframe.
[ "Convert", "a", "multi", "-", "dim", "to", "a", "pandas", "dataframe", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L299-L311
226,890
google/openhtf
openhtf/core/measurements.py
MeasuredValue.set
def set(self, value): """Set the value for this measurement, with some sanity checks.""" if self.is_value_set: # While we want to *allow* re-setting previously set measurements, we'd # rather promote the use of multidimensional measurements instead of # discarding data, so we make this somewha...
python
def set(self, value): """Set the value for this measurement, with some sanity checks.""" if self.is_value_set: # While we want to *allow* re-setting previously set measurements, we'd # rather promote the use of multidimensional measurements instead of # discarding data, so we make this somewha...
[ "def", "set", "(", "self", ",", "value", ")", ":", "if", "self", ".", "is_value_set", ":", "# While we want to *allow* re-setting previously set measurements, we'd", "# rather promote the use of multidimensional measurements instead of", "# discarding data, so we make this somewhat cha...
Set the value for this measurement, with some sanity checks.
[ "Set", "the", "value", "for", "this", "measurement", "with", "some", "sanity", "checks", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L354-L368
226,891
google/openhtf
openhtf/core/measurements.py
Dimension.from_string
def from_string(cls, string): """Convert a string into a Dimension""" # Note: There is some ambiguity as to whether the string passed is intended # to become a unit looked up by name or suffix, or a Dimension descriptor. if string in units.UNITS_BY_ALL: return cls(description=string, unit=units.Un...
python
def from_string(cls, string): """Convert a string into a Dimension""" # Note: There is some ambiguity as to whether the string passed is intended # to become a unit looked up by name or suffix, or a Dimension descriptor. if string in units.UNITS_BY_ALL: return cls(description=string, unit=units.Un...
[ "def", "from_string", "(", "cls", ",", "string", ")", ":", "# Note: There is some ambiguity as to whether the string passed is intended", "# to become a unit looked up by name or suffix, or a Dimension descriptor.", "if", "string", "in", "units", ".", "UNITS_BY_ALL", ":", "return",...
Convert a string into a Dimension
[ "Convert", "a", "string", "into", "a", "Dimension" ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L404-L411
226,892
google/openhtf
openhtf/core/measurements.py
DimensionedMeasuredValue.value
def value(self): """The values stored in this record. Returns: A list of tuples; the last element of each tuple will be the measured value, the other elements will be the associated coordinates. The tuples are output in the order in which they were set. """ if not self.is_value_set: ...
python
def value(self): """The values stored in this record. Returns: A list of tuples; the last element of each tuple will be the measured value, the other elements will be the associated coordinates. The tuples are output in the order in which they were set. """ if not self.is_value_set: ...
[ "def", "value", "(", "self", ")", ":", "if", "not", "self", ".", "is_value_set", ":", "raise", "MeasurementNotSetError", "(", "'Measurement not yet set'", ",", "self", ".", "name", ")", "return", "[", "dimensions", "+", "(", "value", ",", ")", "for", "dime...
The values stored in this record. Returns: A list of tuples; the last element of each tuple will be the measured value, the other elements will be the associated coordinates. The tuples are output in the order in which they were set.
[ "The", "values", "stored", "in", "this", "record", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L505-L516
226,893
google/openhtf
openhtf/core/measurements.py
DimensionedMeasuredValue.to_dataframe
def to_dataframe(self, columns=None): """Converts to a `pandas.DataFrame`""" if not self.is_value_set: raise ValueError('Value must be set before converting to a DataFrame.') if not pandas: raise RuntimeError('Install pandas to convert to pandas.DataFrame') return pandas.DataFrame.from_recor...
python
def to_dataframe(self, columns=None): """Converts to a `pandas.DataFrame`""" if not self.is_value_set: raise ValueError('Value must be set before converting to a DataFrame.') if not pandas: raise RuntimeError('Install pandas to convert to pandas.DataFrame') return pandas.DataFrame.from_recor...
[ "def", "to_dataframe", "(", "self", ",", "columns", "=", "None", ")", ":", "if", "not", "self", ".", "is_value_set", ":", "raise", "ValueError", "(", "'Value must be set before converting to a DataFrame.'", ")", "if", "not", "pandas", ":", "raise", "RuntimeError",...
Converts to a `pandas.DataFrame`
[ "Converts", "to", "a", "pandas", ".", "DataFrame" ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L525-L531
226,894
google/openhtf
openhtf/core/measurements.py
Collection._assert_valid_key
def _assert_valid_key(self, name): """Raises if name is not a valid measurement.""" if name not in self._measurements: raise NotAMeasurementError('Not a measurement', name, self._measurements)
python
def _assert_valid_key(self, name): """Raises if name is not a valid measurement.""" if name not in self._measurements: raise NotAMeasurementError('Not a measurement', name, self._measurements)
[ "def", "_assert_valid_key", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "_measurements", ":", "raise", "NotAMeasurementError", "(", "'Not a measurement'", ",", "name", ",", "self", ".", "_measurements", ")" ]
Raises if name is not a valid measurement.
[ "Raises", "if", "name", "is", "not", "a", "valid", "measurement", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/core/measurements.py#L579-L582
226,895
google/openhtf
openhtf/plugs/usb/adb_device.py
AdbDevice.install
def install(self, apk_path, destination_dir=None, timeout_ms=None): """Install apk to device. Doesn't support verifier file, instead allows destination directory to be overridden. Arguments: apk_path: Local path to apk to install. destination_dir: Optional destination directory. Use /syste...
python
def install(self, apk_path, destination_dir=None, timeout_ms=None): """Install apk to device. Doesn't support verifier file, instead allows destination directory to be overridden. Arguments: apk_path: Local path to apk to install. destination_dir: Optional destination directory. Use /syste...
[ "def", "install", "(", "self", ",", "apk_path", ",", "destination_dir", "=", "None", ",", "timeout_ms", "=", "None", ")", ":", "if", "not", "destination_dir", ":", "destination_dir", "=", "'/data/local/tmp/'", "basename", "=", "os", ".", "path", ".", "basena...
Install apk to device. Doesn't support verifier file, instead allows destination directory to be overridden. Arguments: apk_path: Local path to apk to install. destination_dir: Optional destination directory. Use /system/app/ for persistent applications. timeout_ms: Expected time...
[ "Install", "apk", "to", "device", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_device.py#L111-L132
226,896
google/openhtf
openhtf/plugs/usb/adb_device.py
AdbDevice.push
def push(self, source_file, device_filename, timeout_ms=None): """Push source_file to file on device. Arguments: source_file: Either a filename or file-like object to push to the device. If a filename, will set the remote mtime to match the local mtime, otherwise will use the current time...
python
def push(self, source_file, device_filename, timeout_ms=None): """Push source_file to file on device. Arguments: source_file: Either a filename or file-like object to push to the device. If a filename, will set the remote mtime to match the local mtime, otherwise will use the current time...
[ "def", "push", "(", "self", ",", "source_file", ",", "device_filename", ",", "timeout_ms", "=", "None", ")", ":", "mtime", "=", "0", "if", "isinstance", "(", "source_file", ",", "six", ".", "string_types", ")", ":", "mtime", "=", "os", ".", "path", "."...
Push source_file to file on device. Arguments: source_file: Either a filename or file-like object to push to the device. If a filename, will set the remote mtime to match the local mtime, otherwise will use the current time. device_filename: The filename on the device to write to. ...
[ "Push", "source_file", "to", "file", "on", "device", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_device.py#L134-L151
226,897
google/openhtf
openhtf/plugs/usb/adb_device.py
AdbDevice.pull
def pull(self, device_filename, dest_file=None, timeout_ms=None): """Pull file from device. Arguments: device_filename: The filename on the device to pull. dest_file: If set, a filename or writable file-like object. timeout_ms: Expected timeout for the pull. Returns: The file data ...
python
def pull(self, device_filename, dest_file=None, timeout_ms=None): """Pull file from device. Arguments: device_filename: The filename on the device to pull. dest_file: If set, a filename or writable file-like object. timeout_ms: Expected timeout for the pull. Returns: The file data ...
[ "def", "pull", "(", "self", ",", "device_filename", ",", "dest_file", "=", "None", ",", "timeout_ms", "=", "None", ")", ":", "should_return_data", "=", "dest_file", "is", "None", "if", "isinstance", "(", "dest_file", ",", "six", ".", "string_types", ")", "...
Pull file from device. Arguments: device_filename: The filename on the device to pull. dest_file: If set, a filename or writable file-like object. timeout_ms: Expected timeout for the pull. Returns: The file data if dest_file is not set, None otherwise.
[ "Pull", "file", "from", "device", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_device.py#L153-L172
226,898
google/openhtf
openhtf/plugs/usb/adb_device.py
AdbDevice.list
def list(self, device_path, timeout_ms=None): """Yield filesync_service.DeviceFileStat objects for directory contents.""" return self.filesync_service.list( device_path, timeouts.PolledTimeout.from_millis(timeout_ms))
python
def list(self, device_path, timeout_ms=None): """Yield filesync_service.DeviceFileStat objects for directory contents.""" return self.filesync_service.list( device_path, timeouts.PolledTimeout.from_millis(timeout_ms))
[ "def", "list", "(", "self", ",", "device_path", ",", "timeout_ms", "=", "None", ")", ":", "return", "self", ".", "filesync_service", ".", "list", "(", "device_path", ",", "timeouts", ".", "PolledTimeout", ".", "from_millis", "(", "timeout_ms", ")", ")" ]
Yield filesync_service.DeviceFileStat objects for directory contents.
[ "Yield", "filesync_service", ".", "DeviceFileStat", "objects", "for", "directory", "contents", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_device.py#L174-L177
226,899
google/openhtf
openhtf/plugs/usb/adb_device.py
AdbDevice._check_remote_command
def _check_remote_command(self, destination, timeout_ms, success_msgs=None): """Open a stream to destination, check for remote errors. Used for reboot, remount, and root services. If this method returns, the command was successful, otherwise an appropriate error will have been raised. Args: ...
python
def _check_remote_command(self, destination, timeout_ms, success_msgs=None): """Open a stream to destination, check for remote errors. Used for reboot, remount, and root services. If this method returns, the command was successful, otherwise an appropriate error will have been raised. Args: ...
[ "def", "_check_remote_command", "(", "self", ",", "destination", ",", "timeout_ms", ",", "success_msgs", "=", "None", ")", ":", "timeout", "=", "timeouts", ".", "PolledTimeout", ".", "from_millis", "(", "timeout_ms", ")", "stream", "=", "self", ".", "_adb_conn...
Open a stream to destination, check for remote errors. Used for reboot, remount, and root services. If this method returns, the command was successful, otherwise an appropriate error will have been raised. Args: destination: Stream destination to open. timeout_ms: Timeout in milliseconds ...
[ "Open", "a", "stream", "to", "destination", "check", "for", "remote", "errors", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_device.py#L191-L224