mib_generator.gui package

This sub-package provides a simple GUI for the MIB Generator.

The GUI is utilised through the Qt6 framework joint with its Python bindings PySide6. The files in this folder/sub-package hence follow the format of Qt Creator project. The GUI is however not completely isolated from the rest of the mib_generator package and parts of the logic unique to the GUI are also found e.g. in the mib_generator.data.warn or mib_generator.temp.temp modules.

The modules/files here are:

  • gui - A module holding the declaration and logic of the GUI as well as its initialisation function.

  • form.ui - An XML file holding description of all objects in the GUI, their layout, connections, etc.

  • ui_form - A module holding description of the GUI as Python objects. Automatically generated from the form.ui file.

  • mib_gui.pyproject and mib_gui.pyproject.user - Files associated with the Qt Creator project which makes up the GUI.

Submodules

mib_generator.gui.gui module

The main GUI module.

This module initialises and runs the GUI for the program which uses the Qt framework. The majority of the GUI structure is declared in the mib_generator.gui.ui_form module and here the main-window class MainWindow contains mostly the logic interconnecting various parts of the GUI and their connections to the main program itself (the documentation of MainWindow is not in Sphinx right now because of a bug in PySide6).

class mib_generator.gui.gui.MainWindow(parent=None)[source]

Bases: QMainWindow

Cfile(field)[source]

Open a dialog for choosing files and use the output.

Opens a system dialog for choosing files and lets the user choose an input .c/.h files through it. It then assigns the paths to the chosen locations to the passed text field.

Parameters:

field (PySide6.QtWidgets.QPlainTextEdit) – A text window to which the outputted location is to be filled.

DOCgen()[source]

Generates a .docx document summing up the results of the construction process.

Takes the list of representations of TC and TM packets and generates an entry in a .docx document based on each of them. It then assigns this value to the docum attribute.

DOCsave()[source]

Save the generated .docx document .

Looks up the location where the document should be saved to and saves it ther.

Dfile()[source]

Open a dialog for choosing a file and use the output.

Opens a system dialog for choosing file and lets the user choose an input .docx file through it. It then assigns the path to the chosen location to the .docx path text field.

MIBgen()[source]

Generates MIB tables based on all computation done so far.

With all so far constructed representations (Tm packets, Tc commands, calibrations, etc…) taken into account as well as used config settings, generates the corresponding MIB tables. Also adjusts the GUI appropriately based on the result and saves the generation output to the tables attribute.

MIBsave()[source]

Save the generated MIB tables to .dat files.

Looks up the directory where the tables should be saved to in the runtime config files and saves them there.

TcHshow()[source]

Show GUI representations of parsed Tc .h file.

Opens new window with visual representation of what the parser found/interpreted inside the Tc .h file.

TcTmHshow()[source]

Show GUI representations of parsed TcTm .h file.

Opens new window with visual representation of what the parser found/interpreted inside the TcTm .h file.

Tcinter()[source]

Interpret the Tc packets/commands found in the parsed files.

This method runs the code from the mib_generator.construction module which interprets the parsed files relating to TC packets and constructs appropriate Python representations of the included objects from them. It updates the list of decalibrations dec, verifications ver, the list of TC packets/commands tcs and the TC header TcHead. It also enables buttons for subsequent computation if everything runs correctly.

TmCshow()[source]

Show GUI representations of parsed Tm .c file.

Opens new window with visual representation of what the parser found/interpreted inside the Tm .c file.

TmHshow()[source]

Show GUI representations of parsed Tm .h file.

Opens new window with visual representation of what the parser found/interpreted inside the Tm .h file.

Tminter()[source]

Interpret the Tm packets found in the parsed files.

This method runs the code from the mib_generator.construction module which interprets the parsed files relating to TM packets and constructs appropriate Python representations of the included objects from them. It updates the list of calibrations cal, list of TM packets tms and the TM header TmHead. It also enables buttons for subsequent computation if everything runs correctly.

clean(stri, tok={'\t', '\n', ' ', '"', "'"})[source]

Clean the passed string of the passed tokens.

Replaces all tokens in the passed strings with nothing (deletes them). By default with no tokens passed, deletes all whitespace characters in the string.

Parameters:
  • stri (str) – String which is to be cleaned.

  • tok (set) – Set of tokens to be deleted from the string.

Returns:

The string after cleaning.

Return type:

str

compute()[source]

