populse_mia.user_interface.pipeline_manager.process_library

Module that contains class and methods to process the different libraries of the project.

Functions

import_file(full_name, path)

Import a Python module from a file without registering it in sys.modules.

node_structure_from_dict(datadict[, parent, ...])

Construct a hierarchical node structure from a dictionary.

Classes

DictionaryTreeModel(root[, parent])

Data model providing a tree structure for an arbitrary dictionary.

InstallProcesses(main_window, folder)

Dialog for installing Python packages from a folder or zip file.

Node(name[, parent])

A tree-like structure to manage hierarchical data with parent-child relationships.

PackageLibrary(package_tree, paths)

A tree widget that displays user-added packages and their modules.

PackageLibraryDialog([mia_main_window, parent])

Dialog for managing package library configurations.

ProcessLibrary(d, pkg_lib)

A tree view to display available Capsul's processes.

ProcessLibraryWidget([main_window])

Widget that manages the available Capsul's processes in the software.

class populse_mia.user_interface.pipeline_manager.process_library.DictionaryTreeModel(root, parent=None)[source]

Bases: QAbstractItemModel

Data model providing a tree structure for an arbitrary dictionary.

This model is designed to represent a dictionary as a tree structure, enabling interaction with the data through a tree view.

Contains:
Methods:
  • columnCount: Return always 1.

  • data: Return the data requested by the view.

  • flags: Everything is enabled and selectable, only the leaves can be dragged.

  • getNode: Return a Node() from given index.

  • headerData: Return the name of the requested column.

  • index: Return an index from given row, column and parent.

  • insertRows: Insert rows from starting position and number given by rows.

  • mimeData: Used when the widget is dragged by the user.

  • mimeTypes: Return a constant.

  • parent: return the parent from given index.

  • removeRows: Remove the rows from position to position+rows.

  • rowCount: The number of rows is the number of children.

  • setData: Method called when the user changes data.

  • to_dict: return the root node as a dictionary.

__init__(root, parent=None)[source]

Initializes the DictionaryTreeModel with a root node.

Parameters:
columnCount(parent=None)[source]

Returns the number of columns, which is always 1.

Parameters:

parent (QModelIndex) – The parent index (unused in this implementation).

Returns:

The number of columns.

Return type:

int

data(index, role)[source]

Returns the data associated with the item at the given index and role.

This method is called by Qt’s model/view framework to retrieve data for a model item. The role specifies how the data will be used, for example, Qt.DisplayRole for displaying the item or Qt.EditRole when editing it.

Parameters:
  • index (QModelIndex) – The model index of the item for which data is requested.

  • role (int) – The Qt item-data role specifying the type or purpose of the requested data, such as Qt.DisplayRole or Qt.EditRole.

Returns:

The item’s name for Qt.DisplayRole and Qt.EditRole, or None if the index is invalid or the role is not handled.

Return type:

str | None

flags(index)[source]

Get the item flags for the specified index.

Parameters:

index (QModelIndex) – The model index to retrieve flags for.

Returns:

The corresponding item flags.

Return type:

ItemFlags

getNode(index)[source]

Retrieves the Node object from the given index.

Parameters:

index (QModelIndex) – The index of the node.

Returns:

The Node object.

Return type:

populse_mia.user_interface.pipeline_manager.process_library.Node

headerData(section, orientation, role)[source]

Returns the header label for the given section.

Parameters:
  • section (int) – The section number for which to retrieve the header label.

  • orientation (Orientation) – The orientation of the header, either horizontal or vertical. This parameter is unused in this implementation.

  • role (int) – The role for which to retrieve the header data. Only Qt.DisplayRole is handled by this implementation.

Returns:

The header label for the requested section, or None if the section or role is not handled.

Return type:

str | None

index(row, column, parent)[source]

Creates an index for the given row, column, and parent.

Parameters:
  • row (int) – The row number.

  • column (int) – The column number.

  • parent (QModelIndex) – The parent index.

Returns:

The created index, or an invalid index if not available.

Return type:

QModelIndex

