IoTPy.tools package¶
Submodules¶
IoTPy.tools.assemble module¶
-
IoTPy.tools.assemble.
assemble
(name, template_name, module_name, multiprocessing=False, distributed=False, host='localhost', user='guest', password='guest', **kwargs)[source]¶ Assembles a part.
Parameters: name : str
Name of the part
template_name : str
Name of the template
module_name : str
Name of the module calling assemble
multiprocessing : bool, optional
Describes whether to run the template using multiprocessing (the default is False).
distributed : bool, optional
Describes whether to run the template using distributed computing (the default is False).
host : str, optional
Name of the server for rabbitmq if using distributed (the default is localhost).
user : str, optional
Name of the user for rabbitmq (the default is guest)
password : str, optional
User password for rabbitmq (the default is guest)
kwargs : keyword arguments
Keyword arguments. All inputs and outputs (non-optional) must be keywords
Returns: Component
The component for the template
IoTPy.tools.component module¶
-
class
IoTPy.tools.component.
Component
(name, template_name, module_name, dict_parts, multiprocessing=False, distributed=False, host='localhost', user='guest', password='guest')[source]¶ Class for a template
This class creates a template and assembles its subparts.
Parameters: name : str
Name of the part
template_name : str
Name of the template
module_name : str
Name of the module calling assemble
dict_parts : dict
Keyword arguments. All inputs and outputs (non-optional) must be keywords
multiprocessing : bool, optional
Describes whether to run the template using multiprocessing (the default is False).
distributed : bool, optional
Describes whether to run the template using distributed computing (the default is False).
host : str, optional
Name of the server for rabbitmq if using distributed (the default is localhost).
user : str, optional
Name of the user for rabbitmq (the default is guest)
password : str, optional
User password for rabbitmq (the default is guest)
Attributes
name (str) The name of the part template_name (str) The name of the template
IoTPy.tools.db module¶
-
IoTPy.tools.db.
find
(name)[source]¶ Finds a template in the db
Parameters: name : str
Name of the template
Returns: list
List of templates
-
IoTPy.tools.db.
get_template
(name)[source]¶ Finds and returns a template in the db
Parameters: name : str
Name of the template
Returns: dict or None
If template is found, dict is returned. Otherwise None is returned.
IoTPy.tools.helper_functions module¶
-
IoTPy.tools.helper_functions.
extend
(lst, index)[source]¶ Extends a list to index
This function takes as parameters a list and an index, and extends the list to have length = index + 1.
Parameters: lst : list
The list to extend
index : int
The index to extend list to
-
IoTPy.tools.helper_functions.
get_function
(func_name, module_name)[source]¶ Returns a function.
This function takes as input a function name and a module name and returns the function.
Parameters: func_name : str or function
Name of the function. If func_name is a function, it is returned. Otherwise if func_name has module namespaces, it is returned from the modules directory. E.g. if func_name == module_1.func, func is defined in modules/module_1.py
module_name : str
Name of the module where the function is defined. Used if func_name does not have modules.
Returns: function
Function with name func_name
-
IoTPy.tools.helper_functions.
get_value
(dict_parts)[source]¶ Returns values in dict
This function returns values in Value objects in dict_parts.
Parameters: dict_parts: dict
Dict of Value objects
Returns: dict
Dict of values
-
IoTPy.tools.helper_functions.
get_valueR
(value)[source]¶ Recursively returns values in Value objects
Parameters: value : list or Value
If value is a list, this function recursively returns the values in the list. Otherwise if value is Value, returns the value.
Returns: list or Value or object
-
IoTPy.tools.helper_functions.
parse_fields
(field, dict_parts)[source]¶ Parses fields and returns the field if it is enclosed in ” or if it is a number, otherwise returns the value in dict_parts
Parameters: field : str or float or list
The field to parse
dict_parts : dict
Dictionary containing values for the part
Returns
_______
field
Parsed field
IoTPy.tools.parameter module¶
-
class
IoTPy.tools.parameter.
Parameter
(name, param, index=None)[source]¶ Stores parameter info for assemble
Parameters: name : str
Name of the part
param : str
Name of the field
index : int
Index of the field.
Attributes
name (str) Name of the part param (str) Name of the field index (int, optional) Index of the field (the default is None) Methods
to_list
()Returns the parameter info as a list
-
IoTPy.tools.parameter.
get_external
(external)[source]¶ Constructs a Parameter object from a list
Parameters: external : list
List containing name, param, and index (optional)
Returns: Parameter
-
IoTPy.tools.parameter.
get_internal
(internal)[source]¶ Constructs Parameter objects from internal list
This function constructs a source and a destination from a list.
Parameters: internal : list
List containing source name, source param name, source index (optional), destination name, destination param name, destination index (optional)
Returns: Parameter, Parameter
Source and destination Parameter objects
IoTPy.tools.parser module¶
-
IoTPy.tools.parser.
get_templates
(x)[source]¶ Parses a string containing templates to dict
Parameters: x : str
String that describes templates
Returns: list
List containing dict for templates