Click all computation buttons in sequential order.

This links all the computation to one button, be clicking of which the user effectively clicks all of the computational buttons (if they are disabled, then nothing happens) sequentially.

def_config()[source]

Fill in the path to default config directory to the config directory field.

Gets path to the default config location (it is the mib_generator.data sub-package/directory) and fills it to the config directory input text field.

direc(field)[source]

Open a dialog for choosing a directory and use the output.

Opens a system dialog for choosing a directory and lets the user choose an output directory through it. It then assigns the path to the chosen location to the passed text field.

Parameters:

field (PySide6.QtWidgets.QPlainTextEdit) – A text window to which the outputted location is to be filled.

dist_paths(dic)[source]

Distribute input/output paths across various GUI fields.

This method takes the paths specified in the passed dictionary and based on their keys, assigns them to appropriate input text across the GUI.

evalu(stri)[source]

Evaluates string for boolean values.

Just simple case matching of string to a boolean values.

Parameters:

stri (str) – The string to be evaluated.

Returns:

The result of evaluation.

Return type:

bool

load_config()[source]

Load all data from config files in the specified directory.

This method first looks for config files in the specified directory, if it finds any, it copies them to the runtime config directory and from there loads their content to all the appropriate text fields in the GUI.

mib_use()[source]

Use the config settings for mib tables generation.

This method saves the config setting for mib tables generation (filled out in the GUI input field) by copying them to the runtime config files.

nam_use()[source]

Use the config settings for parameter name creation.

This method saves the config setting for parameter name creation (filled out in the GUI input field) by copying them to the runtime config files.

parse()[source]

Runs the parsing logic and modifies the GUI correspondingly.

This module runs all the parsing from the mib_generator.parsing.load module and then depending on the results for each file either enables or disables GUI buttons that would run subsequent computation or show the parsing results. Also raises warnings/errors if anything fails.

pre_use()[source]

Use the config settings for pre-processor parsing.

This method saves the config setting for per-processor parsing (filled out in the GUI input field) by copying them to the runtime config files.

save_config()[source]

Saves all the currently filled out information to a directory.

This method first applies all the present (filled out in various GUI fields) information by saving them to the runtime config files and them copies these files to the directory specified in the config directory field.

staticMetaObject = PySide6.QtCore.QMetaObject("MainWindow" inherits "QMainWindow": Methods:   #40 type=Slot, signature=compute()   #41 type=Slot, signature=parse()   #42 type=Slot, signature=TmHshow()   #43 type=Slot, signature=TcHshow()   #44 type=Slot, signature=TmCshow()   #45 type=Slot, signature=TcTmHshow()   #46 type=Slot, signature=Tminter()   #47 type=Slot, signature=Tcinter()   #48 type=Slot, signature=MIBgen()   #49 type=Slot, signature=DOCgen()   #50 type=Slot, signature=MIBsave()   #51 type=Slot, signature=DOCsave()   #52 type=Slot, signature=Cfile()   #53 type=Slot, signature=direc()   #54 type=Slot, signature=Dfile()   #55 type=Slot, signature=use_paths()   #56 type=Slot, signature=def_config()   #57 type=Slot, signature=load_config()   #58 type=Slot, signature=save_config()   #59 type=Slot, signature=mib_use()   #60 type=Slot, signature=pre_use()   #61 type=Slot, signature=nam_use() )
to_field(stri)[source]

Convert the passed string/list to an easily readable format.

Takes an inputted string/list and based on its outlook formats it so that it is easily readable/editable by the user (cleans it of redundant whitespaces, adds separators, new lines).

Parameters:

stri (str or object) – An object/string to be reformatted.

Returns:

The reformatted string.

Return type:

str

use_paths()[source]

Use the paths specified in the input field.

Gets all the contents of the paths input fields, saves them to the runtime config files found in the mib_generator.temp sub-package/directory and loads them. Raises various warnings if anything goes wrong.

mib_generator.gui.gui.gui_run()[source]

Run the GUI.

This method runs the GUI as a Qt application, which means that it is “self-contained” and upon closing it also ends the thread in which it was run (hence multiprocessing has to be used in order to run it as part of some larger program).

mib_generator.gui.gui_methods module

mib_generator.gui.ui_form module

class mib_generator.gui.ui_form.Ui_MainWindow[source]

Bases: object

retranslateUi(MainWindow)[source]
setupUi(MainWindow)[source]