bci.utils package

Submodules

bci.utils.cli module

class bci.utils.cli.Log

Bases: object

Warps commands’ output to provide the functionality of the quiet and traceback flags.

quiet

If true, quiets errors.

Type

bool

traceback

If true, prints the traceback in case of an error.

Type

bool

bci.utils.create_mini_sample module

bci.utils.create_mini_sample.create_mini_sample(root=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/bci/checkouts/latest/bci'), sample_file='sample.mind.gz', max_snapshots_num=100)

bci.utils.load module

bci.utils.load.load_modules(loader_file)

Loads all modules that are in the same folder of loader_file.

Parameters

loader_file (str) – Full path of the file loading the modules that are in the same folder with it.

Returns

A dictionary mapping a module name to the corresponding module object.

Return type

dict

bci.utils.sqlalchemy module

bci.utils.sqlalchemy.get_all_as_dict(session, entity, single=False, cols=[], **kwargs)

Gets all instances of entity that meet kwargs in dictionary representation, while selecting cols.

Parameters
  • session (sqlalchemy.orm.session.Session) – The session with which the query will be associated.

  • entity (sqlalchemy.ext.declarative.api.Base) – The entity on which the query is performed.

  • single (bool) – If true, we expect only one instance.

  • cols (list) – The columns to select from each instance.

  • kwargs (dict) – Keyword expressions to filter by.

Returns

The list of the required instances converted to

dictionary representation.

Return type

list

bci.utils.sqlalchemy.get_or_create(session, entity, **kwargs)

Gets the instance of entity that meets kwargs if one exists; Otherwise, create the required entity’s instance and adds it to session.

Parameters
  • session (sqlalchemy.orm.session.Session) – The session with which the query will be associated.

  • entity (sqlalchemy.ext.declarative.api.Base) – The entity on which the query is performed.

  • kwargs (dict) – Keyword expressions to filter by.

Returns

The required instance.

Return type

entity

bci.utils.struct module

bci.utils.struct.read_struct_by_format(stream, format)

Reads a struct, whose format string is format, from stream, and then unpacks it.

Parameters
  • stream (IOBase) – Stream we are reading from.

  • format (str) – Format string of the struct we are interested in.

Returns

The unpacking of the appropriate struct. The result is a tuple even if it contains exactly one item.

Module contents