sparc.client package

Subpackages

Submodules

sparc.client.client module

class sparc.client.client.SparcClient(config_file: str = 'config/config.ini', connect: bool = True)[source]

Bases: object

The main class of the sparc.client library.

This class is used to connect existing modules located in <projectbase>/services folder

Parameters:

config_filestr

The location of the file in INI format that is used to extract configuration variables. The config file needs to define a [global] section with the name of the default profile (in square brackets as well) which holds environmental variables used by the modules. Refer to configparser for further details.

connectbool (True)

Calls connect() method of each of the modules. By default during initialization all modules are initialized and ready to be used, unless connect is set to False.

Attributes:

module_nameslist

Stores the list of modules that are automatically loaded from the <projectbase>/services directory.

Methods:

add_module(path, config, connect):

Adds and optionally connects to a module in a given path with configuration variables defined in config.

connect()

Connects all the modules by calling their connect() functions.

add_module(paths: str | list[str], config: dict | SectionProxy | None = None, connect: bool = True) None[source]

Adds and optionally connects to a module in a given path with configuration variables defined in config.

Parameters:
pathsstr or list[str]

a path to the module

configdict or configparser.SectionProxy

a dictionary (or Section of the config file parsed by ConfigParser) with the configuration variables

connectbool

determines if the module should auto-connect

connect() bool[source]

Connects each of the modules loaded into self.module_names

Module contents

class sparc.client.SparcClient(config_file: str = 'config/config.ini', connect: bool = True)[source]

Bases: object

The main class of the sparc.client library.

This class is used to connect existing modules located in <projectbase>/services folder

Parameters:

config_filestr

The location of the file in INI format that is used to extract configuration variables. The config file needs to define a [global] section with the name of the default profile (in square brackets as well) which holds environmental variables used by the modules. Refer to configparser for further details.

connectbool (True)

Calls connect() method of each of the modules. By default during initialization all modules are initialized and ready to be used, unless connect is set to False.

Attributes:

module_nameslist

Stores the list of modules that are automatically loaded from the <projectbase>/services directory.

Methods:

add_module(path, config, connect):

Adds and optionally connects to a module in a given path with configuration variables defined in config.

connect()

Connects all the modules by calling their connect() functions.

add_module(paths: str | list[str], config: dict | SectionProxy | None = None, connect: bool = True) None[source]

Adds and optionally connects to a module in a given path with configuration variables defined in config.

Parameters:
pathsstr or list[str]

a path to the module

configdict or configparser.SectionProxy

a dictionary (or Section of the config file parsed by ConfigParser) with the configuration variables

connectbool

determines if the module should auto-connect

connect() bool[source]

Connects each of the modules loaded into self.module_names