partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
TeradataBulkLoad.cleanup
Drops any existing work tables, as returned by :meth:`~giraffez.load.TeradataBulkLoad.tables`. :raises `giraffez.TeradataPTError`: if a Teradata error ocurred
giraffez/load.py
def cleanup(self): """ Drops any existing work tables, as returned by :meth:`~giraffez.load.TeradataBulkLoad.tables`. :raises `giraffez.TeradataPTError`: if a Teradata error ocurred """ threads = [] for i, table in enumerate(filter(lambda x: self.mload.exists(x),...
def cleanup(self): """ Drops any existing work tables, as returned by :meth:`~giraffez.load.TeradataBulkLoad.tables`. :raises `giraffez.TeradataPTError`: if a Teradata error ocurred """ threads = [] for i, table in enumerate(filter(lambda x: self.mload.exists(x),...
[ "Drops", "any", "existing", "work", "tables", "as", "returned", "by", ":", "meth", ":", "~giraffez", ".", "load", ".", "TeradataBulkLoad", ".", "tables", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/load.py#L131-L145
[ "def", "cleanup", "(", "self", ")", ":", "threads", "=", "[", "]", "for", "i", ",", "table", "in", "enumerate", "(", "filter", "(", "lambda", "x", ":", "self", ".", "mload", ".", "exists", "(", "x", ")", ",", "self", ".", "tables", ")", ")", ":...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
TeradataBulkLoad.finish
Finishes the load job. Called automatically when the connection closes. :return: The exit code returned when applying rows to the table
giraffez/load.py
def finish(self): """ Finishes the load job. Called automatically when the connection closes. :return: The exit code returned when applying rows to the table """ if self.finished: return self.exit_code checkpoint_status = self.checkpoint() self.exit_c...
def finish(self): """ Finishes the load job. Called automatically when the connection closes. :return: The exit code returned when applying rows to the table """ if self.finished: return self.exit_code checkpoint_status = self.checkpoint() self.exit_c...
[ "Finishes", "the", "load", "job", ".", "Called", "automatically", "when", "the", "connection", "closes", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/load.py#L180-L200
[ "def", "finish", "(", "self", ")", ":", "if", "self", ".", "finished", ":", "return", "self", ".", "exit_code", "checkpoint_status", "=", "self", ".", "checkpoint", "(", ")", "self", ".", "exit_code", "=", "self", ".", "_exit_code", "(", ")", "if", "se...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
TeradataBulkLoad.from_file
Load from a file into the target table, handling each step of the load process. Can load from text files, and properly formatted giraffez archive files. In both cases, if Gzip compression is detected the file will be decompressed while reading and handled appropriately. The encoding is ...
giraffez/load.py
def from_file(self, filename, table=None, delimiter='|', null='NULL', panic=True, quotechar='"', parse_dates=False): """ Load from a file into the target table, handling each step of the load process. Can load from text files, and properly formatted giraffez archive ...
def from_file(self, filename, table=None, delimiter='|', null='NULL', panic=True, quotechar='"', parse_dates=False): """ Load from a file into the target table, handling each step of the load process. Can load from text files, and properly formatted giraffez archive ...
[ "Load", "from", "a", "file", "into", "the", "target", "table", "handling", "each", "step", "of", "the", "load", "process", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/load.py#L202-L267
[ "def", "from_file", "(", "self", ",", "filename", ",", "table", "=", "None", ",", "delimiter", "=", "'|'", ",", "null", "=", "'NULL'", ",", "panic", "=", "True", ",", "quotechar", "=", "'\"'", ",", "parse_dates", "=", "False", ")", ":", "if", "not", ...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
TeradataBulkLoad.put
Load a single row into the target table. :param list items: A list of values in the row corresponding to the fields specified by :code:`self.columns` :param bool panic: If :code:`True`, when an error is encountered it will be raised. Otherwise, the error will be logged and :code...
giraffez/load.py
def put(self, items, panic=True): """ Load a single row into the target table. :param list items: A list of values in the row corresponding to the fields specified by :code:`self.columns` :param bool panic: If :code:`True`, when an error is encountered it will be ...
def put(self, items, panic=True): """ Load a single row into the target table. :param list items: A list of values in the row corresponding to the fields specified by :code:`self.columns` :param bool panic: If :code:`True`, when an error is encountered it will be ...
[ "Load", "a", "single", "row", "into", "the", "target", "table", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/load.py#L269-L293
[ "def", "put", "(", "self", ",", "items", ",", "panic", "=", "True", ")", ":", "if", "not", "self", ".", "initiated", ":", "self", ".", "_initiate", "(", ")", "try", ":", "row_status", "=", "self", ".", "mload", ".", "put_row", "(", "self", ".", "...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
TeradataBulkLoad.release
Attempt release of target mload table. :raises `giraffez.errors.GiraffeError`: if table was not set by the constructor, the :code:`TeradataBulkLoad.table`, or :meth:`~giraffez.load.TeradataBulkLoad.from_file`.
giraffez/load.py
def release(self): """ Attempt release of target mload table. :raises `giraffez.errors.GiraffeError`: if table was not set by the constructor, the :code:`TeradataBulkLoad.table`, or :meth:`~giraffez.load.TeradataBulkLoad.from_file`. """ if self.table is N...
def release(self): """ Attempt release of target mload table. :raises `giraffez.errors.GiraffeError`: if table was not set by the constructor, the :code:`TeradataBulkLoad.table`, or :meth:`~giraffez.load.TeradataBulkLoad.from_file`. """ if self.table is N...
[ "Attempt", "release", "of", "target", "mload", "table", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/load.py#L304-L315
[ "def", "release", "(", "self", ")", ":", "if", "self", ".", "table", "is", "None", ":", "raise", "GiraffeError", "(", "\"Cannot release. Target table has not been set.\"", ")", "log", ".", "info", "(", "\"BulkLoad\"", ",", "\"Attempting release for table {}\"", ".",...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
TeradataBulkLoad.tables
The names of the work tables used for loading. :return: A list of four tables, each the name of the target table with the added suffixes, "_wt", "_log", "_e1", and "_e2" :raises `giraffez.errors.GiraffeError`: if table was not set by the constructor, the :code:`TeradataBulkLoad....
giraffez/load.py
def tables(self): """ The names of the work tables used for loading. :return: A list of four tables, each the name of the target table with the added suffixes, "_wt", "_log", "_e1", and "_e2" :raises `giraffez.errors.GiraffeError`: if table was not set by the con...
def tables(self): """ The names of the work tables used for loading. :return: A list of four tables, each the name of the target table with the added suffixes, "_wt", "_log", "_e1", and "_e2" :raises `giraffez.errors.GiraffeError`: if table was not set by the con...
[ "The", "names", "of", "the", "work", "tables", "used", "for", "loading", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/load.py#L322-L339
[ "def", "tables", "(", "self", ")", ":", "if", "self", ".", "table", "is", "None", ":", "raise", "GiraffeError", "(", "\"Target table has not been set.\"", ")", "return", "[", "\"{}_wt\"", ".", "format", "(", "self", ".", "table", ")", ",", "\"{}_log\"", "....
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
fix_compile
Monkey-patch compiler to allow for removal of default compiler flags.
setup.py
def fix_compile(remove_flags): """ Monkey-patch compiler to allow for removal of default compiler flags. """ import distutils.ccompiler def _fix_compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): ...
def fix_compile(remove_flags): """ Monkey-patch compiler to allow for removal of default compiler flags. """ import distutils.ccompiler def _fix_compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): ...
[ "Monkey", "-", "patch", "compiler", "to", "allow", "for", "removal", "of", "default", "compiler", "flags", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/setup.py#L40-L62
[ "def", "fix_compile", "(", "remove_flags", ")", ":", "import", "distutils", ".", "ccompiler", "def", "_fix_compile", "(", "self", ",", "sources", ",", "output_dir", "=", "None", ",", "macros", "=", "None", ",", "include_dirs", "=", "None", ",", "debug", "=...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
find_teradata_home
Attempts to find the Teradata install directory with the defaults for a given platform. Should always return `None` when the defaults are not present and the TERADATA_HOME environment variable wasn't explicitly set to the correct install location.
setup.py
def find_teradata_home(): """ Attempts to find the Teradata install directory with the defaults for a given platform. Should always return `None` when the defaults are not present and the TERADATA_HOME environment variable wasn't explicitly set to the correct install location. """ if platfo...
def find_teradata_home(): """ Attempts to find the Teradata install directory with the defaults for a given platform. Should always return `None` when the defaults are not present and the TERADATA_HOME environment variable wasn't explicitly set to the correct install location. """ if platfo...
[ "Attempts", "to", "find", "the", "Teradata", "install", "directory", "with", "the", "defaults", "for", "a", "given", "platform", ".", "Should", "always", "return", "None", "when", "the", "defaults", "are", "not", "present", "and", "the", "TERADATA_HOME", "envi...
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/setup.py#L76-L102
[ "def", "find_teradata_home", "(", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "'Windows'", ":", "# The default installation path for Windows is split between the", "# Windows directories for 32-bit/64-bit applications. It is", "# worth noting that Teradata archiecture...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Secret.get
Retrieve the decrypted value of a key in a giraffez configuration file. :param str key: The key used to lookup the encrypted value
giraffez/secret.py
def get(self, key): """ Retrieve the decrypted value of a key in a giraffez configuration file. :param str key: The key used to lookup the encrypted value """ if not key.startswith("secure.") and not key.startswith("connections."): key = "secure.{0}".format(k...
def get(self, key): """ Retrieve the decrypted value of a key in a giraffez configuration file. :param str key: The key used to lookup the encrypted value """ if not key.startswith("secure.") and not key.startswith("connections."): key = "secure.{0}".format(k...
[ "Retrieve", "the", "decrypted", "value", "of", "a", "key", "in", "a", "giraffez", "configuration", "file", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/secret.py#L39-L51
[ "def", "get", "(", "self", ",", "key", ")", ":", "if", "not", "key", ".", "startswith", "(", "\"secure.\"", ")", "and", "not", "key", ".", "startswith", "(", "\"connections.\"", ")", ":", "key", "=", "\"secure.{0}\"", ".", "format", "(", "key", ")", ...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Secret.set
Set a decrypted value by key in a giraffez configuration file. :param str key: The key used to lookup the encrypted value :param value: Value to set at the given key, can be any value that is YAML serializeable.
giraffez/secret.py
def set(self, key, value): """ Set a decrypted value by key in a giraffez configuration file. :param str key: The key used to lookup the encrypted value :param value: Value to set at the given key, can be any value that is YAML serializeable. """ if not key.s...
def set(self, key, value): """ Set a decrypted value by key in a giraffez configuration file. :param str key: The key used to lookup the encrypted value :param value: Value to set at the given key, can be any value that is YAML serializeable. """ if not key.s...
[ "Set", "a", "decrypted", "value", "by", "key", "in", "a", "giraffez", "configuration", "file", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/secret.py#L53-L64
[ "def", "set", "(", "self", ",", "key", ",", "value", ")", ":", "if", "not", "key", ".", "startswith", "(", "\"secure.\"", ")", ":", "key", "=", "\"secure.{0}\"", ".", "format", "(", "key", ")", "self", ".", "config", ".", "set_value", "(", "key", "...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
GiraffeShell.do_table
Display results in table format
giraffez/shell.py
def do_table(self, line): """Display results in table format""" if len(line) > 0: if line.strip().lower() == "on": log.write("Table ON") self.table_output = True return elif line.strip().lower() == "off": log.write("...
def do_table(self, line): """Display results in table format""" if len(line) > 0: if line.strip().lower() == "on": log.write("Table ON") self.table_output = True return elif line.strip().lower() == "off": log.write("...
[ "Display", "results", "in", "table", "format" ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/shell.py#L174-L185
[ "def", "do_table", "(", "self", ",", "line", ")", ":", "if", "len", "(", "line", ")", ">", "0", ":", "if", "line", ".", "strip", "(", ")", ".", "lower", "(", ")", "==", "\"on\"", ":", "log", ".", "write", "(", "\"Table ON\"", ")", "self", ".", ...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Cursor.to_dict
Sets the current encoder output to Python `dict` and returns the cursor. This makes it possible to set the output encoding and iterate over the results: .. code-block:: python with giraffez.Cmd() as cmd: for row in cmd.execute(query).to_dict(): ...
giraffez/cmd.py
def to_dict(self): """ Sets the current encoder output to Python `dict` and returns the cursor. This makes it possible to set the output encoding and iterate over the results: .. code-block:: python with giraffez.Cmd() as cmd: for row in cmd.execute...
def to_dict(self): """ Sets the current encoder output to Python `dict` and returns the cursor. This makes it possible to set the output encoding and iterate over the results: .. code-block:: python with giraffez.Cmd() as cmd: for row in cmd.execute...
[ "Sets", "the", "current", "encoder", "output", "to", "Python", "dict", "and", "returns", "the", "cursor", ".", "This", "makes", "it", "possible", "to", "set", "the", "output", "encoding", "and", "iterate", "over", "the", "results", ":" ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/cmd.py#L161-L182
[ "def", "to_dict", "(", "self", ")", ":", "self", ".", "conn", ".", "set_encoding", "(", "ROW_ENCODING_DICT", ")", "self", ".", "processor", "=", "lambda", "x", ",", "y", ":", "y", "return", "self" ]
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Cursor.to_list
Set the current encoder output to :class:`giraffez.Row` objects and returns the cursor. This is the default value so it is not necessary to select this unless the encoder settings have been changed already.
giraffez/cmd.py
def to_list(self): """ Set the current encoder output to :class:`giraffez.Row` objects and returns the cursor. This is the default value so it is not necessary to select this unless the encoder settings have been changed already. """ self.conn.set_encoding(ROW_EN...
def to_list(self): """ Set the current encoder output to :class:`giraffez.Row` objects and returns the cursor. This is the default value so it is not necessary to select this unless the encoder settings have been changed already. """ self.conn.set_encoding(ROW_EN...
[ "Set", "the", "current", "encoder", "output", "to", ":", "class", ":", "giraffez", ".", "Row", "objects", "and", "returns", "the", "cursor", ".", "This", "is", "the", "default", "value", "so", "it", "is", "not", "necessary", "to", "select", "this", "unle...
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/cmd.py#L184-L193
[ "def", "to_list", "(", "self", ")", ":", "self", ".", "conn", ".", "set_encoding", "(", "ROW_ENCODING_LIST", ")", "self", ".", "processor", "=", "lambda", "x", ",", "y", ":", "Row", "(", "x", ",", "y", ")", "return", "self" ]
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
TeradataCmd.execute
Execute commands using CLIv2. :param str command: The SQL command to be executed :param bool coerce_floats: Coerce Teradata decimal types into Python floats :param bool parse_dates: Parses Teradata datetime types into Python datetimes :param bool header: Include row header :para...
giraffez/cmd.py
def execute(self, command, coerce_floats=True, parse_dates=False, header=False, sanitize=True, silent=False, panic=None, multi_statement=False, prepare_only=False): """ Execute commands using CLIv2. :param str command: The SQL command to be executed :param bool coerce_float...
def execute(self, command, coerce_floats=True, parse_dates=False, header=False, sanitize=True, silent=False, panic=None, multi_statement=False, prepare_only=False): """ Execute commands using CLIv2. :param str command: The SQL command to be executed :param bool coerce_float...
[ "Execute", "commands", "using", "CLIv2", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/cmd.py#L263-L306
[ "def", "execute", "(", "self", ",", "command", ",", "coerce_floats", "=", "True", ",", "parse_dates", "=", "False", ",", "header", "=", "False", ",", "sanitize", "=", "True", ",", "silent", "=", "False", ",", "panic", "=", "None", ",", "multi_statement",...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
TeradataCmd.exists
Check that object (table or view) :code:`object_name` exists, by executing a :code:`show table object_name` query, followed by a :code:`show view object_name` query if :code:`object_name` is not a table. :param str object_name: The name of the object to check for existence. :param bool silent:...
giraffez/cmd.py
def exists(self, object_name, silent=False): """ Check that object (table or view) :code:`object_name` exists, by executing a :code:`show table object_name` query, followed by a :code:`show view object_name` query if :code:`object_name` is not a table. :param str object_name: The name ...
def exists(self, object_name, silent=False): """ Check that object (table or view) :code:`object_name` exists, by executing a :code:`show table object_name` query, followed by a :code:`show view object_name` query if :code:`object_name` is not a table. :param str object_name: The name ...
[ "Check", "that", "object", "(", "table", "or", "view", ")", ":", "code", ":", "object_name", "exists", "by", "executing", "a", ":", "code", ":", "show", "table", "object_name", "query", "followed", "by", "a", ":", "code", ":", "show", "view", "object_nam...
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/cmd.py#L308-L330
[ "def", "exists", "(", "self", ",", "object_name", ",", "silent", "=", "False", ")", ":", "try", ":", "self", ".", "execute", "(", "\"show table {}\"", ".", "format", "(", "object_name", ")", ",", "silent", "=", "silent", ")", "return", "True", "except", ...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
TeradataCmd.fetch_columns
Return the column information for :code:`table_name` by executing a :code:`select top 1 * from table_name` query. :param str table_name: The fully-qualified name of the table to retrieve schema for :param bool silent: Silence console logging (within this function only) :return: the columns of t...
giraffez/cmd.py
def fetch_columns(self, table_name, silent=False): """ Return the column information for :code:`table_name` by executing a :code:`select top 1 * from table_name` query. :param str table_name: The fully-qualified name of the table to retrieve schema for :param bool silent: Silence consol...
def fetch_columns(self, table_name, silent=False): """ Return the column information for :code:`table_name` by executing a :code:`select top 1 * from table_name` query. :param str table_name: The fully-qualified name of the table to retrieve schema for :param bool silent: Silence consol...
[ "Return", "the", "column", "information", "for", ":", "code", ":", "table_name", "by", "executing", "a", ":", "code", ":", "select", "top", "1", "*", "from", "table_name", "query", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/cmd.py#L332-L341
[ "def", "fetch_columns", "(", "self", ",", "table_name", ",", "silent", "=", "False", ")", ":", "return", "self", ".", "execute", "(", "\"select top 1 * from {}\"", ".", "format", "(", "table_name", ")", ",", "silent", "=", "silent", ",", "prepare_only", "=",...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
TeradataCmd.insert
Load a text file into the specified :code:`table_name` or Insert Python :code:`list` rows into the specified :code:`table_name` :param str table_name: The name of the destination table :param list/str rows: A list of rows **or** the name of an input file. Each row must be a :code:`list` of ...
giraffez/cmd.py
def insert(self, table_name, rows, fields=None, delimiter=None, null='NULL', parse_dates=False, quotechar='"'): """ Load a text file into the specified :code:`table_name` or Insert Python :code:`list` rows into the specified :code:`table_name` :param str table_name: The name of the destination ...
def insert(self, table_name, rows, fields=None, delimiter=None, null='NULL', parse_dates=False, quotechar='"'): """ Load a text file into the specified :code:`table_name` or Insert Python :code:`list` rows into the specified :code:`table_name` :param str table_name: The name of the destination ...
[ "Load", "a", "text", "file", "into", "the", "specified", ":", "code", ":", "table_name", "or", "Insert", "Python", ":", "code", ":", "list", "rows", "into", "the", "specified", ":", "code", ":", "table_name" ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/cmd.py#L343-L385
[ "def", "insert", "(", "self", ",", "table_name", ",", "rows", ",", "fields", "=", "None", ",", "delimiter", "=", "None", ",", "null", "=", "'NULL'", ",", "parse_dates", "=", "False", ",", "quotechar", "=", "'\"'", ")", ":", "if", "not", "isfile", "("...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Config.connections
Return a :code:`dict` of connections from the configuration settings. :raises `giraffez.errors.ConfigurationError`: if connections are not present
giraffez/config.py
def connections(self): """ Return a :code:`dict` of connections from the configuration settings. :raises `giraffez.errors.ConfigurationError`: if connections are not present """ if "connections" not in self.settings: raise ConfigurationError("Could not retrieve conne...
def connections(self): """ Return a :code:`dict` of connections from the configuration settings. :raises `giraffez.errors.ConfigurationError`: if connections are not present """ if "connections" not in self.settings: raise ConfigurationError("Could not retrieve conne...
[ "Return", "a", ":", "code", ":", "dict", "of", "connections", "from", "the", "configuration", "settings", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/config.py#L146-L154
[ "def", "connections", "(", "self", ")", ":", "if", "\"connections\"", "not", "in", "self", ".", "settings", ":", "raise", "ConfigurationError", "(", "\"Could not retrieve connections from config file '{}'.\"", ".", "format", "(", "self", ".", "_config_file", ")", ")...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Config.get_connection
Retrieve a connection by the given :code:`dsn`, or the default connection. :param str dsn: The name of the connection to retrieve. Defaults to :code:`None`, which retrieves the default connection. :return: A dict of connection settings :raises `giraffez.errors.ConfigurationError`: i...
giraffez/config.py
def get_connection(self, dsn=None): """ Retrieve a connection by the given :code:`dsn`, or the default connection. :param str dsn: The name of the connection to retrieve. Defaults to :code:`None`, which retrieves the default connection. :return: A dict of connection settings...
def get_connection(self, dsn=None): """ Retrieve a connection by the given :code:`dsn`, or the default connection. :param str dsn: The name of the connection to retrieve. Defaults to :code:`None`, which retrieves the default connection. :return: A dict of connection settings...
[ "Retrieve", "a", "connection", "by", "the", "given", ":", "code", ":", "dsn", "or", "the", "default", "connection", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/config.py#L174-L196
[ "def", "get_connection", "(", "self", ",", "dsn", "=", "None", ")", ":", "if", "dsn", "is", "None", ":", "dsn", "=", "self", ".", "connections", ".", "get", "(", "\"default\"", ",", "None", ")", "if", "dsn", "is", "None", ":", "raise", "Configuration...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Config.get_value
Retrieve a value from the configuration based on its key. The key may be nested. :param str key: A path to the value, with nested levels joined by '.' :param default: Value to return if the key does not exist (defaults to :code:`dict()`) :param bool decrypt: If :code:`True`, decrypt an ...
giraffez/config.py
def get_value(self, key, default={}, nested=True, decrypt=True): """ Retrieve a value from the configuration based on its key. The key may be nested. :param str key: A path to the value, with nested levels joined by '.' :param default: Value to return if the key does not exist (...
def get_value(self, key, default={}, nested=True, decrypt=True): """ Retrieve a value from the configuration based on its key. The key may be nested. :param str key: A path to the value, with nested levels joined by '.' :param default: Value to return if the key does not exist (...
[ "Retrieve", "a", "value", "from", "the", "configuration", "based", "on", "its", "key", ".", "The", "key", "may", "be", "nested", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/config.py#L198-L223
[ "def", "get_value", "(", "self", ",", "key", ",", "default", "=", "{", "}", ",", "nested", "=", "True", ",", "decrypt", "=", "True", ")", ":", "key", "=", "key", ".", "lstrip", "(", ")", "if", "key", ".", "endswith", "(", "\".\"", ")", ":", "ke...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Config.list_value
Return the contents of the configuration as a :code:`dict`. Depending on the structure of the YAML settings, the return value may contain nested :code:`dict` objects. :param bool decrypt: If :code:`True`, decrypt the contents before returning. :return: (potentially) nested :code:`dict` ...
giraffez/config.py
def list_value(self, decrypt=False): """ Return the contents of the configuration as a :code:`dict`. Depending on the structure of the YAML settings, the return value may contain nested :code:`dict` objects. :param bool decrypt: If :code:`True`, decrypt the contents before retur...
def list_value(self, decrypt=False): """ Return the contents of the configuration as a :code:`dict`. Depending on the structure of the YAML settings, the return value may contain nested :code:`dict` objects. :param bool decrypt: If :code:`True`, decrypt the contents before retur...
[ "Return", "the", "contents", "of", "the", "configuration", "as", "a", ":", "code", ":", "dict", ".", "Depending", "on", "the", "structure", "of", "the", "YAML", "settings", "the", "return", "value", "may", "contain", "nested", ":", "code", ":", "dict", "...
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/config.py#L225-L239
[ "def", "list_value", "(", "self", ",", "decrypt", "=", "False", ")", ":", "if", "decrypt", ":", "settings", "=", "self", ".", "decrypt", "(", "self", ".", "settings", ")", "else", ":", "settings", "=", "self", ".", "settings", "return", "yaml", ".", ...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Config.lock_connection
A class method to lock a connection (given by :code:`dsn`) in the specified configuration file. Automatically opens the file and writes to it before closing. :param str conf: The configuration file to modify :param str dsn: The name of the connection to lock :raises `giraffez.er...
giraffez/config.py
def lock_connection(cls, conf, dsn, key=None): """ A class method to lock a connection (given by :code:`dsn`) in the specified configuration file. Automatically opens the file and writes to it before closing. :param str conf: The configuration file to modify :param str d...
def lock_connection(cls, conf, dsn, key=None): """ A class method to lock a connection (given by :code:`dsn`) in the specified configuration file. Automatically opens the file and writes to it before closing. :param str conf: The configuration file to modify :param str d...
[ "A", "class", "method", "to", "lock", "a", "connection", "(", "given", "by", ":", "code", ":", "dsn", ")", "in", "the", "specified", "configuration", "file", ".", "Automatically", "opens", "the", "file", "and", "writes", "to", "it", "before", "closing", ...
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/config.py#L242-L264
[ "def", "lock_connection", "(", "cls", ",", "conf", ",", "dsn", ",", "key", "=", "None", ")", ":", "with", "Config", "(", "conf", ",", "\"w\"", ",", "key", ")", "as", "c", ":", "connection", "=", "c", ".", "get_connection", "(", "dsn", ")", "if", ...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Config.set_value
Set a value within the configuration based on its key. The key may be nested, any nested levels that do not exist prior to the final segment of the key path will be created. *Note*: In order to write changes to the file, ensure that :meth:`~giraffez.config.Config.write` is called prior t...
giraffez/config.py
def set_value(self, key, value): """ Set a value within the configuration based on its key. The key may be nested, any nested levels that do not exist prior to the final segment of the key path will be created. *Note*: In order to write changes to the file, ensure that :m...
def set_value(self, key, value): """ Set a value within the configuration based on its key. The key may be nested, any nested levels that do not exist prior to the final segment of the key path will be created. *Note*: In order to write changes to the file, ensure that :m...
[ "Set", "a", "value", "within", "the", "configuration", "based", "on", "its", "key", ".", "The", "key", "may", "be", "nested", "any", "nested", "levels", "that", "do", "not", "exist", "prior", "to", "the", "final", "segment", "of", "the", "key", "path", ...
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/config.py#L276-L303
[ "def", "set_value", "(", "self", ",", "key", ",", "value", ")", ":", "if", "key", ".", "endswith", "(", "\".\"", ")", ":", "key", "=", "key", "[", ":", "-", "1", "]", "path", "=", "key", ".", "split", "(", "\".\"", ")", "curr", "=", "self", "...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Config.unlock_connection
A class method to unlock a connection (given by :code:`dsn`) in the specified configuration file. Automatically opens the file and writes to it before closing. :param str conf: The configuration file to modify :param str dsn: The name of the connection to unlock :raises `giraffe...
giraffez/config.py
def unlock_connection(cls, conf, dsn, key=None): """ A class method to unlock a connection (given by :code:`dsn`) in the specified configuration file. Automatically opens the file and writes to it before closing. :param str conf: The configuration file to modify :param s...
def unlock_connection(cls, conf, dsn, key=None): """ A class method to unlock a connection (given by :code:`dsn`) in the specified configuration file. Automatically opens the file and writes to it before closing. :param str conf: The configuration file to modify :param s...
[ "A", "class", "method", "to", "unlock", "a", "connection", "(", "given", "by", ":", "code", ":", "dsn", ")", "in", "the", "specified", "configuration", "file", ".", "Automatically", "opens", "the", "file", "and", "writes", "to", "it", "before", "closing", ...
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/config.py#L306-L325
[ "def", "unlock_connection", "(", "cls", ",", "conf", ",", "dsn", ",", "key", "=", "None", ")", ":", "with", "Config", "(", "conf", ",", "\"w\"", ",", "key", ")", "as", "c", ":", "connection", "=", "c", ".", "connections", ".", "get", "(", "dsn", ...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Config.unset_value
Remove a value at the given key -- and any nested values -- from the configuration. *Note*: In order to write changes to the file, ensure that :meth:`~giraffez.config.Config.write` is called prior to exit. :param str key: A path to the value destination, with nested levels joined by '.'...
giraffez/config.py
def unset_value(self, key): """ Remove a value at the given key -- and any nested values -- from the configuration. *Note*: In order to write changes to the file, ensure that :meth:`~giraffez.config.Config.write` is called prior to exit. :param str key: A path to the val...
def unset_value(self, key): """ Remove a value at the given key -- and any nested values -- from the configuration. *Note*: In order to write changes to the file, ensure that :meth:`~giraffez.config.Config.write` is called prior to exit. :param str key: A path to the val...
[ "Remove", "a", "value", "at", "the", "given", "key", "--", "and", "any", "nested", "values", "--", "from", "the", "configuration", ".", "*", "Note", "*", ":", "In", "order", "to", "write", "changes", "to", "the", "file", "ensure", "that", ":", "meth", ...
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/config.py#L327-L349
[ "def", "unset_value", "(", "self", ",", "key", ")", ":", "if", "key", ".", "endswith", "(", "\".\"", ")", ":", "key", "=", "key", "[", ":", "-", "1", "]", "path", "=", "key", ".", "split", "(", "\".\"", ")", "curr", "=", "self", ".", "settings"...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Config.write
Save the current configuration to its file (as given by :code:`self._config_file`). Optionally, settings may be passed in to override the current settings before writing. Returns :code:`None` if the file could not be written to, either due to permissions, or if the :class:`~giraffez.config.Confi...
giraffez/config.py
def write(self, settings=None): """ Save the current configuration to its file (as given by :code:`self._config_file`). Optionally, settings may be passed in to override the current settings before writing. Returns :code:`None` if the file could not be written to, either due to p...
def write(self, settings=None): """ Save the current configuration to its file (as given by :code:`self._config_file`). Optionally, settings may be passed in to override the current settings before writing. Returns :code:`None` if the file could not be written to, either due to p...
[ "Save", "the", "current", "configuration", "to", "its", "file", "(", "as", "given", "by", ":", "code", ":", "self", ".", "_config_file", ")", ".", "Optionally", "settings", "may", "be", "passed", "in", "to", "override", "the", "current", "settings", "befor...
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/config.py#L351-L371
[ "def", "write", "(", "self", ",", "settings", "=", "None", ")", ":", "if", "\"r\"", "in", "self", ".", "mode", ":", "raise", "ConfigReadOnly", "(", "\"Cannot write Config while in 'r' mode\"", ")", "try", ":", "if", "settings", ":", "self", ".", "settings", ...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Config.write_default
A class method to write a default configuration file structure to a file. Note that the contents of the file will be overwritten if it already exists. :param str conf: The name of the file to write to. Defaults to :code:`None`, for ~/.girafferc :return: The content written to the file :...
giraffez/config.py
def write_default(self, conf=None): """ A class method to write a default configuration file structure to a file. Note that the contents of the file will be overwritten if it already exists. :param str conf: The name of the file to write to. Defaults to :code:`None`, for ~/.girafferc ...
def write_default(self, conf=None): """ A class method to write a default configuration file structure to a file. Note that the contents of the file will be overwritten if it already exists. :param str conf: The name of the file to write to. Defaults to :code:`None`, for ~/.girafferc ...
[ "A", "class", "method", "to", "write", "a", "default", "configuration", "file", "structure", "to", "a", "file", ".", "Note", "that", "the", "contents", "of", "the", "file", "will", "be", "overwritten", "if", "it", "already", "exists", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/config.py#L374-L389
[ "def", "write_default", "(", "self", ",", "conf", "=", "None", ")", ":", "if", "conf", "is", "None", ":", "conf", "=", "home_file", "(", "\".girafferc\"", ")", "contents", "=", "yaml", ".", "dump", "(", "default_config", ",", "default_flow_style", "=", "...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Columns.get
Retrieve a column from the list with name value :code:`column_name` :param str column_name: The name of the column to get :return: :class:`~giraffez.types.Column` with the specified name, or :code:`None` if it does not exist.
giraffez/types.py
def get(self, column_name): """ Retrieve a column from the list with name value :code:`column_name` :param str column_name: The name of the column to get :return: :class:`~giraffez.types.Column` with the specified name, or :code:`None` if it does not exist. """ column_na...
def get(self, column_name): """ Retrieve a column from the list with name value :code:`column_name` :param str column_name: The name of the column to get :return: :class:`~giraffez.types.Column` with the specified name, or :code:`None` if it does not exist. """ column_na...
[ "Retrieve", "a", "column", "from", "the", "list", "with", "name", "value", ":", "code", ":", "column_name" ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/types.py#L204-L215
[ "def", "get", "(", "self", ",", "column_name", ")", ":", "column_name", "=", "column_name", ".", "lower", "(", ")", "for", "c", "in", "self", ".", "columns", ":", "if", "c", ".", "name", "==", "column_name", ":", "return", "c", "return", "None" ]
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Columns.set_filter
Set the names of columns to be used when iterating through the list, retrieving names, etc. :param list names: A list of names to be used, or :code:`None` for all
giraffez/types.py
def set_filter(self, names=None): """ Set the names of columns to be used when iterating through the list, retrieving names, etc. :param list names: A list of names to be used, or :code:`None` for all """ _names = [] if names: for name in names: ...
def set_filter(self, names=None): """ Set the names of columns to be used when iterating through the list, retrieving names, etc. :param list names: A list of names to be used, or :code:`None` for all """ _names = [] if names: for name in names: ...
[ "Set", "the", "names", "of", "columns", "to", "be", "used", "when", "iterating", "through", "the", "list", "retrieving", "names", "etc", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/types.py#L233-L249
[ "def", "set_filter", "(", "self", ",", "names", "=", "None", ")", ":", "_names", "=", "[", "]", "if", "names", ":", "for", "name", "in", "names", ":", "_safe_name", "=", "safe_name", "(", "name", ")", "if", "_safe_name", "not", "in", "self", ".", "...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Columns.serialize
Serializes the columns into the giraffez archive header binary format:: 0 1 2 +------+------+------+------+------+------+------+------+ | Header | Header Data | | Length | | ...
giraffez/types.py
def serialize(self): """ Serializes the columns into the giraffez archive header binary format:: 0 1 2 +------+------+------+------+------+------+------+------+ | Header | Header Data | | Length | ...
def serialize(self): """ Serializes the columns into the giraffez archive header binary format:: 0 1 2 +------+------+------+------+------+------+------+------+ | Header | Header Data | | Length | ...
[ "Serializes", "the", "columns", "into", "the", "giraffez", "archive", "header", "binary", "format", "::" ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/types.py#L282-L344
[ "def", "serialize", "(", "self", ")", ":", "data", "=", "b\"\"", "for", "column", "in", "self", ":", "row", "=", "struct", ".", "pack", "(", "\"5H\"", ",", "column", ".", "type", ",", "column", ".", "length", ",", "column", ".", "precision", ",", "...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Columns.deserialize
Deserializes giraffez Archive header. See :meth:`~giraffez.types.Columns.serialize` for more information. :param str data: data in giraffez Archive format, to be deserialized :return: :class:`~giraffez.types.Columns` object decoded from data
giraffez/types.py
def deserialize(cls, data): """ Deserializes giraffez Archive header. See :meth:`~giraffez.types.Columns.serialize` for more information. :param str data: data in giraffez Archive format, to be deserialized :return: :class:`~giraffez.types.Columns` object decoded from data ...
def deserialize(cls, data): """ Deserializes giraffez Archive header. See :meth:`~giraffez.types.Columns.serialize` for more information. :param str data: data in giraffez Archive format, to be deserialized :return: :class:`~giraffez.types.Columns` object decoded from data ...
[ "Deserializes", "giraffez", "Archive", "header", ".", "See", ":", "meth", ":", "~giraffez", ".", "types", ".", "Columns", ".", "serialize", "for", "more", "information", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/types.py#L347-L364
[ "def", "deserialize", "(", "cls", ",", "data", ")", ":", "column_list", "=", "cls", "(", ")", "while", "data", ":", "tup", ",", "data", "=", "data", "[", ":", "10", "]", ",", "data", "[", "10", ":", "]", "column_type", ",", "length", ",", "prec",...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
Row.items
Represents the contents of the row as a :code:`dict` with the column names as keys, and the row's fields as values. :rtype: dict
giraffez/types.py
def items(self): """ Represents the contents of the row as a :code:`dict` with the column names as keys, and the row's fields as values. :rtype: dict """ return {k.name: v for k, v in zip(self.columns, self)}
def items(self): """ Represents the contents of the row as a :code:`dict` with the column names as keys, and the row's fields as values. :rtype: dict """ return {k.name: v for k, v in zip(self.columns, self)}
[ "Represents", "the", "contents", "of", "the", "row", "as", "a", ":", "code", ":", "dict", "with", "the", "column", "names", "as", "keys", "and", "the", "row", "s", "fields", "as", "values", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/types.py#L474-L481
[ "def", "items", "(", "self", ")", ":", "return", "{", "k", ".", "name", ":", "v", "for", "k", ",", "v", "in", "zip", "(", "self", ".", "columns", ",", "self", ")", "}" ]
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
TeradataBulkExport.query
Set the query to be run and initiate the connection with Teradata. Only necessary if the query/table name was not specified as an argument to the constructor of the instance. :param str query: Valid SQL query to be executed
giraffez/export.py
def query(self, query): """ Set the query to be run and initiate the connection with Teradata. Only necessary if the query/table name was not specified as an argument to the constructor of the instance. :param str query: Valid SQL query to be executed """ if quer...
def query(self, query): """ Set the query to be run and initiate the connection with Teradata. Only necessary if the query/table name was not specified as an argument to the constructor of the instance. :param str query: Valid SQL query to be executed """ if quer...
[ "Set", "the", "query", "to", "be", "run", "and", "initiate", "the", "connection", "with", "Teradata", ".", "Only", "necessary", "if", "the", "query", "/", "table", "name", "was", "not", "specified", "as", "an", "argument", "to", "the", "constructor", "of",...
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/export.py#L110-L149
[ "def", "query", "(", "self", ",", "query", ")", ":", "if", "query", "is", "None", ":", "return", "if", "log", ".", "level", ">=", "VERBOSE", ":", "self", ".", "options", "(", "\"query\"", ",", "query", ",", "6", ")", "else", ":", "self", ".", "op...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
TeradataBulkExport.to_archive
Writes export archive files in the Giraffez archive format. This takes a `giraffez.io.Writer` and writes archive chunks to file until all rows for a given statement have been exhausted. .. code-block:: python with giraffez.BulkExport("database.table_name") as export: ...
giraffez/export.py
def to_archive(self, writer): """ Writes export archive files in the Giraffez archive format. This takes a `giraffez.io.Writer` and writes archive chunks to file until all rows for a given statement have been exhausted. .. code-block:: python with giraffez.BulkExpor...
def to_archive(self, writer): """ Writes export archive files in the Giraffez archive format. This takes a `giraffez.io.Writer` and writes archive chunks to file until all rows for a given statement have been exhausted. .. code-block:: python with giraffez.BulkExpor...
[ "Writes", "export", "archive", "files", "in", "the", "Giraffez", "archive", "format", ".", "This", "takes", "a", "giraffez", ".", "io", ".", "Writer", "and", "writes", "archive", "chunks", "to", "file", "until", "all", "rows", "for", "a", "given", "stateme...
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/export.py#L151-L175
[ "def", "to_archive", "(", "self", ",", "writer", ")", ":", "if", "'b'", "not", "in", "writer", ".", "mode", ":", "raise", "GiraffeError", "(", "\"Archive writer must be in binary mode\"", ")", "writer", ".", "write", "(", "GIRAFFE_MAGIC", ")", "writer", ".", ...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
TeradataBulkExport.to_str
Sets the current encoder output to Python `str` and returns a row iterator. :param str null: The string representation of null values :param str delimiter: The string delimiting values in the output string :rtype: iterator (yields ``str``)
giraffez/export.py
def to_str(self, delimiter='|', null='NULL'): """ Sets the current encoder output to Python `str` and returns a row iterator. :param str null: The string representation of null values :param str delimiter: The string delimiting values in the output string :r...
def to_str(self, delimiter='|', null='NULL'): """ Sets the current encoder output to Python `str` and returns a row iterator. :param str null: The string representation of null values :param str delimiter: The string delimiting values in the output string :r...
[ "Sets", "the", "current", "encoder", "output", "to", "Python", "str", "and", "returns", "a", "row", "iterator", "." ]
capitalone/giraffez
python
https://github.com/capitalone/giraffez/blob/6b4d27eb1a1eaf188c6885c7364ef27e92b1b957/giraffez/export.py#L204-L219
[ "def", "to_str", "(", "self", ",", "delimiter", "=", "'|'", ",", "null", "=", "'NULL'", ")", ":", "self", ".", "export", ".", "set_null", "(", "null", ")", "self", ".", "export", ".", "set_delimiter", "(", "delimiter", ")", "self", ".", "options", "(...
6b4d27eb1a1eaf188c6885c7364ef27e92b1b957
test
float_with_multiplier
Convert string with optional k, M, G, T multiplier to float
soapypower/__main__.py
def float_with_multiplier(string): """Convert string with optional k, M, G, T multiplier to float""" match = re_float_with_multiplier.search(string) if not match or not match.group('num'): raise ValueError('String "{}" is not numeric!'.format(string)) num = float(match.group('num')) multi =...
def float_with_multiplier(string): """Convert string with optional k, M, G, T multiplier to float""" match = re_float_with_multiplier.search(string) if not match or not match.group('num'): raise ValueError('String "{}" is not numeric!'.format(string)) num = float(match.group('num')) multi =...
[ "Convert", "string", "with", "optional", "k", "M", "G", "T", "multiplier", "to", "float" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/__main__.py#L15-L28
[ "def", "float_with_multiplier", "(", "string", ")", ":", "match", "=", "re_float_with_multiplier", ".", "search", "(", "string", ")", "if", "not", "match", "or", "not", "match", ".", "group", "(", "'num'", ")", ":", "raise", "ValueError", "(", "'String \"{}\...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
specific_gains
Convert string with gains of individual amplification elements to dict
soapypower/__main__.py
def specific_gains(string): """Convert string with gains of individual amplification elements to dict""" if not string: return {} gains = {} for gain in string.split(','): amp_name, value = gain.split('=') gains[amp_name.strip()] = float(value.strip()) return gains
def specific_gains(string): """Convert string with gains of individual amplification elements to dict""" if not string: return {} gains = {} for gain in string.split(','): amp_name, value = gain.split('=') gains[amp_name.strip()] = float(value.strip()) return gains
[ "Convert", "string", "with", "gains", "of", "individual", "amplification", "elements", "to", "dict" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/__main__.py#L36-L45
[ "def", "specific_gains", "(", "string", ")", ":", "if", "not", "string", ":", "return", "{", "}", "gains", "=", "{", "}", "for", "gain", "in", "string", ".", "split", "(", "','", ")", ":", "amp_name", ",", "value", "=", "gain", ".", "split", "(", ...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
device_settings
Convert string with SoapySDR device settings to dict
soapypower/__main__.py
def device_settings(string): """Convert string with SoapySDR device settings to dict""" if not string: return {} settings = {} for setting in string.split(','): setting_name, value = setting.split('=') settings[setting_name.strip()] = value.strip() return settings
def device_settings(string): """Convert string with SoapySDR device settings to dict""" if not string: return {} settings = {} for setting in string.split(','): setting_name, value = setting.split('=') settings[setting_name.strip()] = value.strip() return settings
[ "Convert", "string", "with", "SoapySDR", "device", "settings", "to", "dict" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/__main__.py#L48-L57
[ "def", "device_settings", "(", "string", ")", ":", "if", "not", "string", ":", "return", "{", "}", "settings", "=", "{", "}", "for", "setting", "in", "string", ".", "split", "(", "','", ")", ":", "setting_name", ",", "value", "=", "setting", ".", "sp...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
wrap
Wrap text to terminal width with default indentation
soapypower/__main__.py
def wrap(text, indent=' '): """Wrap text to terminal width with default indentation""" wrapper = textwrap.TextWrapper( width=int(os.environ.get('COLUMNS', 80)), initial_indent=indent, subsequent_indent=indent ) return '\n'.join(wrapper.wrap(text))
def wrap(text, indent=' '): """Wrap text to terminal width with default indentation""" wrapper = textwrap.TextWrapper( width=int(os.environ.get('COLUMNS', 80)), initial_indent=indent, subsequent_indent=indent ) return '\n'.join(wrapper.wrap(text))
[ "Wrap", "text", "to", "terminal", "width", "with", "default", "indentation" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/__main__.py#L60-L67
[ "def", "wrap", "(", "text", ",", "indent", "=", "' '", ")", ":", "wrapper", "=", "textwrap", ".", "TextWrapper", "(", "width", "=", "int", "(", "os", ".", "environ", ".", "get", "(", "'COLUMNS'", ",", "80", ")", ")", ",", "initial_indent", "=", ...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
detect_devices
Returns detected SoapySDR devices
soapypower/__main__.py
def detect_devices(soapy_args=''): """Returns detected SoapySDR devices""" devices = simplesoapy.detect_devices(soapy_args, as_string=True) text = [] text.append('Detected SoapySDR devices:') if devices: for i, d in enumerate(devices): text.append(' {}'.format(d)) else: ...
def detect_devices(soapy_args=''): """Returns detected SoapySDR devices""" devices = simplesoapy.detect_devices(soapy_args, as_string=True) text = [] text.append('Detected SoapySDR devices:') if devices: for i, d in enumerate(devices): text.append(' {}'.format(d)) else: ...
[ "Returns", "detected", "SoapySDR", "devices" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/__main__.py#L70-L80
[ "def", "detect_devices", "(", "soapy_args", "=", "''", ")", ":", "devices", "=", "simplesoapy", ".", "detect_devices", "(", "soapy_args", ",", "as_string", "=", "True", ")", "text", "=", "[", "]", "text", ".", "append", "(", "'Detected SoapySDR devices:'", "...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
device_info
Returns info about selected SoapySDR device
soapypower/__main__.py
def device_info(soapy_args=''): """Returns info about selected SoapySDR device""" text = [] try: device = simplesoapy.SoapyDevice(soapy_args) text.append('Selected device: {}'.format(device.hardware)) text.append(' Available RX channels:') text.append(' {}'.format(', '.jo...
def device_info(soapy_args=''): """Returns info about selected SoapySDR device""" text = [] try: device = simplesoapy.SoapyDevice(soapy_args) text.append('Selected device: {}'.format(device.hardware)) text.append(' Available RX channels:') text.append(' {}'.format(', '.jo...
[ "Returns", "info", "about", "selected", "SoapySDR", "device" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/__main__.py#L83-L129
[ "def", "device_info", "(", "soapy_args", "=", "''", ")", ":", "text", "=", "[", "]", "try", ":", "device", "=", "simplesoapy", ".", "SoapyDevice", "(", "soapy_args", ")", "text", ".", "append", "(", "'Selected device: {}'", ".", "format", "(", "device", ...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
setup_argument_parser
Setup command line parser
soapypower/__main__.py
def setup_argument_parser(): """Setup command line parser""" # Fix help formatter width if 'COLUMNS' not in os.environ: os.environ['COLUMNS'] = str(shutil.get_terminal_size().columns) parser = argparse.ArgumentParser( prog='soapy_power', formatter_class=argparse.RawDescriptionHe...
def setup_argument_parser(): """Setup command line parser""" # Fix help formatter width if 'COLUMNS' not in os.environ: os.environ['COLUMNS'] = str(shutil.get_terminal_size().columns) parser = argparse.ArgumentParser( prog='soapy_power', formatter_class=argparse.RawDescriptionHe...
[ "Setup", "command", "line", "parser" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/__main__.py#L132-L275
[ "def", "setup_argument_parser", "(", ")", ":", "# Fix help formatter width", "if", "'COLUMNS'", "not", "in", "os", ".", "environ", ":", "os", ".", "environ", "[", "'COLUMNS'", "]", "=", "str", "(", "shutil", ".", "get_terminal_size", "(", ")", ".", "columns"...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
PSD.set_center_freq
Set center frequency and clear averaged PSD data
soapypower/psd.py
def set_center_freq(self, center_freq): """Set center frequency and clear averaged PSD data""" psd_state = { 'repeats': 0, 'freq_array': self._base_freq_array + self._lnb_lo + center_freq, 'pwr_array': None, 'update_lock': threading.Lock(), 'fu...
def set_center_freq(self, center_freq): """Set center frequency and clear averaged PSD data""" psd_state = { 'repeats': 0, 'freq_array': self._base_freq_array + self._lnb_lo + center_freq, 'pwr_array': None, 'update_lock': threading.Lock(), 'fu...
[ "Set", "center", "frequency", "and", "clear", "averaged", "PSD", "data" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/psd.py#L35-L44
[ "def", "set_center_freq", "(", "self", ",", "center_freq", ")", ":", "psd_state", "=", "{", "'repeats'", ":", "0", ",", "'freq_array'", ":", "self", ".", "_base_freq_array", "+", "self", ".", "_lnb_lo", "+", "center_freq", ",", "'pwr_array'", ":", "None", ...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
PSD.result
Return freqs and averaged PSD for given center frequency
soapypower/psd.py
def result(self, psd_state): """Return freqs and averaged PSD for given center frequency""" freq_array = numpy.fft.fftshift(psd_state['freq_array']) pwr_array = numpy.fft.fftshift(psd_state['pwr_array']) if self._crop_factor: crop_bins_half = round((self._crop_factor * self....
def result(self, psd_state): """Return freqs and averaged PSD for given center frequency""" freq_array = numpy.fft.fftshift(psd_state['freq_array']) pwr_array = numpy.fft.fftshift(psd_state['pwr_array']) if self._crop_factor: crop_bins_half = round((self._crop_factor * self....
[ "Return", "freqs", "and", "averaged", "PSD", "for", "given", "center", "frequency" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/psd.py#L46-L62
[ "def", "result", "(", "self", ",", "psd_state", ")", ":", "freq_array", "=", "numpy", ".", "fft", ".", "fftshift", "(", "psd_state", "[", "'freq_array'", "]", ")", "pwr_array", "=", "numpy", ".", "fft", ".", "fftshift", "(", "psd_state", "[", "'pwr_array...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
PSD.wait_for_result
Wait for all PSD threads to finish and return result
soapypower/psd.py
def wait_for_result(self, psd_state): """Wait for all PSD threads to finish and return result""" if len(psd_state['futures']) > 1: concurrent.futures.wait(psd_state['futures']) elif psd_state['futures']: psd_state['futures'][0].result() return self.result(psd_stat...
def wait_for_result(self, psd_state): """Wait for all PSD threads to finish and return result""" if len(psd_state['futures']) > 1: concurrent.futures.wait(psd_state['futures']) elif psd_state['futures']: psd_state['futures'][0].result() return self.result(psd_stat...
[ "Wait", "for", "all", "PSD", "threads", "to", "finish", "and", "return", "result" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/psd.py#L64-L70
[ "def", "wait_for_result", "(", "self", ",", "psd_state", ")", ":", "if", "len", "(", "psd_state", "[", "'futures'", "]", ")", ">", "1", ":", "concurrent", ".", "futures", ".", "wait", "(", "psd_state", "[", "'futures'", "]", ")", "elif", "psd_state", "...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
PSD.update
Compute PSD from samples and update average for given center frequency
soapypower/psd.py
def update(self, psd_state, samples_array): """Compute PSD from samples and update average for given center frequency""" freq_array, pwr_array = simplespectral.welch(samples_array, self._sample_rate, nperseg=self._bins, window=self._fft_window, noverl...
def update(self, psd_state, samples_array): """Compute PSD from samples and update average for given center frequency""" freq_array, pwr_array = simplespectral.welch(samples_array, self._sample_rate, nperseg=self._bins, window=self._fft_window, noverl...
[ "Compute", "PSD", "from", "samples", "and", "update", "average", "for", "given", "center", "frequency" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/psd.py#L80-L94
[ "def", "update", "(", "self", ",", "psd_state", ",", "samples_array", ")", ":", "freq_array", ",", "pwr_array", "=", "simplespectral", ".", "welch", "(", "samples_array", ",", "self", ".", "_sample_rate", ",", "nperseg", "=", "self", ".", "_bins", ",", "wi...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
PSD.update_async
Compute PSD from samples and update average for given center frequency (asynchronously in another thread)
soapypower/psd.py
def update_async(self, psd_state, samples_array): """Compute PSD from samples and update average for given center frequency (asynchronously in another thread)""" future = self._executor.submit(self.update, psd_state, samples_array) future.add_done_callback(self._release_future_memory) ps...
def update_async(self, psd_state, samples_array): """Compute PSD from samples and update average for given center frequency (asynchronously in another thread)""" future = self._executor.submit(self.update, psd_state, samples_array) future.add_done_callback(self._release_future_memory) ps...
[ "Compute", "PSD", "from", "samples", "and", "update", "average", "for", "given", "center", "frequency", "(", "asynchronously", "in", "another", "thread", ")" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/psd.py#L96-L101
[ "def", "update_async", "(", "self", ",", "psd_state", ",", "samples_array", ")", ":", "future", "=", "self", ".", "_executor", ".", "submit", "(", "self", ".", "update", ",", "psd_state", ",", "samples_array", ")", "future", ".", "add_done_callback", "(", ...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
BaseWriter.write_async
Write PSD of one frequncy hop (asynchronously in another thread)
soapypower/writer.py
def write_async(self, psd_data_or_future, time_start, time_stop, samples): """Write PSD of one frequncy hop (asynchronously in another thread)""" return self._executor.submit(self.write, psd_data_or_future, time_start, time_stop, samples)
def write_async(self, psd_data_or_future, time_start, time_stop, samples): """Write PSD of one frequncy hop (asynchronously in another thread)""" return self._executor.submit(self.write, psd_data_or_future, time_start, time_stop, samples)
[ "Write", "PSD", "of", "one", "frequncy", "hop", "(", "asynchronously", "in", "another", "thread", ")" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/writer.py#L44-L46
[ "def", "write_async", "(", "self", ",", "psd_data_or_future", ",", "time_start", ",", "time_stop", ",", "samples", ")", ":", "return", "self", ".", "_executor", ".", "submit", "(", "self", ".", "write", ",", "psd_data_or_future", ",", "time_start", ",", "tim...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
SoapyPowerBinFormat.read
Read data from file-like object
soapypower/writer.py
def read(self, f): """Read data from file-like object""" magic = f.read(len(self.magic)) if not magic: return None if magic != self.magic: raise ValueError('Magic bytes not found! Read data: {}'.format(magic)) header = self.header._make( self....
def read(self, f): """Read data from file-like object""" magic = f.read(len(self.magic)) if not magic: return None if magic != self.magic: raise ValueError('Magic bytes not found! Read data: {}'.format(magic)) header = self.header._make( self....
[ "Read", "data", "from", "file", "-", "like", "object" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/writer.py#L69-L81
[ "def", "read", "(", "self", ",", "f", ")", ":", "magic", "=", "f", ".", "read", "(", "len", "(", "self", ".", "magic", ")", ")", "if", "not", "magic", ":", "return", "None", "if", "magic", "!=", "self", ".", "magic", ":", "raise", "ValueError", ...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
SoapyPowerBinFormat.write
Write data to file-like object
soapypower/writer.py
def write(self, f, time_start, time_stop, start, stop, step, samples, pwr_array): """Write data to file-like object""" f.write(self.magic) f.write(self.header_struct.pack( self.version, time_start, time_stop, start, stop, step, samples, pwr_array.nbytes )) #pwr_array....
def write(self, f, time_start, time_stop, start, stop, step, samples, pwr_array): """Write data to file-like object""" f.write(self.magic) f.write(self.header_struct.pack( self.version, time_start, time_stop, start, stop, step, samples, pwr_array.nbytes )) #pwr_array....
[ "Write", "data", "to", "file", "-", "like", "object" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/writer.py#L83-L91
[ "def", "write", "(", "self", ",", "f", ",", "time_start", ",", "time_stop", ",", "start", ",", "stop", ",", "step", ",", "samples", ",", "pwr_array", ")", ":", "f", ".", "write", "(", "self", ".", "magic", ")", "f", ".", "write", "(", "self", "."...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
SoapyPowerBinWriter.write
Write PSD of one frequency hop
soapypower/writer.py
def write(self, psd_data_or_future, time_start, time_stop, samples): """Write PSD of one frequency hop""" try: # Wait for result of future f_array, pwr_array = psd_data_or_future.result() except AttributeError: f_array, pwr_array = psd_data_or_future ...
def write(self, psd_data_or_future, time_start, time_stop, samples): """Write PSD of one frequency hop""" try: # Wait for result of future f_array, pwr_array = psd_data_or_future.result() except AttributeError: f_array, pwr_array = psd_data_or_future ...
[ "Write", "PSD", "of", "one", "frequency", "hop" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/writer.py#L104-L125
[ "def", "write", "(", "self", ",", "psd_data_or_future", ",", "time_start", ",", "time_stop", ",", "samples", ")", ":", "try", ":", "# Wait for result of future", "f_array", ",", "pwr_array", "=", "psd_data_or_future", ".", "result", "(", ")", "except", "Attribut...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
RtlPowerFftwWriter.write
Write PSD of one frequency hop
soapypower/writer.py
def write(self, psd_data_or_future, time_start, time_stop, samples): """Write PSD of one frequency hop""" try: # Wait for result of future f_array, pwr_array = psd_data_or_future.result() except AttributeError: f_array, pwr_array = psd_data_or_future ...
def write(self, psd_data_or_future, time_start, time_stop, samples): """Write PSD of one frequency hop""" try: # Wait for result of future f_array, pwr_array = psd_data_or_future.result() except AttributeError: f_array, pwr_array = psd_data_or_future ...
[ "Write", "PSD", "of", "one", "frequency", "hop" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/writer.py#L138-L156
[ "def", "write", "(", "self", ",", "psd_data_or_future", ",", "time_start", ",", "time_stop", ",", "samples", ")", ":", "try", ":", "# Wait for result of future", "f_array", ",", "pwr_array", "=", "psd_data_or_future", ".", "result", "(", ")", "except", "Attribut...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
RtlPowerWriter.write
Write PSD of one frequency hop
soapypower/writer.py
def write(self, psd_data_or_future, time_start, time_stop, samples): """Write PSD of one frequency hop""" try: # Wait for result of future f_array, pwr_array = psd_data_or_future.result() except AttributeError: f_array, pwr_array = psd_data_or_future ...
def write(self, psd_data_or_future, time_start, time_stop, samples): """Write PSD of one frequency hop""" try: # Wait for result of future f_array, pwr_array = psd_data_or_future.result() except AttributeError: f_array, pwr_array = psd_data_or_future ...
[ "Write", "PSD", "of", "one", "frequency", "hop" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/writer.py#L170-L188
[ "def", "write", "(", "self", ",", "psd_data_or_future", ",", "time_start", ",", "time_stop", ",", "samples", ")", ":", "try", ":", "# Wait for result of future", "f_array", ",", "pwr_array", "=", "psd_data_or_future", ".", "result", "(", ")", "except", "Attribut...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
ThreadPoolExecutor.submit
Submits a callable to be executed with the given arguments. Count maximum reached work queue size in ThreadPoolExecutor.max_queue_size_reached.
soapypower/threadpool.py
def submit(self, fn, *args, **kwargs): """Submits a callable to be executed with the given arguments. Count maximum reached work queue size in ThreadPoolExecutor.max_queue_size_reached. """ future = super().submit(fn, *args, **kwargs) work_queue_size = self._work_queue.qsize() ...
def submit(self, fn, *args, **kwargs): """Submits a callable to be executed with the given arguments. Count maximum reached work queue size in ThreadPoolExecutor.max_queue_size_reached. """ future = super().submit(fn, *args, **kwargs) work_queue_size = self._work_queue.qsize() ...
[ "Submits", "a", "callable", "to", "be", "executed", "with", "the", "given", "arguments", "." ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/threadpool.py#L14-L23
[ "def", "submit", "(", "self", ",", "fn", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "future", "=", "super", "(", ")", ".", "submit", "(", "fn", ",", "*", "args", ",", "*", "*", "kwargs", ")", "work_queue_size", "=", "self", ".", "_wor...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
SoapyPower.nearest_bins
Return nearest number of FFT bins (even or power of two)
soapypower/power.py
def nearest_bins(self, bins, even=False, pow2=False): """Return nearest number of FFT bins (even or power of two)""" if pow2: bins_log2 = math.log(bins, 2) if bins_log2 % 1 != 0: bins = 2**math.ceil(bins_log2) logger.warning('number of FFT bins sho...
def nearest_bins(self, bins, even=False, pow2=False): """Return nearest number of FFT bins (even or power of two)""" if pow2: bins_log2 = math.log(bins, 2) if bins_log2 % 1 != 0: bins = 2**math.ceil(bins_log2) logger.warning('number of FFT bins sho...
[ "Return", "nearest", "number", "of", "FFT", "bins", "(", "even", "or", "power", "of", "two", ")" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/power.py#L59-L71
[ "def", "nearest_bins", "(", "self", ",", "bins", ",", "even", "=", "False", ",", "pow2", "=", "False", ")", ":", "if", "pow2", ":", "bins_log2", "=", "math", ".", "log", "(", "bins", ",", "2", ")", "if", "bins_log2", "%", "1", "!=", "0", ":", "...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
SoapyPower.nearest_overlap
Return nearest overlap/crop factor based on number of bins
soapypower/power.py
def nearest_overlap(self, overlap, bins): """Return nearest overlap/crop factor based on number of bins""" bins_overlap = overlap * bins if bins_overlap % 2 != 0: bins_overlap = math.ceil(bins_overlap / 2) * 2 overlap = bins_overlap / bins logger.warning('numb...
def nearest_overlap(self, overlap, bins): """Return nearest overlap/crop factor based on number of bins""" bins_overlap = overlap * bins if bins_overlap % 2 != 0: bins_overlap = math.ceil(bins_overlap / 2) * 2 overlap = bins_overlap / bins logger.warning('numb...
[ "Return", "nearest", "overlap", "/", "crop", "factor", "based", "on", "number", "of", "bins" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/power.py#L73-L81
[ "def", "nearest_overlap", "(", "self", ",", "overlap", ",", "bins", ")", ":", "bins_overlap", "=", "overlap", "*", "bins", "if", "bins_overlap", "%", "2", "!=", "0", ":", "bins_overlap", "=", "math", ".", "ceil", "(", "bins_overlap", "/", "2", ")", "*"...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
SoapyPower.time_to_repeats
Convert integration time to number of repeats
soapypower/power.py
def time_to_repeats(self, bins, integration_time): """Convert integration time to number of repeats""" return math.ceil((self.device.sample_rate * integration_time) / bins)
def time_to_repeats(self, bins, integration_time): """Convert integration time to number of repeats""" return math.ceil((self.device.sample_rate * integration_time) / bins)
[ "Convert", "integration", "time", "to", "number", "of", "repeats" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/power.py#L91-L93
[ "def", "time_to_repeats", "(", "self", ",", "bins", ",", "integration_time", ")", ":", "return", "math", ".", "ceil", "(", "(", "self", ".", "device", ".", "sample_rate", "*", "integration_time", ")", "/", "bins", ")" ]
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
SoapyPower.freq_plan
Returns list of frequencies for frequency hopping
soapypower/power.py
def freq_plan(self, min_freq, max_freq, bins, overlap=0, quiet=False): """Returns list of frequencies for frequency hopping""" bin_size = self.bins_to_bin_size(bins) bins_crop = round((1 - overlap) * bins) sample_rate_crop = (1 - overlap) * self.device.sample_rate freq_range = m...
def freq_plan(self, min_freq, max_freq, bins, overlap=0, quiet=False): """Returns list of frequencies for frequency hopping""" bin_size = self.bins_to_bin_size(bins) bins_crop = round((1 - overlap) * bins) sample_rate_crop = (1 - overlap) * self.device.sample_rate freq_range = m...
[ "Returns", "list", "of", "frequencies", "for", "frequency", "hopping" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/power.py#L99-L139
[ "def", "freq_plan", "(", "self", ",", "min_freq", ",", "max_freq", ",", "bins", ",", "overlap", "=", "0", ",", "quiet", "=", "False", ")", ":", "bin_size", "=", "self", ".", "bins_to_bin_size", "(", "bins", ")", "bins_crop", "=", "round", "(", "(", "...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
SoapyPower.create_buffer
Create buffer for reading samples
soapypower/power.py
def create_buffer(self, bins, repeats, base_buffer_size, max_buffer_size=0): """Create buffer for reading samples""" samples = bins * repeats buffer_repeats = 1 buffer_size = math.ceil(samples / base_buffer_size) * base_buffer_size if not max_buffer_size: # Max buffe...
def create_buffer(self, bins, repeats, base_buffer_size, max_buffer_size=0): """Create buffer for reading samples""" samples = bins * repeats buffer_repeats = 1 buffer_size = math.ceil(samples / base_buffer_size) * base_buffer_size if not max_buffer_size: # Max buffe...
[ "Create", "buffer", "for", "reading", "samples" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/power.py#L141-L173
[ "def", "create_buffer", "(", "self", ",", "bins", ",", "repeats", ",", "base_buffer_size", ",", "max_buffer_size", "=", "0", ")", ":", "samples", "=", "bins", "*", "repeats", "buffer_repeats", "=", "1", "buffer_size", "=", "math", ".", "ceil", "(", "sample...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
SoapyPower.setup
Prepare samples buffer and start streaming samples from device
soapypower/power.py
def setup(self, bins, repeats, base_buffer_size=0, max_buffer_size=0, fft_window='hann', fft_overlap=0.5, crop_factor=0, log_scale=True, remove_dc=False, detrend=None, lnb_lo=0, tune_delay=0, reset_stream=False, max_threads=0, max_queue_size=0): """Prepare samples buffer and start st...
def setup(self, bins, repeats, base_buffer_size=0, max_buffer_size=0, fft_window='hann', fft_overlap=0.5, crop_factor=0, log_scale=True, remove_dc=False, detrend=None, lnb_lo=0, tune_delay=0, reset_stream=False, max_threads=0, max_queue_size=0): """Prepare samples buffer and start st...
[ "Prepare", "samples", "buffer", "and", "start", "streaming", "samples", "from", "device" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/power.py#L175-L195
[ "def", "setup", "(", "self", ",", "bins", ",", "repeats", ",", "base_buffer_size", "=", "0", ",", "max_buffer_size", "=", "0", ",", "fft_window", "=", "'hann'", ",", "fft_overlap", "=", "0.5", ",", "crop_factor", "=", "0", ",", "log_scale", "=", "True", ...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
SoapyPower.stop
Stop streaming samples from device and delete samples buffer
soapypower/power.py
def stop(self): """Stop streaming samples from device and delete samples buffer""" if not self.device.is_streaming: return self.device.stop_stream() self._writer.close() self._bins = None self._repeats = None self._base_buffer_size = None sel...
def stop(self): """Stop streaming samples from device and delete samples buffer""" if not self.device.is_streaming: return self.device.stop_stream() self._writer.close() self._bins = None self._repeats = None self._base_buffer_size = None sel...
[ "Stop", "streaming", "samples", "from", "device", "and", "delete", "samples", "buffer" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/power.py#L197-L214
[ "def", "stop", "(", "self", ")", ":", "if", "not", "self", ".", "device", ".", "is_streaming", ":", "return", "self", ".", "device", ".", "stop_stream", "(", ")", "self", ".", "_writer", ".", "close", "(", ")", "self", ".", "_bins", "=", "None", "s...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
SoapyPower.psd
Tune to specified center frequency and compute Power Spectral Density
soapypower/power.py
def psd(self, freq): """Tune to specified center frequency and compute Power Spectral Density""" if not self.device.is_streaming: raise RuntimeError('Streaming is not initialized, you must run setup() first!') # Tune to new frequency in main thread logger.debug(' Frequency ...
def psd(self, freq): """Tune to specified center frequency and compute Power Spectral Density""" if not self.device.is_streaming: raise RuntimeError('Streaming is not initialized, you must run setup() first!') # Tune to new frequency in main thread logger.debug(' Frequency ...
[ "Tune", "to", "specified", "center", "frequency", "and", "compute", "Power", "Spectral", "Density" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/power.py#L216-L272
[ "def", "psd", "(", "self", ",", "freq", ")", ":", "if", "not", "self", ".", "device", ".", "is_streaming", ":", "raise", "RuntimeError", "(", "'Streaming is not initialized, you must run setup() first!'", ")", "# Tune to new frequency in main thread", "logger", ".", "...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
SoapyPower.sweep
Sweep spectrum using frequency hopping
soapypower/power.py
def sweep(self, min_freq, max_freq, bins, repeats, runs=0, time_limit=0, overlap=0, fft_window='hann', fft_overlap=0.5, crop=False, log_scale=True, remove_dc=False, detrend=None, lnb_lo=0, tune_delay=0, reset_stream=False, base_buffer_size=0, max_buffer_size=0, max_threads=0, max_queue_size=...
def sweep(self, min_freq, max_freq, bins, repeats, runs=0, time_limit=0, overlap=0, fft_window='hann', fft_overlap=0.5, crop=False, log_scale=True, remove_dc=False, detrend=None, lnb_lo=0, tune_delay=0, reset_stream=False, base_buffer_size=0, max_buffer_size=0, max_threads=0, max_queue_size=...
[ "Sweep", "spectrum", "using", "frequency", "hopping" ]
xmikos/soapy_power
python
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/power.py#L274-L330
[ "def", "sweep", "(", "self", ",", "min_freq", ",", "max_freq", ",", "bins", ",", "repeats", ",", "runs", "=", "0", ",", "time_limit", "=", "0", ",", "overlap", "=", "0", ",", "fft_window", "=", "'hann'", ",", "fft_overlap", "=", "0.5", ",", "crop", ...
46e12659b8d08af764dc09a1f31b0e85a68f808f
test
SMBus.close
close() Disconnects the object from the bus.
smbus/smbus.py
def close(self): """close() Disconnects the object from the bus. """ os.close(self._fd) self._fd = -1 self._addr = -1 self._pec = 0
def close(self): """close() Disconnects the object from the bus. """ os.close(self._fd) self._fd = -1 self._addr = -1 self._pec = 0
[ "close", "()" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L58-L66
[ "def", "close", "(", "self", ")", ":", "os", ".", "close", "(", "self", ".", "_fd", ")", "self", ".", "_fd", "=", "-", "1", "self", ".", "_addr", "=", "-", "1", "self", ".", "_pec", "=", "0" ]
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus.open
open(bus) Connects the object to the specified SMBus.
smbus/smbus.py
def open(self, bus): """open(bus) Connects the object to the specified SMBus. """ bus = int(bus) path = "/dev/i2c-%d" % (bus,) if len(path) >= MAXPATH: raise OverflowError("Bus number is invalid.") try: self._fd = os.open(path, os.O_RD...
def open(self, bus): """open(bus) Connects the object to the specified SMBus. """ bus = int(bus) path = "/dev/i2c-%d" % (bus,) if len(path) >= MAXPATH: raise OverflowError("Bus number is invalid.") try: self._fd = os.open(path, os.O_RD...
[ "open", "(", "bus", ")" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L71-L83
[ "def", "open", "(", "self", ",", "bus", ")", ":", "bus", "=", "int", "(", "bus", ")", "path", "=", "\"/dev/i2c-%d\"", "%", "(", "bus", ",", ")", "if", "len", "(", "path", ")", ">=", "MAXPATH", ":", "raise", "OverflowError", "(", "\"Bus number is inva...
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus._set_addr
private helper method
smbus/smbus.py
def _set_addr(self, addr): """private helper method""" if self._addr != addr: ioctl(self._fd, SMBUS.I2C_SLAVE, addr) self._addr = addr
def _set_addr(self, addr): """private helper method""" if self._addr != addr: ioctl(self._fd, SMBUS.I2C_SLAVE, addr) self._addr = addr
[ "private", "helper", "method" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L85-L89
[ "def", "_set_addr", "(", "self", ",", "addr", ")", ":", "if", "self", ".", "_addr", "!=", "addr", ":", "ioctl", "(", "self", ".", "_fd", ",", "SMBUS", ".", "I2C_SLAVE", ",", "addr", ")", "self", ".", "_addr", "=", "addr" ]
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus.write_quick
write_quick(addr) Perform SMBus Quick transaction.
smbus/smbus.py
def write_quick(self, addr): """write_quick(addr) Perform SMBus Quick transaction. """ self._set_addr(addr) if SMBUS.i2c_smbus_write_quick(self._fd, SMBUS.I2C_SMBUS_WRITE) != 0: raise IOError(ffi.errno)
def write_quick(self, addr): """write_quick(addr) Perform SMBus Quick transaction. """ self._set_addr(addr) if SMBUS.i2c_smbus_write_quick(self._fd, SMBUS.I2C_SMBUS_WRITE) != 0: raise IOError(ffi.errno)
[ "write_quick", "(", "addr", ")" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L92-L99
[ "def", "write_quick", "(", "self", ",", "addr", ")", ":", "self", ".", "_set_addr", "(", "addr", ")", "if", "SMBUS", ".", "i2c_smbus_write_quick", "(", "self", ".", "_fd", ",", "SMBUS", ".", "I2C_SMBUS_WRITE", ")", "!=", "0", ":", "raise", "IOError", "...
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus.read_byte
read_byte(addr) -> result Perform SMBus Read Byte transaction.
smbus/smbus.py
def read_byte(self, addr): """read_byte(addr) -> result Perform SMBus Read Byte transaction. """ self._set_addr(addr) result = SMBUS.i2c_smbus_read_byte(self._fd) if result == -1: raise IOError(ffi.errno) return result
def read_byte(self, addr): """read_byte(addr) -> result Perform SMBus Read Byte transaction. """ self._set_addr(addr) result = SMBUS.i2c_smbus_read_byte(self._fd) if result == -1: raise IOError(ffi.errno) return result
[ "read_byte", "(", "addr", ")", "-", ">", "result" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L102-L111
[ "def", "read_byte", "(", "self", ",", "addr", ")", ":", "self", ".", "_set_addr", "(", "addr", ")", "result", "=", "SMBUS", ".", "i2c_smbus_read_byte", "(", "self", ".", "_fd", ")", "if", "result", "==", "-", "1", ":", "raise", "IOError", "(", "ffi",...
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus.write_byte
write_byte(addr, val) Perform SMBus Write Byte transaction.
smbus/smbus.py
def write_byte(self, addr, val): """write_byte(addr, val) Perform SMBus Write Byte transaction. """ self._set_addr(addr) if SMBUS.i2c_smbus_write_byte(self._fd, ffi.cast("__u8", val)) == -1: raise IOError(ffi.errno)
def write_byte(self, addr, val): """write_byte(addr, val) Perform SMBus Write Byte transaction. """ self._set_addr(addr) if SMBUS.i2c_smbus_write_byte(self._fd, ffi.cast("__u8", val)) == -1: raise IOError(ffi.errno)
[ "write_byte", "(", "addr", "val", ")" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L114-L121
[ "def", "write_byte", "(", "self", ",", "addr", ",", "val", ")", ":", "self", ".", "_set_addr", "(", "addr", ")", "if", "SMBUS", ".", "i2c_smbus_write_byte", "(", "self", ".", "_fd", ",", "ffi", ".", "cast", "(", "\"__u8\"", ",", "val", ")", ")", "=...
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus.read_byte_data
read_byte_data(addr, cmd) -> result Perform SMBus Read Byte Data transaction.
smbus/smbus.py
def read_byte_data(self, addr, cmd): """read_byte_data(addr, cmd) -> result Perform SMBus Read Byte Data transaction. """ self._set_addr(addr) res = SMBUS.i2c_smbus_read_byte_data(self._fd, ffi.cast("__u8", cmd)) if res == -1: raise IOError(ffi.errno) ...
def read_byte_data(self, addr, cmd): """read_byte_data(addr, cmd) -> result Perform SMBus Read Byte Data transaction. """ self._set_addr(addr) res = SMBUS.i2c_smbus_read_byte_data(self._fd, ffi.cast("__u8", cmd)) if res == -1: raise IOError(ffi.errno) ...
[ "read_byte_data", "(", "addr", "cmd", ")", "-", ">", "result" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L124-L133
[ "def", "read_byte_data", "(", "self", ",", "addr", ",", "cmd", ")", ":", "self", ".", "_set_addr", "(", "addr", ")", "res", "=", "SMBUS", ".", "i2c_smbus_read_byte_data", "(", "self", ".", "_fd", ",", "ffi", ".", "cast", "(", "\"__u8\"", ",", "cmd", ...
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus.write_byte_data
write_byte_data(addr, cmd, val) Perform SMBus Write Byte Data transaction.
smbus/smbus.py
def write_byte_data(self, addr, cmd, val): """write_byte_data(addr, cmd, val) Perform SMBus Write Byte Data transaction. """ self._set_addr(addr) if SMBUS.i2c_smbus_write_byte_data(self._fd, ffi.cast("__u8", cmd), ...
def write_byte_data(self, addr, cmd, val): """write_byte_data(addr, cmd, val) Perform SMBus Write Byte Data transaction. """ self._set_addr(addr) if SMBUS.i2c_smbus_write_byte_data(self._fd, ffi.cast("__u8", cmd), ...
[ "write_byte_data", "(", "addr", "cmd", "val", ")" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L136-L145
[ "def", "write_byte_data", "(", "self", ",", "addr", ",", "cmd", ",", "val", ")", ":", "self", ".", "_set_addr", "(", "addr", ")", "if", "SMBUS", ".", "i2c_smbus_write_byte_data", "(", "self", ".", "_fd", ",", "ffi", ".", "cast", "(", "\"__u8\"", ",", ...
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus.read_word_data
read_word_data(addr, cmd) -> result Perform SMBus Read Word Data transaction.
smbus/smbus.py
def read_word_data(self, addr, cmd): """read_word_data(addr, cmd) -> result Perform SMBus Read Word Data transaction. """ self._set_addr(addr) result = SMBUS.i2c_smbus_read_word_data(self._fd, ffi.cast("__u8", cmd)) if result == -1: raise IOError(ffi.errno) ...
def read_word_data(self, addr, cmd): """read_word_data(addr, cmd) -> result Perform SMBus Read Word Data transaction. """ self._set_addr(addr) result = SMBUS.i2c_smbus_read_word_data(self._fd, ffi.cast("__u8", cmd)) if result == -1: raise IOError(ffi.errno) ...
[ "read_word_data", "(", "addr", "cmd", ")", "-", ">", "result" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L148-L157
[ "def", "read_word_data", "(", "self", ",", "addr", ",", "cmd", ")", ":", "self", ".", "_set_addr", "(", "addr", ")", "result", "=", "SMBUS", ".", "i2c_smbus_read_word_data", "(", "self", ".", "_fd", ",", "ffi", ".", "cast", "(", "\"__u8\"", ",", "cmd",...
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus.write_word_data
write_word_data(addr, cmd, val) Perform SMBus Write Word Data transaction.
smbus/smbus.py
def write_word_data(self, addr, cmd, val): """write_word_data(addr, cmd, val) Perform SMBus Write Word Data transaction. """ self._set_addr(addr) if SMBUS.i2c_smbus_write_word_data(self._fd, ffi.cast("__u8", cmd), ...
def write_word_data(self, addr, cmd, val): """write_word_data(addr, cmd, val) Perform SMBus Write Word Data transaction. """ self._set_addr(addr) if SMBUS.i2c_smbus_write_word_data(self._fd, ffi.cast("__u8", cmd), ...
[ "write_word_data", "(", "addr", "cmd", "val", ")" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L160-L169
[ "def", "write_word_data", "(", "self", ",", "addr", ",", "cmd", ",", "val", ")", ":", "self", ".", "_set_addr", "(", "addr", ")", "if", "SMBUS", ".", "i2c_smbus_write_word_data", "(", "self", ".", "_fd", ",", "ffi", ".", "cast", "(", "\"__u8\"", ",", ...
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus.process_call
process_call(addr, cmd, val) Perform SMBus Process Call transaction. Note: although i2c_smbus_process_call returns a value, according to smbusmodule.c this method does not return a value by default. Set _compat = False on the SMBus instance to get a return value.
smbus/smbus.py
def process_call(self, addr, cmd, val): """process_call(addr, cmd, val) Perform SMBus Process Call transaction. Note: although i2c_smbus_process_call returns a value, according to smbusmodule.c this method does not return a value by default. Set _compat = False on the SMBus in...
def process_call(self, addr, cmd, val): """process_call(addr, cmd, val) Perform SMBus Process Call transaction. Note: although i2c_smbus_process_call returns a value, according to smbusmodule.c this method does not return a value by default. Set _compat = False on the SMBus in...
[ "process_call", "(", "addr", "cmd", "val", ")" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L172-L189
[ "def", "process_call", "(", "self", ",", "addr", ",", "cmd", ",", "val", ")", ":", "self", ".", "_set_addr", "(", "addr", ")", "ret", "=", "SMBUS", ".", "i2c_smbus_process_call", "(", "self", ".", "_fd", ",", "ffi", ".", "cast", "(", "\"__u8\"", ",",...
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus.read_block_data
read_block_data(addr, cmd) -> results Perform SMBus Read Block Data transaction.
smbus/smbus.py
def read_block_data(self, addr, cmd): """read_block_data(addr, cmd) -> results Perform SMBus Read Block Data transaction. """ # XXX untested, the raspberry pi i2c driver does not support this # command self._set_addr(addr) data = ffi.new("union i2c_smbus_data *")...
def read_block_data(self, addr, cmd): """read_block_data(addr, cmd) -> results Perform SMBus Read Block Data transaction. """ # XXX untested, the raspberry pi i2c driver does not support this # command self._set_addr(addr) data = ffi.new("union i2c_smbus_data *")...
[ "read_block_data", "(", "addr", "cmd", ")", "-", ">", "results" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L192-L207
[ "def", "read_block_data", "(", "self", ",", "addr", ",", "cmd", ")", ":", "# XXX untested, the raspberry pi i2c driver does not support this", "# command", "self", ".", "_set_addr", "(", "addr", ")", "data", "=", "ffi", ".", "new", "(", "\"union i2c_smbus_data *\"", ...
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus.write_block_data
write_block_data(addr, cmd, vals) Perform SMBus Write Block Data transaction.
smbus/smbus.py
def write_block_data(self, addr, cmd, vals): """write_block_data(addr, cmd, vals) Perform SMBus Write Block Data transaction. """ self._set_addr(addr) data = ffi.new("union i2c_smbus_data *") list_to_smbus_data(data, vals) if SMBUS.i2c_smbus_access(self._fd, ...
def write_block_data(self, addr, cmd, vals): """write_block_data(addr, cmd, vals) Perform SMBus Write Block Data transaction. """ self._set_addr(addr) data = ffi.new("union i2c_smbus_data *") list_to_smbus_data(data, vals) if SMBUS.i2c_smbus_access(self._fd, ...
[ "write_block_data", "(", "addr", "cmd", "vals", ")" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L210-L223
[ "def", "write_block_data", "(", "self", ",", "addr", ",", "cmd", ",", "vals", ")", ":", "self", ".", "_set_addr", "(", "addr", ")", "data", "=", "ffi", ".", "new", "(", "\"union i2c_smbus_data *\"", ")", "list_to_smbus_data", "(", "data", ",", "vals", ")...
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus.block_process_call
block_process_call(addr, cmd, vals) -> results Perform SMBus Block Process Call transaction.
smbus/smbus.py
def block_process_call(self, addr, cmd, vals): """block_process_call(addr, cmd, vals) -> results Perform SMBus Block Process Call transaction. """ self._set_addr(addr) data = ffi.new("union i2c_smbus_data *") list_to_smbus_data(data, vals) if SMBUS.i2c_smbus_acce...
def block_process_call(self, addr, cmd, vals): """block_process_call(addr, cmd, vals) -> results Perform SMBus Block Process Call transaction. """ self._set_addr(addr) data = ffi.new("union i2c_smbus_data *") list_to_smbus_data(data, vals) if SMBUS.i2c_smbus_acce...
[ "block_process_call", "(", "addr", "cmd", "vals", ")", "-", ">", "results" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L226-L239
[ "def", "block_process_call", "(", "self", ",", "addr", ",", "cmd", ",", "vals", ")", ":", "self", ".", "_set_addr", "(", "addr", ")", "data", "=", "ffi", ".", "new", "(", "\"union i2c_smbus_data *\"", ")", "list_to_smbus_data", "(", "data", ",", "vals", ...
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus.read_i2c_block_data
read_i2c_block_data(addr, cmd, len=32) -> results Perform I2C Block Read transaction.
smbus/smbus.py
def read_i2c_block_data(self, addr, cmd, len=32): """read_i2c_block_data(addr, cmd, len=32) -> results Perform I2C Block Read transaction. """ self._set_addr(addr) data = ffi.new("union i2c_smbus_data *") data.block[0] = len if len == 32: arg = SMBUS....
def read_i2c_block_data(self, addr, cmd, len=32): """read_i2c_block_data(addr, cmd, len=32) -> results Perform I2C Block Read transaction. """ self._set_addr(addr) data = ffi.new("union i2c_smbus_data *") data.block[0] = len if len == 32: arg = SMBUS....
[ "read_i2c_block_data", "(", "addr", "cmd", "len", "=", "32", ")", "-", ">", "results" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L242-L259
[ "def", "read_i2c_block_data", "(", "self", ",", "addr", ",", "cmd", ",", "len", "=", "32", ")", ":", "self", ".", "_set_addr", "(", "addr", ")", "data", "=", "ffi", ".", "new", "(", "\"union i2c_smbus_data *\"", ")", "data", ".", "block", "[", "0", "...
7486931edf55fcdde84db38356331c65851a40b1
test
SMBus.pec
True if Packet Error Codes (PEC) are enabled
smbus/smbus.py
def pec(self, value): """True if Packet Error Codes (PEC) are enabled""" pec = bool(value) if pec != self._pec: if ioctl(self._fd, SMBUS.I2C_PEC, pec): raise IOError(ffi.errno) self._pec = pec
def pec(self, value): """True if Packet Error Codes (PEC) are enabled""" pec = bool(value) if pec != self._pec: if ioctl(self._fd, SMBUS.I2C_PEC, pec): raise IOError(ffi.errno) self._pec = pec
[ "True", "if", "Packet", "Error", "Codes", "(", "PEC", ")", "are", "enabled" ]
bivab/smbus-cffi
python
https://github.com/bivab/smbus-cffi/blob/7486931edf55fcdde84db38356331c65851a40b1/smbus/smbus.py#L282-L288
[ "def", "pec", "(", "self", ",", "value", ")", ":", "pec", "=", "bool", "(", "value", ")", "if", "pec", "!=", "self", ".", "_pec", ":", "if", "ioctl", "(", "self", ".", "_fd", ",", "SMBUS", ".", "I2C_PEC", ",", "pec", ")", ":", "raise", "IOError...
7486931edf55fcdde84db38356331c65851a40b1
test
run_cmake
Forcing to run cmake
setup.py
def run_cmake(arg=""): """ Forcing to run cmake """ if ds.find_executable('cmake') is None: print "CMake is required to build zql" print "Please install cmake version >= 2.8 and re-run setup" sys.exit(-1) print "Configuring zql build with CMake.... " cmake_args = arg ...
def run_cmake(arg=""): """ Forcing to run cmake """ if ds.find_executable('cmake') is None: print "CMake is required to build zql" print "Please install cmake version >= 2.8 and re-run setup" sys.exit(-1) print "Configuring zql build with CMake.... " cmake_args = arg ...
[ "Forcing", "to", "run", "cmake" ]
vulogov/zq
python
https://github.com/vulogov/zq/blob/86a47b03582f9544614f1a038ef020145172dd08/setup.py#L13-L36
[ "def", "run_cmake", "(", "arg", "=", "\"\"", ")", ":", "if", "ds", ".", "find_executable", "(", "'cmake'", ")", "is", "None", ":", "print", "\"CMake is required to build zql\"", "print", "\"Please install cmake version >= 2.8 and re-run setup\"", "sys", ".", "exit", ...
86a47b03582f9544614f1a038ef020145172dd08
test
Filter.start
Return the starting datetime: ``number`` of units before ``now``.
grandfatherson/filters.py
def start(cls, now, number, **options): """ Return the starting datetime: ``number`` of units before ``now``. """ return (cls.mask(now, **options) - timedelta(**{cls.__name__.lower(): number - 1}))
def start(cls, now, number, **options): """ Return the starting datetime: ``number`` of units before ``now``. """ return (cls.mask(now, **options) - timedelta(**{cls.__name__.lower(): number - 1}))
[ "Return", "the", "starting", "datetime", ":", "number", "of", "units", "before", "now", "." ]
ecometrica/grandfatherson
python
https://github.com/ecometrica/grandfatherson/blob/b166e4e44887960c3066ebd28eecadfae19561e1/grandfatherson/filters.py#L37-L42
[ "def", "start", "(", "cls", ",", "now", ",", "number", ",", "*", "*", "options", ")", ":", "return", "(", "cls", ".", "mask", "(", "now", ",", "*", "*", "options", ")", "-", "timedelta", "(", "*", "*", "{", "cls", ".", "__name__", ".", "lower",...
b166e4e44887960c3066ebd28eecadfae19561e1
test
Filter.filter
Return a set of datetimes, after filtering ``datetimes``. The result will be the ``datetimes`` which are ``number`` of units before ``now``, until ``now``, with approximately one unit between each of them. The first datetime for any unit is kept, later duplicates are removed. ...
grandfatherson/filters.py
def filter(cls, datetimes, number, now=None, **options): """Return a set of datetimes, after filtering ``datetimes``. The result will be the ``datetimes`` which are ``number`` of units before ``now``, until ``now``, with approximately one unit between each of them. The first datetime f...
def filter(cls, datetimes, number, now=None, **options): """Return a set of datetimes, after filtering ``datetimes``. The result will be the ``datetimes`` which are ``number`` of units before ``now``, until ``now``, with approximately one unit between each of them. The first datetime f...
[ "Return", "a", "set", "of", "datetimes", "after", "filtering", "datetimes", "." ]
ecometrica/grandfatherson
python
https://github.com/ecometrica/grandfatherson/blob/b166e4e44887960c3066ebd28eecadfae19561e1/grandfatherson/filters.py#L45-L89
[ "def", "filter", "(", "cls", ",", "datetimes", ",", "number", ",", "now", "=", "None", ",", "*", "*", "options", ")", ":", "if", "not", "isinstance", "(", "number", ",", "int", ")", "or", "number", "<", "0", ":", "raise", "ValueError", "(", "'Inval...
b166e4e44887960c3066ebd28eecadfae19561e1
test
Days.mask
Return a datetime with the same value as ``dt``, to a resolution of days.
grandfatherson/filters.py
def mask(cls, dt, **options): """ Return a datetime with the same value as ``dt``, to a resolution of days. """ return dt.replace(hour=0, minute=0, second=0, microsecond=0)
def mask(cls, dt, **options): """ Return a datetime with the same value as ``dt``, to a resolution of days. """ return dt.replace(hour=0, minute=0, second=0, microsecond=0)
[ "Return", "a", "datetime", "with", "the", "same", "value", "as", "dt", "to", "a", "resolution", "of", "days", "." ]
ecometrica/grandfatherson
python
https://github.com/ecometrica/grandfatherson/blob/b166e4e44887960c3066ebd28eecadfae19561e1/grandfatherson/filters.py#L124-L129
[ "def", "mask", "(", "cls", ",", "dt", ",", "*", "*", "options", ")", ":", "return", "dt", ".", "replace", "(", "hour", "=", "0", ",", "minute", "=", "0", ",", "second", "=", "0", ",", "microsecond", "=", "0", ")" ]
b166e4e44887960c3066ebd28eecadfae19561e1
test
Weeks.start
Return the starting datetime: ``number`` of weeks before ``now``. ``firstweekday`` determines when the week starts. It defaults to Saturday.
grandfatherson/filters.py
def start(cls, now, number, firstweekday=calendar.SATURDAY, **options): """ Return the starting datetime: ``number`` of weeks before ``now``. ``firstweekday`` determines when the week starts. It defaults to Saturday. """ week = cls.mask(now, firstweekday=firstweekday, **...
def start(cls, now, number, firstweekday=calendar.SATURDAY, **options): """ Return the starting datetime: ``number`` of weeks before ``now``. ``firstweekday`` determines when the week starts. It defaults to Saturday. """ week = cls.mask(now, firstweekday=firstweekday, **...
[ "Return", "the", "starting", "datetime", ":", "number", "of", "weeks", "before", "now", "." ]
ecometrica/grandfatherson
python
https://github.com/ecometrica/grandfatherson/blob/b166e4e44887960c3066ebd28eecadfae19561e1/grandfatherson/filters.py#L136-L145
[ "def", "start", "(", "cls", ",", "now", ",", "number", ",", "firstweekday", "=", "calendar", ".", "SATURDAY", ",", "*", "*", "options", ")", ":", "week", "=", "cls", ".", "mask", "(", "now", ",", "firstweekday", "=", "firstweekday", ",", "*", "*", ...
b166e4e44887960c3066ebd28eecadfae19561e1
test
Weeks.mask
Return a datetime with the same value as ``dt``, to a resolution of weeks. ``firstweekday`` determines when the week starts. It defaults to Saturday.
grandfatherson/filters.py
def mask(cls, dt, firstweekday=calendar.SATURDAY, **options): """ Return a datetime with the same value as ``dt``, to a resolution of weeks. ``firstweekday`` determines when the week starts. It defaults to Saturday. """ correction = (dt.weekday() - firstweekday) ...
def mask(cls, dt, firstweekday=calendar.SATURDAY, **options): """ Return a datetime with the same value as ``dt``, to a resolution of weeks. ``firstweekday`` determines when the week starts. It defaults to Saturday. """ correction = (dt.weekday() - firstweekday) ...
[ "Return", "a", "datetime", "with", "the", "same", "value", "as", "dt", "to", "a", "resolution", "of", "weeks", "." ]
ecometrica/grandfatherson
python
https://github.com/ecometrica/grandfatherson/blob/b166e4e44887960c3066ebd28eecadfae19561e1/grandfatherson/filters.py#L148-L158
[ "def", "mask", "(", "cls", ",", "dt", ",", "firstweekday", "=", "calendar", ".", "SATURDAY", ",", "*", "*", "options", ")", ":", "correction", "=", "(", "dt", ".", "weekday", "(", ")", "-", "firstweekday", ")", "%", "cls", ".", "DAYS_IN_WEEK", "week"...
b166e4e44887960c3066ebd28eecadfae19561e1
test
Months.start
Return the starting datetime: ``number`` of months before ``now``.
grandfatherson/filters.py
def start(cls, now, number, **options): """ Return the starting datetime: ``number`` of months before ``now``. """ year = now.year month = now.month - number + 1 # Handle negative months if month < 0: year = year + (month // cls.MONTHS_IN_YEAR) ...
def start(cls, now, number, **options): """ Return the starting datetime: ``number`` of months before ``now``. """ year = now.year month = now.month - number + 1 # Handle negative months if month < 0: year = year + (month // cls.MONTHS_IN_YEAR) ...
[ "Return", "the", "starting", "datetime", ":", "number", "of", "months", "before", "now", "." ]
ecometrica/grandfatherson
python
https://github.com/ecometrica/grandfatherson/blob/b166e4e44887960c3066ebd28eecadfae19561e1/grandfatherson/filters.py#L165-L179
[ "def", "start", "(", "cls", ",", "now", ",", "number", ",", "*", "*", "options", ")", ":", "year", "=", "now", ".", "year", "month", "=", "now", ".", "month", "-", "number", "+", "1", "# Handle negative months", "if", "month", "<", "0", ":", "year"...
b166e4e44887960c3066ebd28eecadfae19561e1
test
Years.start
Return the starting datetime: ``number`` of years before ``now``.
grandfatherson/filters.py
def start(cls, now, number, **options): """ Return the starting datetime: ``number`` of years before ``now``. """ return cls.mask(now).replace(year=(now.year - number + 1))
def start(cls, now, number, **options): """ Return the starting datetime: ``number`` of years before ``now``. """ return cls.mask(now).replace(year=(now.year - number + 1))
[ "Return", "the", "starting", "datetime", ":", "number", "of", "years", "before", "now", "." ]
ecometrica/grandfatherson
python
https://github.com/ecometrica/grandfatherson/blob/b166e4e44887960c3066ebd28eecadfae19561e1/grandfatherson/filters.py#L193-L197
[ "def", "start", "(", "cls", ",", "now", ",", "number", ",", "*", "*", "options", ")", ":", "return", "cls", ".", "mask", "(", "now", ")", ".", "replace", "(", "year", "=", "(", "now", ".", "year", "-", "number", "+", "1", ")", ")" ]
b166e4e44887960c3066ebd28eecadfae19561e1
test
to_keep
Return a set of datetimes that should be kept, out of ``datetimes``. Keeps up to ``years``, ``months``, ``weeks``, ``days``, ``hours``, ``minutes``, and ``seconds`` in the past. When keeping weeks, it prefers to keep ``firstweekday``, which defaults to Saturday. If ``now`` is None, it will base i...
grandfatherson/__init__.py
def to_keep(datetimes, years=0, months=0, weeks=0, days=0, hours=0, minutes=0, seconds=0, firstweekday=SATURDAY, now=None): """ Return a set of datetimes that should be kept, out of ``datetimes``. Keeps up to ``years``, ``months``, ``weeks``, ``days``, ``hours``, ``m...
def to_keep(datetimes, years=0, months=0, weeks=0, days=0, hours=0, minutes=0, seconds=0, firstweekday=SATURDAY, now=None): """ Return a set of datetimes that should be kept, out of ``datetimes``. Keeps up to ``years``, ``months``, ``weeks``, ``days``, ``hours``, ``m...
[ "Return", "a", "set", "of", "datetimes", "that", "should", "be", "kept", "out", "of", "datetimes", "." ]
ecometrica/grandfatherson
python
https://github.com/ecometrica/grandfatherson/blob/b166e4e44887960c3066ebd28eecadfae19561e1/grandfatherson/__init__.py#L150-L175
[ "def", "to_keep", "(", "datetimes", ",", "years", "=", "0", ",", "months", "=", "0", ",", "weeks", "=", "0", ",", "days", "=", "0", ",", "hours", "=", "0", ",", "minutes", "=", "0", ",", "seconds", "=", "0", ",", "firstweekday", "=", "SATURDAY", ...
b166e4e44887960c3066ebd28eecadfae19561e1
test
to_delete
Return a set of datetimes that should be deleted, out of ``datetimes``. See ``to_keep`` for a description of arguments.
grandfatherson/__init__.py
def to_delete(datetimes, years=0, months=0, weeks=0, days=0, hours=0, minutes=0, seconds=0, firstweekday=SATURDAY, now=None): """ Return a set of datetimes that should be deleted, out of ``datetimes``. See ``to_keep`` for a description of arguments. """ dat...
def to_delete(datetimes, years=0, months=0, weeks=0, days=0, hours=0, minutes=0, seconds=0, firstweekday=SATURDAY, now=None): """ Return a set of datetimes that should be deleted, out of ``datetimes``. See ``to_keep`` for a description of arguments. """ dat...
[ "Return", "a", "set", "of", "datetimes", "that", "should", "be", "deleted", "out", "of", "datetimes", "." ]
ecometrica/grandfatherson
python
https://github.com/ecometrica/grandfatherson/blob/b166e4e44887960c3066ebd28eecadfae19561e1/grandfatherson/__init__.py#L178-L192
[ "def", "to_delete", "(", "datetimes", ",", "years", "=", "0", ",", "months", "=", "0", ",", "weeks", "=", "0", ",", "days", "=", "0", ",", "hours", "=", "0", ",", "minutes", "=", "0", ",", "seconds", "=", "0", ",", "firstweekday", "=", "SATURDAY"...
b166e4e44887960c3066ebd28eecadfae19561e1
test
dates_to_keep
Return a set of dates that should be kept, out of ``dates``. See ``to_keep`` for a description of arguments.
grandfatherson/__init__.py
def dates_to_keep(dates, years=0, months=0, weeks=0, days=0, firstweekday=SATURDAY, now=None): """ Return a set of dates that should be kept, out of ``dates``. See ``to_keep`` for a description of arguments. """ datetimes = to_keep((datetime.combine(d, time()) fo...
def dates_to_keep(dates, years=0, months=0, weeks=0, days=0, firstweekday=SATURDAY, now=None): """ Return a set of dates that should be kept, out of ``dates``. See ``to_keep`` for a description of arguments. """ datetimes = to_keep((datetime.combine(d, time()) fo...
[ "Return", "a", "set", "of", "dates", "that", "should", "be", "kept", "out", "of", "dates", "." ]
ecometrica/grandfatherson
python
https://github.com/ecometrica/grandfatherson/blob/b166e4e44887960c3066ebd28eecadfae19561e1/grandfatherson/__init__.py#L195-L207
[ "def", "dates_to_keep", "(", "dates", ",", "years", "=", "0", ",", "months", "=", "0", ",", "weeks", "=", "0", ",", "days", "=", "0", ",", "firstweekday", "=", "SATURDAY", ",", "now", "=", "None", ")", ":", "datetimes", "=", "to_keep", "(", "(", ...
b166e4e44887960c3066ebd28eecadfae19561e1
test
dates_to_delete
Return a set of date that should be deleted, out of ``dates``. See ``to_keep`` for a description of arguments.
grandfatherson/__init__.py
def dates_to_delete(dates, years=0, months=0, weeks=0, days=0, firstweekday=SATURDAY, now=None): """ Return a set of date that should be deleted, out of ``dates``. See ``to_keep`` for a description of arguments. """ dates = set(dates) return dates - dates...
def dates_to_delete(dates, years=0, months=0, weeks=0, days=0, firstweekday=SATURDAY, now=None): """ Return a set of date that should be deleted, out of ``dates``. See ``to_keep`` for a description of arguments. """ dates = set(dates) return dates - dates...
[ "Return", "a", "set", "of", "date", "that", "should", "be", "deleted", "out", "of", "dates", "." ]
ecometrica/grandfatherson
python
https://github.com/ecometrica/grandfatherson/blob/b166e4e44887960c3066ebd28eecadfae19561e1/grandfatherson/__init__.py#L210-L222
[ "def", "dates_to_delete", "(", "dates", ",", "years", "=", "0", ",", "months", "=", "0", ",", "weeks", "=", "0", ",", "days", "=", "0", ",", "firstweekday", "=", "SATURDAY", ",", "now", "=", "None", ")", ":", "dates", "=", "set", "(", "dates", ")...
b166e4e44887960c3066ebd28eecadfae19561e1
test
MCP23S17._get_spi_control_byte
Returns an SPI control byte. The MCP23S17 is a slave SPI device. The slave address contains four fixed bits and three user-defined hardware address bits (if enabled via IOCON.HAEN) (pins A2, A1 and A0) with the read/write bit filling out the control byte:: +----------------...
pifacecommon/mcp23s17.py
def _get_spi_control_byte(self, read_write_cmd): """Returns an SPI control byte. The MCP23S17 is a slave SPI device. The slave address contains four fixed bits and three user-defined hardware address bits (if enabled via IOCON.HAEN) (pins A2, A1 and A0) with the read/write bit f...
def _get_spi_control_byte(self, read_write_cmd): """Returns an SPI control byte. The MCP23S17 is a slave SPI device. The slave address contains four fixed bits and three user-defined hardware address bits (if enabled via IOCON.HAEN) (pins A2, A1 and A0) with the read/write bit f...
[ "Returns", "an", "SPI", "control", "byte", "." ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/mcp23s17.py#L116-L135
[ "def", "_get_spi_control_byte", "(", "self", ",", "read_write_cmd", ")", ":", "# board_addr_pattern = (self.hardware_addr & 0b111) << 1", "board_addr_pattern", "=", "(", "self", ".", "hardware_addr", "<<", "1", ")", "&", "0xE", "rw_cmd_pattern", "=", "read_write_cmd", "...
006bca14c18d43ba2d9eafaa84ef83b512c51cf6
test
MCP23S17.read_bit
Returns the bit specified from the address. :param bit_num: The bit number to read from. :type bit_num: int :param address: The address to read from. :type address: int :returns: int -- the bit value from the address
pifacecommon/mcp23s17.py
def read_bit(self, bit_num, address): """Returns the bit specified from the address. :param bit_num: The bit number to read from. :type bit_num: int :param address: The address to read from. :type address: int :returns: int -- the bit value from the address """ ...
def read_bit(self, bit_num, address): """Returns the bit specified from the address. :param bit_num: The bit number to read from. :type bit_num: int :param address: The address to read from. :type address: int :returns: int -- the bit value from the address """ ...
[ "Returns", "the", "bit", "specified", "from", "the", "address", "." ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/mcp23s17.py#L177-L188
[ "def", "read_bit", "(", "self", ",", "bit_num", ",", "address", ")", ":", "value", "=", "self", ".", "read", "(", "address", ")", "bit_mask", "=", "get_bit_mask", "(", "bit_num", ")", "return", "1", "if", "value", "&", "bit_mask", "else", "0" ]
006bca14c18d43ba2d9eafaa84ef83b512c51cf6
test
MCP23S17.write_bit
Writes the value given to the bit in the address specified. :param value: The value to write. :type value: int :param bit_num: The bit number to write to. :type bit_num: int :param address: The address to write to. :type address: int
pifacecommon/mcp23s17.py
def write_bit(self, value, bit_num, address): """Writes the value given to the bit in the address specified. :param value: The value to write. :type value: int :param bit_num: The bit number to write to. :type bit_num: int :param address: The address to write to. ...
def write_bit(self, value, bit_num, address): """Writes the value given to the bit in the address specified. :param value: The value to write. :type value: int :param bit_num: The bit number to write to. :type bit_num: int :param address: The address to write to. ...
[ "Writes", "the", "value", "given", "to", "the", "bit", "in", "the", "address", "specified", "." ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/mcp23s17.py#L190-L207
[ "def", "write_bit", "(", "self", ",", "value", ",", "bit_num", ",", "address", ")", ":", "bit_mask", "=", "get_bit_mask", "(", "bit_num", ")", "old_byte", "=", "self", ".", "read", "(", "address", ")", "# generate the new byte", "if", "value", ":", "new_by...
006bca14c18d43ba2d9eafaa84ef83b512c51cf6
test
get_bit_num
Returns the lowest bit num from a given bit pattern. Returns None if no bits set. :param bit_pattern: The bit pattern. :type bit_pattern: int :returns: int -- the bit number :returns: None -- no bits set >>> pifacecommon.core.get_bit_num(0) None >>> pifacecommon.core.get_bit_num(0b1) ...
pifacecommon/core.py
def get_bit_num(bit_pattern): """Returns the lowest bit num from a given bit pattern. Returns None if no bits set. :param bit_pattern: The bit pattern. :type bit_pattern: int :returns: int -- the bit number :returns: None -- no bits set >>> pifacecommon.core.get_bit_num(0) None >>>...
def get_bit_num(bit_pattern): """Returns the lowest bit num from a given bit pattern. Returns None if no bits set. :param bit_pattern: The bit pattern. :type bit_pattern: int :returns: int -- the bit number :returns: None -- no bits set >>> pifacecommon.core.get_bit_num(0) None >>>...
[ "Returns", "the", "lowest", "bit", "num", "from", "a", "given", "bit", "pattern", ".", "Returns", "None", "if", "no", "bits", "set", "." ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/core.py#L19-L46
[ "def", "get_bit_num", "(", "bit_pattern", ")", ":", "if", "bit_pattern", "==", "0", ":", "return", "None", "bit_num", "=", "0", "# assume bit 0", "while", "(", "bit_pattern", "&", "1", ")", "==", "0", ":", "bit_pattern", "=", "bit_pattern", ">>", "1", "b...
006bca14c18d43ba2d9eafaa84ef83b512c51cf6
test
watch_port_events
Waits for a port event. When a port event occurs it is placed onto the event queue. :param port: The port we are waiting for interrupts on (GPIOA/GPIOB). :type port: int :param chip: The chip we are waiting for interrupts on. :type chip: :class:`pifacecommon.mcp23s17.MCP23S17` :param pin_functi...
pifacecommon/interrupts.py
def watch_port_events(port, chip, pin_function_maps, event_queue, return_after_kbdint=False): """Waits for a port event. When a port event occurs it is placed onto the event queue. :param port: The port we are waiting for interrupts on (GPIOA/GPIOB). :type port: int :param chi...
def watch_port_events(port, chip, pin_function_maps, event_queue, return_after_kbdint=False): """Waits for a port event. When a port event occurs it is placed onto the event queue. :param port: The port we are waiting for interrupts on (GPIOA/GPIOB). :type port: int :param chi...
[ "Waits", "for", "a", "port", "event", ".", "When", "a", "port", "event", "occurs", "it", "is", "placed", "onto", "the", "event", "queue", "." ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/interrupts.py#L255-L306
[ "def", "watch_port_events", "(", "port", ",", "chip", ",", "pin_function_maps", ",", "event_queue", ",", "return_after_kbdint", "=", "False", ")", ":", "# set up epoll", "gpio25", "=", "open", "(", "GPIO_INTERRUPT_DEVICE_VALUE", ",", "'r'", ")", "# change to use 'wi...
006bca14c18d43ba2d9eafaa84ef83b512c51cf6
test
handle_events
Waits for events on the event queue and calls the registered functions. :param function_maps: A list of classes that have inheritted from :class:`FunctionMap`\ s describing what to do with events. :type function_maps: list :param event_queue: A queue to put events on. :type event_queue: :py:cla...
pifacecommon/interrupts.py
def handle_events( function_maps, event_queue, event_matches_function_map, terminate_signal): """Waits for events on the event queue and calls the registered functions. :param function_maps: A list of classes that have inheritted from :class:`FunctionMap`\ s describing what to do with e...
def handle_events( function_maps, event_queue, event_matches_function_map, terminate_signal): """Waits for events on the event queue and calls the registered functions. :param function_maps: A list of classes that have inheritted from :class:`FunctionMap`\ s describing what to do with e...
[ "Waits", "for", "events", "on", "the", "event", "queue", "and", "calls", "the", "registered", "functions", "." ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/interrupts.py#L309-L341
[ "def", "handle_events", "(", "function_maps", ",", "event_queue", ",", "event_matches_function_map", ",", "terminate_signal", ")", ":", "while", "True", ":", "# print(\"HANDLE: Waiting for events!\")", "event", "=", "event_queue", ".", "get", "(", ")", "# print(\"HANDLE...
006bca14c18d43ba2d9eafaa84ef83b512c51cf6
test
bring_gpio_interrupt_into_userspace
Bring the interrupt pin on the GPIO into Linux userspace.
pifacecommon/interrupts.py
def bring_gpio_interrupt_into_userspace(): # activate gpio interrupt """Bring the interrupt pin on the GPIO into Linux userspace.""" try: # is it already there? with open(GPIO_INTERRUPT_DEVICE_VALUE): return except IOError: # no, bring it into userspace with open...
def bring_gpio_interrupt_into_userspace(): # activate gpio interrupt """Bring the interrupt pin on the GPIO into Linux userspace.""" try: # is it already there? with open(GPIO_INTERRUPT_DEVICE_VALUE): return except IOError: # no, bring it into userspace with open...
[ "Bring", "the", "interrupt", "pin", "on", "the", "GPIO", "into", "Linux", "userspace", "." ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/interrupts.py#L381-L392
[ "def", "bring_gpio_interrupt_into_userspace", "(", ")", ":", "# activate gpio interrupt", "try", ":", "# is it already there?", "with", "open", "(", "GPIO_INTERRUPT_DEVICE_VALUE", ")", ":", "return", "except", "IOError", ":", "# no, bring it into userspace", "with", "open",...
006bca14c18d43ba2d9eafaa84ef83b512c51cf6
test
set_gpio_interrupt_edge
Set the interrupt edge on the userspace GPIO pin. :param edge: The interrupt edge ('none', 'falling', 'rising'). :type edge: string
pifacecommon/interrupts.py
def set_gpio_interrupt_edge(edge='falling'): """Set the interrupt edge on the userspace GPIO pin. :param edge: The interrupt edge ('none', 'falling', 'rising'). :type edge: string """ # we're only interested in the falling edge (1 -> 0) start_time = time.time() time_limit = start_time + FIL...
def set_gpio_interrupt_edge(edge='falling'): """Set the interrupt edge on the userspace GPIO pin. :param edge: The interrupt edge ('none', 'falling', 'rising'). :type edge: string """ # we're only interested in the falling edge (1 -> 0) start_time = time.time() time_limit = start_time + FIL...
[ "Set", "the", "interrupt", "edge", "on", "the", "userspace", "GPIO", "pin", "." ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/interrupts.py#L401-L416
[ "def", "set_gpio_interrupt_edge", "(", "edge", "=", "'falling'", ")", ":", "# we're only interested in the falling edge (1 -> 0)", "start_time", "=", "time", ".", "time", "(", ")", "time_limit", "=", "start_time", "+", "FILE_IO_TIMEOUT", "while", "time", ".", "time", ...
006bca14c18d43ba2d9eafaa84ef83b512c51cf6
test
wait_until_file_exists
Wait until a file exists. :param filename: The name of the file to wait for. :type filename: string
pifacecommon/interrupts.py
def wait_until_file_exists(filename): """Wait until a file exists. :param filename: The name of the file to wait for. :type filename: string """ start_time = time.time() time_limit = start_time + FILE_IO_TIMEOUT while time.time() < time_limit: try: with open(filename): ...
def wait_until_file_exists(filename): """Wait until a file exists. :param filename: The name of the file to wait for. :type filename: string """ start_time = time.time() time_limit = start_time + FILE_IO_TIMEOUT while time.time() < time_limit: try: with open(filename): ...
[ "Wait", "until", "a", "file", "exists", "." ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/interrupts.py#L419-L434
[ "def", "wait_until_file_exists", "(", "filename", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "time_limit", "=", "start_time", "+", "FILE_IO_TIMEOUT", "while", "time", ".", "time", "(", ")", "<", "time_limit", ":", "try", ":", "with", "open...
006bca14c18d43ba2d9eafaa84ef83b512c51cf6