insertRows(position, rows, parent=<PyQt5.QtCore.QModelIndex object>)[source]

Inserts rows starting from the specified position.

Parameters:
  • position (int) – The starting position to insert rows.

  • rows (int) – The number of rows to insert.

  • parent (QModelIndex) – The parent index.

Returns:

True if the rows were successfully inserted, False otherwise.

Return type:

bool

mimeData(indexes)[source]

Return MIME data for the specified model indexes.

The data associated with each valid index is encoded as bytes and concatenated into a single QByteArray, which is stored under the "component/name" MIME type.

Parameters:

indexes (list[QModelIndex]) – The model indexes to include in the MIME data.

Returns:

MIME data containing the encoded data associated with the specified indexes.

Return type:

QMimeData

mimeTypes()[source]

Returns the supported MIME types.

Returns:

A list of supported MIME types.

Return type:

list[str]

parent(index)[source]

Returns the parent index for the given index.

Parameters:

index (QModelIndex) – The index of the item.

Returns:

The parent index, or an invalid index if not available.

Return type:

QModelIndex

removeRows(position, rows, parent=<PyQt5.QtCore.QModelIndex object>)[source]

Removes rows starting from the specified position to position+rows.

Parameters:
  • position (int) – The starting position to remove rows.

  • rows (int) – The number of rows to remove.

  • parent (QModelIndex) – The parent index.

Returns:

True if all rows were successfully removed, False otherwise.

Return type:

bool

rowCount(parent)[source]

Returns the number of rows, which corresponds to the number of children.

Parameters:

parent (QModelIndex) – The parent index.

Returns:

The number of rows.

Return type:

int

setData(index, value, role=2)[source]

Updates the data when the user makes changes.

Parameters:
  • index (QModelIndex) – The index of the item.

  • value (str) – The new value to set.

  • role (ItemDataRole) – The role of the data to set.

Returns:

True if the data was successfully set, False otherwise.

Return type:

bool

to_dict()[source]

Converts the root node to a dictionary.

Returns:

The dictionary representation of the root node.

Return type:

dict

class populse_mia.user_interface.pipeline_manager.process_library.InstallProcesses(main_window, folder)[source]

Bases: QDialog

Dialog for installing Python packages from a folder or zip file.

This widget allows users to browse and select a Python package or zip file containing packages, then install them into Mia.

Contains:
Methods:
  • _add_package: Add a package and its modules to the process tree.

  • _change_pattern_in_folder: Replace pattern in all Python files within a folder.

  • _install_new_package: Install a new package.

  • _load_process_config: Load the process configuration from YAML.

  • _rollback_changes: Roll back changes in case of installation failure.

  • _show_qmessagebox: Display an error message box.

  • _show_status_message: Update status message in the main window.

  • _update_existing_package: Update an existing package.

  • _validate_input: Validate the input file or directory.

  • get_filename: Opens a file dialog to get the folder or zip file to install.

  • install: Installs the selected file/folder on Populse_mia.

Signals:
  • process_installed: Signal emitted when a process is successfully installed.

__init__(main_window, folder)[source]

Initialize the installation dialog.

Parameters:
_add_package(proc_dic, module_name)[source]

Add a package and its modules to the process tree.

Parameters:
  • proc_dic (dict) – The process tree dictionary to update.

  • module_name (str) – Name of the module to add.

Returns:

The updated process tree dictionary.

Return type:

dict

_change_pattern_in_folder(path, old_pattern, new_pattern)[source]

Replace pattern in all Python files within a folder.

Parameters:
  • path (str) – Directory path to process.

  • old_pattern (str) – Pattern to search for.

  • new_pattern (str) – Pattern to replace with.

_install_new_package(filename, package_name, processes_path)[source]

Install a new package.

Parameters:
  • filename (str) – Path to zip file or directory.

  • package_name (str) – Name of the package to install.

  • processes_path (str) – Target directory for installation.

_load_process_config(config_path)[source]

Load the process configuration from YAML.

Parameters:

config_path (str) – Path to the configuration file.

Returns:

The loaded configuration or empty dict if error.

Return type:

dict

