spinetoolbox.project_items.exporter.exporter

Exporter project item.

author:
  1. Soininen (VTT)
date:

5.9.2019

Module Contents

Classes

Exporter This project item handles all functionality regarding exporting a database to a file.

Functions

_normalize_url(url) Normalized url’s path separators to their OS specific characters.
_latest_database_commit_time_stamp(url) Returns the latest commit timestamp from database at given URL or None.
class spinetoolbox.project_items.exporter.exporter.Exporter(toolbox, project, logger, name, description, settings_packs, x, y, cancel_on_export_error=None, cancel_on_error=None)[source]

Bases: spinetoolbox.project_item.ProjectItem

This project item handles all functionality regarding exporting a database to a file.

Currently, only .gdx format is supported.

Parameters:
  • toolbox (ToolboxUI) – a ToolboxUI instance
  • project (SpineToolboxProject) – the project this item belongs to
  • logger (LoggerInterface) – a logger instance
  • name (str) – item name
  • description (str) – item description
  • settings_packs (list) – dicts mapping database URLs to _SettingsPack objects
  • x (float) – initial X coordinate of item icon
  • y (float) – initial Y coordinate of item icon
  • cancel_on_export_error (bool, options) – legacy cancel_on_error option
  • cancel_on_error (bool, options) – True if execution should fail on all export errors, False to ignore certain error cases; optional to provide backwards compatibility
set_up(self)[source]

See base class.

static item_type()[source]

See base class.

static item_category()[source]

See base class.

execution_item(self)[source]

Creates Exporter’s execution counterpart.

settings_pack(self, database_path)[source]
make_signal_handler_dict(self)[source]

Returns a dictionary of all shared signals and their handlers.

restore_selections(self)[source]

Restores selections and connects signals.

_connect_signals(self)[source]

Connect signals to handlers.

_read_scenarios(self, database_url)[source]

Reads scenarios from database.

Parameters:database_url (str) – database url
Returns:a mapping from scenario name to boolean ‘active’ flag
Return type:dict
_update_properties_tab(self)[source]

Updates the database list and scenario combo boxes in the properties tab.

_do_handle_dag_changed(self, resources)[source]

See base class.

_start_worker(self, database_url, update_settings=False)[source]

Starts fetching settings using a worker in another thread.

_worker_msg(self, database_url, text)[source]
_worker_msg_warning(self, database_url, text)[source]
_worker_msg_error(self, database_url, text)[source]
_worker_finished(self, database_url, result)[source]

Gets and updates and export settings pack from a worker.

_worker_failed(self, database_url, exception)[source]

Clean up after a worker has failed fetching export settings.

_cancel_worker(self, database_url)[source]

Cleans up after worker has given up fetching export settings.

_check_state(self, clear_before_check=True)[source]

Checks the status of database export settings.

Updates both the notification message (exclamation icon) and settings states.

_check_missing_file_names(self)[source]

Checks the status of output file names.

_check_duplicate_file_names(self)[source]

Checks for duplicate output file names.

_check_missing_parameter_indexing(self)[source]

Checks the status of parameter indexing settings.

_check_erroneous_databases(self)[source]

Checks errors in settings fetching from a database.

_report_notifications(self)[source]

Updates the exclamation icon and notifications labels.

_show_settings(self, database_url)[source]

Opens the item’s settings window.

_reset_settings_window(self, database_url)[source]

Sends new settings to Gdx Export Settings window.

_dispose_settings_window(self, database_url)[source]

Deletes rejected export settings windows.

_update_out_file_name(self, file_name, database_path)[source]

Pushes a new UpdateExporterOutFileNameCommand to the toolbox undo stack.

_update_scenario(self, scenario, database_url)[source]

Updates the selected scenario.

Parameters:
  • scenario (str or NoneType) – selected scenario
  • database_url (str) – database URL
set_scenario(self, scenario, database_url)[source]

Sets the selected scenario in settings pack.

Parameters:
  • scenario (str or NoneType) – selected scenario
  • database_url (str) – database URL
_update_settings_from_settings_window(self, database_path)[source]

Pushes a new UpdateExporterSettingsCommand to the toolbox undo stack.

_cancel_on_error_option_changed(self, checkbox_state)[source]

Handles changes to the Cancel export on error option.

set_cancel_on_error(self, cancel)[source]

Sets the Cancel export on error option.

undo_redo_out_file_name(self, file_name, database_path)[source]

Updates the output file name for given database

undo_or_redo_settings(self, settings, indexing_settings, merging_settings, none_fallback, none_export, database_path)[source]

Updates the export settings for given database.

item_dict(self)[source]

Returns a dictionary corresponding to this item’s configuration.

_discard_settings_window(self, database_path)[source]

Discards the settings window for given database.

_send_settings_to_window(self, database_url)[source]

Resets settings in given export settings window.

update_name_label(self)[source]

See base class.

notify_destination(self, source_item)[source]

See base class.

_update_settings_after_db_commit(self, committed_db_maps, cookie)[source]

Refreshes export settings for databases after data has been committed to them.

_update_settings_after_db_creation(self, url)[source]

Triggers settings override.

static default_name_prefix()[source]

See base class.

resources_for_direct_successors(self)[source]

See base class.

tear_down(self)[source]

See base class.

static upgrade_v1_to_v2(item_name, item_dict)[source]

Upgrades item’s dictionary from v1 to v2.

Changes: - output_file_name and database_url stay the same but state is set to Fetching.

Parameters:
  • item_name (str) – item’s name
  • item_dict (dict) – Version 1 item dictionary
Returns:

Version 2 Exporter dictionary

Return type:

dict

spinetoolbox.project_items.exporter.exporter._normalize_url(url)[source]

Normalized url’s path separators to their OS specific characters.

This function is needed during the transition period from no-version to version 1 project files. It should be removed once we are using version 1 files.

spinetoolbox.project_items.exporter.exporter._latest_database_commit_time_stamp(url)[source]

Returns the latest commit timestamp from database at given URL or None.