libs_pkg package¶
Submodules¶
libs_pkg.command_execution module¶
The module command_execution contains three functions to execute three categories of commands and return the results by calling other functions in other modules that read and parse the results to proper data structures in python.
-
async
libs_pkg.command_execution.general_command(reader, writer, bin_list, command, stream_source=None)¶ This function executes the query-commands and returns the result message.
- Parameters
reader – The stream reader of the Secondo object.
writer – The stream writer of the Secondo object.
bin_list – A boolean value for result format of the result list returned from Secondo server.
command – The command to be executed.
stream_source – This is an optional parameter given as a list containning the tuples
to be sent to Secondo as a stream when the query contains the operator pyreceive[]. :return: The result received from Secondo by calling the function receive_secondo_response().
-
async
libs_pkg.command_execution.restore_command(reader, writer, bin_list, command)¶ This function executes the commands containing restore keyword and returns the result message.
- Parameters
reader – The stream reader of the Secondo object.
writer – The stream writer of the Secondo object.
bin_list – A boolean value for result format of the result list returned from Secondo server.
command – The command to be executed.
- Returns
The result received from Secondo by calling the function receive_secondo_response().
-
async
libs_pkg.command_execution.save_command(reader, writer, bin_list, command)¶ This function executes the commands containing save keyword and returns the result message.
- Parameters
reader – The stream reader of the Secondo object.
writer – The stream writer of the Secondo object.
bin_list – A boolean value for result format of the result list returned from Secondo server.
command – The command to be executed.
- Returns
The result received from Secondo by calling the function receive_secondo_response().
libs_pkg.exception_handler module¶
This dictionary contains all error codes and descriptions of errors for Secondo server.
-
exception
libs_pkg.exception_handler.GeneralError(error, *args)¶ Bases:
ExceptionThis exception class is the base class of all other error exceptions, used to catch all errors with one single except statement.
-
__init__(error, *args)¶ Initialize self. See help(type(self)) for accurate signature.
-
-
exception
libs_pkg.exception_handler.SecondoAPI_Error(error, *args)¶ Bases:
libs_pkg.exception_handler.GeneralErrorThe class that is responsible for raising Exception for errors that are related to the PySecondo interface rather than the database itself.
-
__init__(error, *args)¶ Initialize self. See help(type(self)) for accurate signature.
-
-
exception
libs_pkg.exception_handler.SecondoError(error, *args)¶ Bases:
libs_pkg.exception_handler.GeneralErrorThe class that is responsible for raising Exception for errors that are related to the database.
-
__init__(error, *args)¶ Initialize self. See help(type(self)) for accurate signature.
-
-
exception
libs_pkg.exception_handler.UnexpectedSystemError(error, *args)¶ Bases:
libs_pkg.exception_handler.SecondoErrorThe class that is responsible for raising Exception for errors that are related to the database’s operation e.g. an unexpected disconnect, the data source name not found, a transaction could not be processed, a memory allocation error, etc.
-
__init__(error, *args)¶ Initialize self. See help(type(self)) for accurate signature.
-
libs_pkg.nested_list module¶
-
libs_pkg.nested_list.change_nl_item_type(seq)¶ The function change_nl_item_type() modifies the type of string items in a nested list to proper types in python according to their values.
- Parameters
seq – An iterable data structure like nested list.
- Returns
The modified iterable.
-
libs_pkg.nested_list.change_nl_item_val(seq, what, make)¶ The function change_nl_item_val updates the value of a specific item in a nested list with unknown depth and structure to another given value.
- Parameters
seq – An iterable data structure like nested list.
what – The value that should be modified.
make – The vlue that should replace the original value.
- Returns
The modified iterable.
-
libs_pkg.nested_list.change_nl_text_form(seq)¶ The function change_nl_text_form() modifies the value of items of type text in a nested list with form ‘****’ to <text>****</text—> form.
- Parameters
seq – An iterable data structure like nested list.
- Returns
The modified iterable.
-
class
libs_pkg.nested_list.dbl_quot¶ Bases:
str
-
libs_pkg.nested_list.item_type(item)¶ The function item_type() detect the type of an item in a pythonic list and maps it to a secondo data type.
- Parameters
item – An elemt in an iterable like a nested list.
- Returns
The relevant data type in Secondo nested lists as a string.
-
libs_pkg.nested_list.nl_parse(content, ftype)¶ The function nl_parse() parses a Secondo NestedList to a Python Nestedlist.
- Parameters
content – The nested list to be parsed.
ftype – A boolean value which tells if the first parameter is a string containing the nested list(False) or a file name(True).
- Returns
The python nested list.
-
libs_pkg.nested_list.nl_to_String(NL)¶ The function nl_to_String() converts a pythonic nested list to a textual nestedlist with nested parenthesis that matches the nested list format in Secondo.
- Parameters
NL – The nested list to be changed.
- Returns
The Secondo nested list.
libs_pkg.read_binary_format module¶
The module read_binary_format defines the function that reads the stream of data from Secondo server which contains the result of commands/ queries in binary format and decodes them to textual format.
-
async
libs_pkg.read_binary_format.binary_decode(reader)¶ This function binary_decode() reads a binary byte from stream of data from Secondo server which contains the result of commands/ queries in binary format. The read byte represents the type of next element in the stream. The function then decodes the element to textual format according to read type.
- Parameters
reader – The stream reader of the Secondo object that receives the result from Secondo Server.
- Returns
The decoded element in the result list.
libs_pkg.secondo_results module¶
The module secondo_results contains two functions for receiving the results from Secondo and decoding the result to textual format if the default seocndo result format is binary.
-
async
libs_pkg.secondo_results.receive_query_result_list(reader, final_token, bin_list)¶ The function receive_query_result_list() reads the result list after execution of commands/ queries from stream reader of the Secondo object until reaching the final token then stops reading. If the the default seocndo result format is binary it calls another function for decoding the result to textual format.
- Parameters
reader – The stream reader of the Secondo object.
final_token – Stops reading by receiving this element from the stream.
bin_list – A binary value that defines the default seocndo result format, True when binary and False when textual nested list.
- Returns
The result list in textual/ binary format.
-
async
libs_pkg.secondo_results.receive_secondo_response(reader, bin_list)¶ This function receive_secondo_response() reads the response of the Secondo server after execution of commands/ queries from stream reader of the Secondo object until reaching specific tags. It calls the function receive_query_result_list() when receiving the <SecondoResponse> tag to get the actual result list.
- Parameters
reader – The stream reader of the Secondo object.
bin_list – A binary value that defines the default seocndo result format, True when binary and False when textual nested list.
- Returns
The result list in textual/ binary format.
libs_pkg.write_binary_format module¶
-
async
libs_pkg.write_binary_format.binary_encode(writer, NL)¶ The function binary_encode() converts each element of the nested list to binary format and writes them to the stream writer of Secondo object which is connected to Secondo server.
- Parameters
writer – Stream writer of the Secondo object.
NL – The nested list to be converted.
- Returns
True if the conversion is succesful and Flase when not.
-
libs_pkg.write_binary_format.binary_type(item)¶ The function binary_type() returns the aquivalent binary type of the item in a nested list according to the data types of the nested lists in Secondo. :param item: An element in nested list. :return: The binary data type.
-
async
libs_pkg.write_binary_format.write_binary_header(writer, NL)¶ The function write_binary_header() writes the binary header which contains signature and version to the stream writer of Secondo object which is connected to Secondo server and converts each element of the nested list to binary format by calling the function binary_encode().
- Parameters
writer – Stream writer of the Secondo object.
NL – The nested list to be converted.
- Returns
True if the conversion is succesful Flase when not.