_rollback_changes(config_path, original_config, processes_path, package_names, mia_processes_not_found, tmp_folder4MIA)[source]

Roll back changes in case of installation failure.

Parameters:
  • config_path (str) – Path to configuration file.

  • original_config (dict) – Original configuration to restore.

  • processes_path (str) – Path to processes directory.

  • package_names (list) – Names of packages that were being installed.

  • mia_processes_not_found (bool) – Flag indicating if Mia processes backup was made.

  • tmp_folder4MIA (str) – Path to Mia processes backup.

_show_qmessagebox(message, critical=True)[source]

Display an error message box.

Parameters:
  • message (str) – Message to display.

  • critical (bool) – If True, display a critical message box.

_show_status_message(message)[source]

Update status message in the main window.

Parameters:

message (str) – Status message to display.

_update_existing_package(filename, package_name, processes_path)[source]

Update an existing package.

Parameters:
  • filename (str) – Path to zip file or directory.

  • package_name (str) – Name of the package to update.

  • processes_path (str) – Target directory for installation.

Returns:

The new package name (with timestamp).

Return type:

str

_validate_input(filename)[source]

Validate the input file or directory.

Parameters:

filename (str) – Path to the file or directory.

Returns:

True if valid, False otherwise

Return type:

bool

get_filename(folder)[source]

Open a file dialog to select the package source.

Parameters:

folder (bool) – If True, opens a directory selection dialog; If False, opens a zip file selection dialog.

install()[source]

Install a package from a zip file or a folder.

This method handles the complete installation process:
  1. Extracts or copies the package to the processes directory.

  2. Updates the process dictionary.

  3. Registers the new package in the configuration.

Any exceptions during installation are caught and reported to the user, with automatic rollback of any changes made.

class populse_mia.user_interface.pipeline_manager.process_library.Node(name, parent=None)[source]

Bases: object

A tree-like structure to manage hierarchical data with parent-child relationships.

This class provides functionality to create and manipulate tree nodes, where each node can have a name, value, parent, and multiple children.

Contains:
Methods:
  • __repr__: Define what should be printed by the class.

  • _recurse_dict: Recursively build a dictionary representation of the node hierarchy.

  • addChild: Add a child to the children list.

  • attrs: Get attributes of this node as a dictionary.

  • child: Return a child from its index in the list.

  • childCount: return the number of children.

  • data: Return the name or the value of the object.

  • insertChild: Insert a child to a specific position.

  • log: Generate a formatted string representation of the node hierarchy.

  • name: Gets or sets the name of the node.

  • parent: Return the parent of the node.

  • removeChild: Remove a child node at the specified position.

  • resource: Placeholder that always returns None.

  • row: Return the index of the object in its parent list of children.

  • setData: Update the name or the value of the object.

  • to_dict: Convert the node hierarchy to a dictionary.

  • to_list: Convert the node hierarchy to a list.

  • value: Gets or sets the value of the node.

__init__(name, parent=None)[source]

Initialize a new Node instance.

Parameters:
_recurse_dict(d)[source]

Recursively build a dictionary representation of the node hierarchy.

Parameters:

d (dict) – The dictionary to populate with the node hierarchy.

addChild(child)[source]

Add a child node to this node.

Parameters:

child (populse_mia.user_interface.pipeline_manager.process_library.Node) – The child node to add.

attrs()[source]

Get attributes of this node as a dictionary.

Returns:

A dictionary of property names and their values.

Return type:

dict

child(row)[source]

Get a child node by its index.

Parameters:

row (int) – The index of the child node in the children list.

Returns:

The child node at the specified index.

Return type:

populse_mia.user_interface.pipeline_manager.process_library.Node

childCount()[source]

Get the number of children of this node.

Returns:

The number of child nodes.

Return type:

int

data(column)[source]

Get data about this node based on the column parameter.

Parameters:

column (int) – 0 for the fully qualified name (including parent names), 1 for the value of this node.

Returns:

The requested data (either string path or node value).

Return type:

str

insertChild(position, child)[source]

Insert a child node at a specific position.

Parameters:
Returns:

