mib_generator.utilities package
These modules serve various side roles which are not essential to the functioning of the main generation scipt but make user interaction with it more straightforward, automatic and pleasant.
The submodules here are:
data_gen- Module that helped automate inputting all MIB tables parameters into themib_generator.data.longdatafile/method. Unused now.
update- Module holding methods that create a small CLI interface (accessible from terminal if the main script is run with appropriate flags) that allows the user to update the configuration options and input/output paths.
visualiser- Module that provides a GUI representation of the Python objects created by parsing the inputted files. Useful mostly for checking the correct functioning of the parser.
Submodules
mib_generator.utilities.data_gen module
This is just a quick script that helped me automate translating the information about structure and characteristics
of MIB tables into Python (now stored in mib_generator.data.longdata).
mib_generator.utilities.update module
Various CLI scripts that update various files that configure the generation process.
This module holds methods that allow the user to easily modify various files that affects the behaviour of the main Python script. They can be called by simply importing and calling them or through appropriate flags build into the main CLI of the MIB generator.
- mib_generator.utilities.update.update_config_d(directory=None)[source]
Run a series of queries asking user to specify parsing configuration parameters.
This method allows the user to specify configuration parameters to be used by the parsing pre-processor (i.e. say, whether the macro is defined or not). First, the already saved parameters are loaded and the user is asked whether he wants to keep the current value, change it or delete the parameter altogether. Then, the user is given the option to create a new parameter. The only valid accepted of parameters are boolean or a string.
All of this happens with respect to either a config file specified through the passed
directoryparameter or w.r.t. the default config file which is located inmib_generator.data.- Parameters:
directory (str) – String with the location of the directory in which the config file to be modified is located.
- mib_generator.utilities.update.update_config_m(directory=None)[source]
Run a series of queries asking user to specify generation configuration parameters.
This method allows the user to specify configuration parameters to be used at the generation step (i.e. the list of the MIB databases to be generated). First, the already saved parameters are loaded and the user is asked whether he wants to keep, change or delete them. Then, the user is given the option to create a new parameter. The only valid accepted of parameters are strins.
All of this happens with respect to either a config file specified through the passed
directoryparameter or w.r.t. the default config file which is located inmib_generator.data.- Parameters:
directory (str) – String with the location of the directory in which the config file to be modified is located.
- mib_generator.utilities.update.update_config_n(directory=None)[source]
Run a series of queries asking user to specify parameter name creation configuration parameters.
This method allows the user to specify configuration parameters to be used at the parameter construction step (i.e. what form should the names of the parameters take. There are four parameters which define these settings and the user is asked about the value of each of them which he can either change or leave the previous.
All of this happens with respect to either a config file specified through the passed
directoryparameter or w.r.t. the default config file which is located inmib_generator.data.- Parameters:
directory (str) – String with the location of the directory in which the config file to be modified is located.
- mib_generator.utilities.update.update_path(directory=None)[source]
Run a series of queries asking user to specify valid paths to input files.
This method allows the user to specify paths to the 4 input files and 1 output directory that the MIB generator requires. The previously stored values are shown to the user and he can leave them be or choose to modify them stating the location of the target files either in terms of absolute or relative path. The inputted location is then checked and if it exists, then the path is saved (in absolute form). Only existence is checked, not that the file is valid for the given purpose.
All of this happens with respect to either a paths config file specified through the passed
directoryparameter or w.r.t. the default paths config file which is located inmib_generator.data.- Parameters:
directory (str) – String with the location of the directory in which the paths config file to be modified is located.
mib_generator.utilities.visualiser module
Allow a GUI representation of the parsed data.
This module allows the user to see the output of the parsing process, i.e. the tree of the Python objects that were created as a representation of the original C-files. For the creation of the GUI the Qt framework is used in connection with its Python toolkit/bindings PySide-6.
- class mib_generator.utilities.visualiser.CommentWindow(comment)[source]
Bases:
QWidget- staticMetaObject = PySide6.QtCore.QMetaObject("CommentWindow" inherits "QWidget": )
- class mib_generator.utilities.visualiser.MainWindow(struct)[source]
Bases:
QMainWindow- staticMetaObject = PySide6.QtCore.QMetaObject("MainWindow" inherits "QMainWindow": )
- class mib_generator.utilities.visualiser.TextWindow(text)[source]
Bases:
QWidget- staticMetaObject = PySide6.QtCore.QMetaObject("TextWindow" inherits "QWidget": )
- class mib_generator.utilities.visualiser.Ui_MainWindow[source]
Bases:
objectThis class holds functions that build up geometry and objects in the main window.
In case of this application, the UI has to be dynamically created, i.e. the number of entries in a toolbox has to change depending on the number of structures that need to be displayed. Because of this, this class which holds the description of the UI of the main visualisation window is perhaps more complicated than usual. Its base layout is created in
setupUi, but this includes a recursive reference tointer, which always creates a visualisation of contents of some object (i.e. shows a list of some objects as entries in a toolbox). Since structures can be members of structures,intercan also call itself, hence the recursivity.- inter(struct)[source]
Recursively create entries for each C-object in the parsed file.
For any passed parsed object, creates an appropriate representation through a Qt Widget. Since such object can also be a
struct, this function is sometimes called recursively. For some objects it also creates buttons which can open other windows which visualise associated comments or e.g. long section of the original C-file.- Parameters:
struct (child-class of parsing.par_header.structure or parsing.par_cfile.instance_og) – The object to be visualised by the custom-created Qt Widget.
- Returns:
Qt widget representing the passed object.
- Return type:
QFrame
- setupUi(MainWindow, struct)[source]
Builds up the UI of the Main window.
This is done dynamically based on the nature of the passed file representation. See
Ui_MainWindowfor more info.- Parameters:
MainWindow (QMainWindow) – Base Qt object in which this UI is build.
struct (parsing.parser_main.file) – The Python representation of a file on basis of which the UI will be constructed.
- view_comments(comment)[source]
Show a window with comments.
This method when called opens a window showing the passed comment.
- Parameters:
comment (list) – List of comments to be shown in the new window. Each of type
mib_generator.parsing.par_methods.comment.
- mib_generator.utilities.visualiser.getdata(struct)[source]
Extract all posible showable (str, int) data about an object
From a list of attributes that the passed object has, extracts the interesting ones (which are not buildins for any Python object) and if they have showable value (their value is either
strorintand it isn’t the whole text of the corresponding C code found in the original C-file), adds this attribute-value pair to a list. It also tries to substitute the name of the attribute with a more human-readable name by looking it up inmib_generator.data.longdata.translation.- Parameters:
struct (any Python object really) – The object who’s attributes are to be extracted.
- Returns:
A list holding all “interesting” attributes of the original object jointly with their values.
- Return type:
list
- mib_generator.utilities.visualiser.intable(table, data)[source]
Add the given data to the given table.
This method takes a table (its representation as a Qt widget) and inputs the passed data into its rows and columns. It expects the inputted data to be a list of pairs.
- Parameters:
table (QTableWidget) – The Qt table to which the data is to be added.
data (list) – List of pairs representing the data to be added to the table.
- mib_generator.utilities.visualiser.main(struct=[None])[source]
For each file create a process and run the visualiser in it.
This method creates (or rather starts the process of creating) a visualisation window for each of the files in the passed list. In order to do this it has to create a separate new process for each of the files since otherwise closing the windows would exit the whole Python runtime.
- mib_generator.utilities.visualiser.runt(struct)[source]
Run the app in one process.
This method first creates the UI based on the passed file representation and then runs it as a Qt app.
At the exit, this method kills the whole process so it should be isolated into separate process if it is only called by some additional code which is supposed to continue running.
- Parameters:
struct (parsing.parser_main.file) – The Python representation of the file on basis of which the visualisation will be constructed.