mafw.examples.db_processors
The module provides some basic processors with DB interaction for demonstrating the basic functionalities.
Classes
|
A processor to count the number of standard tables |
|
The Model class representing the table in the database |
|
Processor to fill a table with the content of a directory |
Exceptions
Exception raised if the table corresponding to the File model does not exist. |
- exception mafw.examples.db_processors.FileDoesNotExist[source]
Bases:
ExceptionException raised if the table corresponding to the File model does not exist.
- class mafw.examples.db_processors.CountStandardTables(*args: Any, **kwargs: Any)[source]
Bases:
ProcessorA processor to count the number of standard tables
Processor parameters
n_tables: The number of standard tables (default: -1)
Constructor parameters
- Parameters:
name (str, Optional) – The name of the processor. If None is provided, the class name is used instead. Defaults to None.
description (str, Optional) – A short description of the processor task. Defaults to the processor name.
config (dict, Optional) – A configuration dictionary for this processor. Defaults to None.
looper (LoopType, Optional) – Enumerator to define the looping type. Defaults to LoopType.ForLoop
user_interface (UserInterfaceBase, Optional) – A user interface instance to be used by the processor to interact with the user.
timer (Timer, Optional) – A timer object to measure process duration.
timer_params (dict, Optional) – Parameters for the timer object.
database (Database, Optional) – A database instance. Defaults to None.
database_conf (dict, Optional) – Configuration for the database. Default to None.
remove_orphan_files (bool, Optional) – Boolean flag to remove files on disc without a reference to the database. See Standard tables and
_remove_orphan_files(). Defaults to Truekwargs – Keyword arguments that can be used to set processor parameters.
- process()[source]
Processes the current item.
This is the core of the Processor, where the user has to define the calculations required.
- start() None
Start method.
The user can overload this method, including all steps that should be performed at the beginning of the operation.
If the user decides to overload it, it should include a call to the super method.
- class mafw.examples.db_processors.File(*args, **kwargs)[source]
Bases:
MAFwBaseModelThe Model class representing the table in the database
- DoesNotExist
alias of
FileDoesNotExist
- class mafw.examples.db_processors.FillFileTableProcessor(*args: Any, **kwargs: Any)[source]
Bases:
ProcessorProcessor to fill a table with the content of a directory
Processor parameters
root_folder: The root folder for the file listing (default: PosixPath(‘/tmp/mafw-docs-d16l86xo/v1.4.0’))
Constructor parameter:
- Parameters:
root_folder (Path, Optional) – ActiveParameter corresponding to the directory from where to start the recursive search
- format_progress_message()[source]
Customizes the progress message with information about the current item.
The user can overload this method in order to modify the message being displayed during the process loop with information about the current item.
The user can access the current value, its position in the looping cycle and the total number of items using
Processor.item,Processor.i_itemandProcessor.n_item.