True if insertion was successful, False otherwise.

Return type:

bool

log(tabLevel=-1)[source]

Generate a formatted string representation of the node hierarchy.

Parameters:

tabLevel (int) – The current indentation level. Defaults to -1.

Returns:

A formatted string showing the node hierarchy.

Return type:

str

property name

Get the name of this node.

Returns:

The name of the node.

Return type:

str

parent()[source]

Get the parent of this node.

Returns:

The parent node or None if this is a root node.

Return type:

populse_mia.user_interface.pipeline_manager.process_library.Node | None

removeChild(position, child)[source]

Remove a child node at the specified position.

Parameters:
Returns:

True if removal was successful, False otherwise.

Return type:

bool

resource()[source]

Get resource information for this node.

This method is a placeholder that always returns None.

Returns:

None.

Return type:

None

row()[source]

Get the index of this node in its parent’s children list.

Returns:

The index of this node in its parent’s children list, or None if this node has no parent.

Return type:

int | None

setData(column, value)[source]

Set the name or value of this node based on the column parameter.

Parameters:
  • column (int) – 0 to set the name, 1 to set the value.

  • value (str) – The new name or value to set.

to_dict(d=None)[source]

Convert the node hierarchy to a dictionary.

Parameters:

d (dict | None) – A dictionary to populate. Defaults to None.

Returns:

A dictionary representation of the node hierarchy.

Return type:

dict

to_list()[source]

Convert the node hierarchy to a list.

Returns:

A list representation of the node hierarchy.

Return type:

list

property value

Get the value of this node.

Returns:

The value of the node.

Return type:

str

class populse_mia.user_interface.pipeline_manager.process_library.PackageLibrary(package_tree, paths)[source]

Bases: QTreeWidget

A tree widget that displays user-added packages and their modules.

This widget allows users to enable or disable packages and modules by checking or unchecking them in the tree view. The tree structure reflects the hierarchical organization of packages and their modules.

Contains:
Methods:
  • fill_item: fills the items of the tree recursively.

  • generate_tree: generates the package tree.

  • recursive_checks: checks/unchecks all child items.

  • recursive_checks_from_child: checks/unchecks all parent items.

  • set_module_view: sets if a module has to be enabled or disabled in the process library.

  • update_checks: updates the checks of the tree from an item.

__init__(package_tree, paths)[source]

Initialize the PackageLibrary widget.

Parameters:
  • package_tree (dict) – Hierarchical representation of packages.

  • paths (list) – System paths for importing the packages.

fill_item(item, value)[source]

Recursively populate the tree items.

Traverses the package tree and creates corresponding QTreeWidgetItems with appropriate check states.

Parameters:
generate_tree()[source]

Generate the package tree structure.

Clears the current tree and populates it with items from package_tree. Temporarily disconnects the itemChanged signal to prevent unwanted updates.

recursive_checks(parent)[source]

Propagate check state down to all child items.

When a parent item is checked/unchecked, all its children inherit the same check state.

Parameters:

parent (QTreeWidgetItem) – Parent item whose check state is propagated.

recursive_checks_from_child(child)[source]

Propagate check state up to parent items.

When a child item is checked, its parents are also checked. When a child item is unchecked, its parent is unchecked only if all siblings are also unchecked.

Parameters:

child (QTreeWidgetItem) – Child item whose check state affects parents.

set_module_view(item, state)[source]

Update the enabled/disabled state of a module in the package tree.

Updates the underlying package_tree data structure according to the check state of the module’s tree item. Qt.Checked has a value of 2, while Qt.Unchecked has a value of 0.

Parameters:
  • item (QTreeWidgetItem) – Tree item corresponding to a module.

  • state (CheckState) – New check state of the module, either Qt.Checked (2) or Qt.Unchecked (0).

update_checks(item, column)[source]

Handle check state changes and propagate them.

When an item’s check state changes, this method ensures the change is properly propagated to children and parent items.

Parameters:
  • item (QTreeWidgetItem) – Item whose check state changed.

  • column (int) – Column index of the change (should be 0).

class populse_mia.user_interface.pipeline_manager.process_library.PackageLibraryDialog(mia_main_window=None, parent=None)[source]

Bases: QDialog

Dialog for managing package library configurations.

This dialog allows users to add, remove, and delete packages from the process library. It provides interfaces for installing packages, updating the package tree, and saving configurations.

Contains:
Methods:
  • _create_button: Create a standardized button.

  • _create_install_buttons: Create buttons for installing processes.

  • _create_line_edit: Create and configure the line edit.

  • _create_list_group: Create a group box for a list with reset functionality.

  • _create_list_widget: Create a list widget with extended selection mode.

  • _create_main_layout: Create the main layout for the dialog.

  • _create_package_management_buttons: Create buttons for package management.

  • _create_save_cancel_layout: Create layout for save and cancel buttons.

  • _create_status_label: Create and configure the status label.

  • _load_initial_configuration: Load initial package configuration.

  • _setup_ui: Set up the user interface components

  • add_package: Add a package and its modules to the package tree.

  • add_package_with_text: Add a package from the line edit text.

  • browse_package: Open a browser to select a package (commented).

  • delete_package: Delete a package (admin-only functionality).

  • delete_package_with_text: Delete a package from the line edit text.

  • install_processes_pop_up: Open popup for installing processes.

  • load_config: Load package configuration from YAML file.

  • load_packages: Update the process library tree.

  • ok_clicked: Handle applying changes to packages.

  • remove_package: Remove a package from the package tree.

  • remove_package_with_text: Remove a package from the line edit text.

  • reset_action: Reset previous package addition or removal actions.

  • save: Save package configuration to process_config.yml.

  • save_config: save the current config to process_config.yml (commented).

  • update_config: Update package configuration and library attributes.

Signals:
  • signal_save: Signal emitted when configuration is saved.

__init__(mia_main_window=None, parent=None)[source]

Initialize the PackageLibraryDialog.

Parameters:
_create_button(text, callback)[source]

Create and configure a push button.

The button is configured not to be the dialog’s default button and not to become the default button automatically.

Parameters:
  • text (str) – Text displayed on the button.

  • callback (callable) – Callback invoked when the button is clicked.

Returns:

Configured push button.

Return type:

QPushButton

_create_install_buttons()[source]

Create buttons for installing processes.

Returns:

Layout with install process buttons.

Return type:

QHBoxLayout

_create_line_edit()[source]

Create and configure the line edit.

Returns:

Configured line edit for package input.

Return type:

QLineEdit

_create_list_group(title, list_widget, reset_callback)[source]

Create a group box for a list with reset functionality.

Parameters:
  • title (str) – Group box title.

  • list_widget (QListWidget) – List widget to add to group.

  • reset_callback (callable) – Callback for reset button.

Returns:

Configured group box with list and reset button.

Return type:

QGroupBox

_create_list_widget()[source]

Create a list widget with extended selection mode.

Returns:

Configured list widget.

Return type:

QListWidget

_create_main_layout(install_layout, management_layout, user_mode)[source]

Create the main layout for the dialog.

Parameters:
  • install_layout (QHBoxLayout) – Layout for install buttons.

  • management_layout (QHBoxLayout) – Layout for package management buttons.

  • user_mode (bool) – Whether the application is in user mode.

Returns:

Main layout of the dialog.

Return type:

QHBoxLayout

_create_package_management_buttons(user_mode)[source]

Create buttons for package management.

Parameters:

user_mode (bool) – Whether the application is in user mode.

Returns:

Layout with package management buttons.

Return type:

QHBoxLayout

_create_save_cancel_layout()[source]

Create layout for save and cancel buttons.

Returns:

Layout with save and cancel buttons.

Return type:

QHBoxLayout

_create_status_label()[source]

Create and configure the status label.

Returns:

Configured status label.

Return type:

QLabel

_load_initial_configuration()[source]

Load initial package configuration.

_setup_ui()[source]

Set up the user interface components.

add_package(module_name, class_name=None, show_error=False, init_package_tree=False)[source]

Add a package and its modules to the package tree with comprehensive module and class discovery.

This method recursively discovers and adds packages, subpackages, and their classes to the package tree. It provides flexible options for package initialization and error handling.

Parameters:
  • module_name (str) – Fully qualified name of the module to add. Example: ‘myproject.processors’

  • class_name (str | None) – Specific class name to focus on during package addition. If provided, only this class or its parent packages will be processed.

  • show_error (bool) – Controls error reporting behavior. If True, displays error messages in a QMessageBox. If False, collects errors silently. Defaults to False.

  • init_package_tree (bool) – If True, reinitializes the entire package tree before adding the module. Defaults to False.

Returns:

A list of error messages encountered during package addition, or “No package selected!” if no module name is provided.

Return type:

list[str] | str

add_package_with_text(package_name=False, update_view=True)[source]

Add a package to the Package Library.

This method attempts to add a package or module to the library based on the provided package name. It supports adding packages with or without file extensions, and handles various import scenarios.

Parameters:
  • package_name (str | bool) – Name of the package to add. If False (default), uses the text from the line edit widget.

  • update_view (bool) – Whether to update the package list view. Defaults to True.

delete_package(index=1, to_delete=None, remove=True, loop=False, from_pipeline_manager=False)[source]

Delete a package from the library (admin-only functionality).

This method removes the package from the package library tree, updates the __init__.py file, and deletes the package directory and files if they are empty.

Parameters:
  • index (int) – Recursive index for navigating modules. Defaults to 1.

  • to_delete (str | None) – The package / brick to delete (e.g., ‘test.Test’). Defaults to None.

  • remove (bool) – Whether to remove the brick from the package tree. Defaults to True.

  • loop (bool) – Whether to delete silently without confirmation. Defaults to False.

  • from_pipeline_manager (bool) – Whether deletion is initiated from pipeline manager. Defaults to False.

Returns:

A list of deleted packages/bricks (classes).

Return type:

list[str]

delete_package_with_text(package_name='', update_view=True)[source]

Delete a package from the line edit’s text.

Parameters:
  • package_name (str) – The name of the package to delete. Defaults to the text in the line edit.

  • update_view (bool) – Whether to update the QListWidget after deletion. Defaults to True.

install_processes_pop_up(from_folder=False)[source]

Display the install processes pop-up.

Parameters:

from_folder (bool) – Whether the installation is from a folder. Defaults to False.

static load_config()[source]

Load the process configuration from process_config.yml.

The configuration file is searched for in the properties directory of the configured properties path. If the file cannot be read or parsed, an empty dictionary is returned and a warning is logged.

Returns:

The loaded configuration dictionary, or an empty dictionary if the configuration cannot be loaded.

Return type:

dict

load_packages()[source]

Update the tree of the process library.

ok_clicked()[source]

Handles the click event when the ‘Apply Changes’ button is clicked.

remove_package(package)[source]

Removes a package from the package tree.

This method attempts to remove the specified package from the package library. If the package is not found, a warning message is displayed. The package tree is updated after a successful removal.

Parameters:

package (str) – The fully qualified module name (e.g., ‘nipype.interfaces.spm’).

Returns:

True if the package was successfully removed, False if the package was not found or no package was provided.

Return type:

bool

remove_package_with_text(package_name='', update_view=True, tree_remove=True)[source]

Removes the specified package from the package tree and updates the view accordingly.

Parameters:
  • package_name (str) – The name of the package to remove. If not provided, the package name is taken from the line edit.

  • update_view (bool) – Whether to update the QListWidget view after removal. Defaults to True.

  • tree_remove (bool) – Whether to remove the package from the tree. Defaults to True.

reset_action(itemlist, add)[source]

Resets a previous package addition or removal action.

Parameters:
  • itemlist (QListWidget) – The list widget containing items to reset.

  • add (bool) – If True, resets an addition by removing the package if it exists in the configuration. If False, re-adds the package.

save(close=True)[source]

Saves the package library configuration to process_config.yml.

This method updates the package information from the package library tree and writes it to the configuration file. Optionally, it can close the dialog after saving.

Parameters:

close (bool) – If True, closes the dialog after saving. Defaults to True.

update_config()[source]

Refreshes the process configuration and updates the package library.

This method reloads the configuration from ‘process_config.yml’, updates the package library attributes, and regenerates the package tree.

class populse_mia.user_interface.pipeline_manager.process_library.ProcessLibrary(d, pkg_lib)[source]

Bases: QTreeView

A tree view to display available Capsul’s processes.

Contains:
Methods:
  • keyPressEvent: Event when the delete key is pressed.

  • load_dictionary: Loads a dictionary to the tree.

  • mousePressEvent: Event when the mouse is pressed.

  • to_dict: Returns a dictionary from the current tree.

Signals:
  • item_library_clicked: Signal emitted when an item in the library is clicked.

__init__(d, pkg_lib)[source]

Initialize the ProcessLibrary class.

Parameters:
  • d (dict) – Dictionary corresponding to the tree.

  • pkg_lib (PackageLibraryDialog) – Package library dialog associated with this process library.

keyPressEvent(event)[source]

Handles key press events, specifically the Delete key.

If the Delete key is pressed and the user is not in user mode, the selected package(s) will be deleted from the package library.

Parameters:

event (QKeyEvent) – The key event triggering this handler.

load_dictionary(d)[source]

Load a dictionary into the tree.

Parameters:

d (dict) – Dictionary to load. See the packages attribute in the ProcessLibraryWidget class.

mousePressEvent(event)[source]

Handles mouse press events on the tree view.

If a valid item is clicked, it sets the current index and emits a signal with the selected item’s text. If the right mouse button is pressed, a context menu is displayed, allowing the user to remove or delete a package.

Parameters:

event (QMouseEvent) – The mouse event triggering this handler.

to_dict()[source]

Return a dictionary representation of the current tree.

Returns:

The dictionary of the tree.

Return type:

dict

class populse_mia.user_interface.pipeline_manager.process_library.ProcessLibraryWidget(main_window=None)[source]

Bases: QWidget

Widget that manages the available Capsul’s processes in the software.

Contains:
Methods:
  • _configure_process_library: Configure the process library settings.

  • _setup_layout: Setup the layout for the widget.

  • load_config: Read the config in process_config.yml and return it as a dictionary.

  • load_packages: Set packages and paths to the widget and to the system paths.

  • open_pkg_lib: Open the package library.

  • save_config: Save the current config to process_config.yml. (commented)

  • update_config: Update the config and loads the corresponding packages.

  • update_process_library: Update the tree of the process library.

__init__(main_window=None)[source]

Initialize the ProcessLibraryWidget.

Parameters:

main_window (populse_mia.user_interface.main_window.MainWindow) – The current main window.

_configure_process_library()[source]

Configure the process library settings.

_setup_layout()[source]

Setup the layout for the widget.

static load_config()[source]

Read the configuration from process_config.yml and return it as a dictionary. . :return: The configuration as a dictionary. :rtype: dict

load_packages()[source]

Set packages and paths to the widget and to the system paths.

open_pkg_lib()[source]

Open the package library.

update_config()[source]

Update the configuration and load the corresponding packages.

update_process_library()[source]

Update the tree of the process library.

populse_mia.user_interface.pipeline_manager.process_library.import_file(full_name, path)[source]

Import a Python module from a file without registering it in sys.modules.

Creates a module specification from the specified file, creates the corresponding module object, and executes the module using its loader.

Parameters:
  • full_name (str) – Name to assign to the imported module.

  • path (str) – Path to the Python file to import.

Returns:

The imported module.

Return type:

types.ModuleType

populse_mia.user_interface.pipeline_manager.process_library.node_structure_from_dict(datadict, parent=None, root_node=None)[source]

Construct a hierarchical node structure from a dictionary.

This function converts a nested dictionary into a tree structure suitable for a TreeModel. It processes nodes based on specific conditions and recursively builds the tree.

Parameters:
Returns:

The root node of the constructed tree.

Return type:

populse_mia.user_interface.pipeline_manager.process_library.Node | None