spinetoolbox.widgets.spine_datapackage_widget
¶
Widget shown to user when opening a ‘datapackage.json’ file in Data Connection item.
author: |
|
---|---|
date: | 7.7.2018 |
Module Contents¶
-
class
spinetoolbox.widgets.spine_datapackage_widget.
SpineDatapackageWidget
(data_connection)[source]¶ Bases:
PySide2.QtWidgets.QMainWindow
A widget to allow user to edit a datapackage and convert it to a Spine database in SQLite.
-
data_connection
¶ Data Connection associated to this widget
Type: DataConnection
Initialize class.
-
show
(self)[source]¶ Called when the form shows. Init datapackage (either from existing datapackage.json or by inferring a new one from sources) and update ui.
-
infer_datapackage
(self, checked=False)[source]¶ Called when the user triggers the infer action. Infer datapackage from sources and update ui.
-
load_datapackage
(self)[source]¶ Load datapackage from ‘datapackage.json’ file in data directory, or infer one from CSV files in that directory.
Called when a menu from the menubar is about to show. Adjust infer action depending on whether or not we have a datapackage. Adjust copy paste actions depending on which widget has the focus. TODO Enable/disable action to save datapackage depending on status.
-
add_message
(self, msg)[source]¶ Prepend regular message to status bar.
Parameters: msg (str) – String to show in QStatusBar
-
add_process_message
(self, msg)[source]¶ Show process message in status bar. This messages stays until replaced.
Parameters: msg (str) – String to show in QStatusBar
-
save_datapackage
(self, checked=False)[source]¶ Write datapackage to file ‘datapackage.json’ in data directory.
-
show_export_to_spine_dialog
(self, checked=False)[source]¶ Show dialog to allow user to select a file to export.
-
reset_resource_models
(self, current, previous)[source]¶ Reset resource data and schema models whenever a new resource is selected.
-
reset_resource_data_model
(self)[source]¶ Reset resource data model with data from newly selected resource.
-
_handle_resource_name_data_committed
(self, index, new_name)[source]¶ Called when line edit delegate wants to edit resource name data. Update resources model and descriptor with new resource name.
-
_handle_field_name_data_committed
(self, index, new_name)[source]¶ Called when line edit delegate wants to edit field name data. Update name in fields_model, resource_data_model’s header and datapackage descriptor.
-
_handle_primary_key_data_committed
(self, index)[source]¶ Called when checkbox delegate wants to edit primary key data. Add or remove primary key field accordingly.
-
_handle_foreign_keys_data_changed
(self, top_left, bottom_right, roles=None)[source]¶ Called when foreign keys data is updated in model. Update descriptor accordingly.
Create button to remove foreign keys row.
-
-
class
spinetoolbox.widgets.spine_datapackage_widget.
CustomPackage
(descriptor=None, base_path=None, strict=False, storage=None)[source]¶ Bases:
datapackage.Package
Custom datapackage class.
-
set_primary_key
(self, resource, *primary_key)[source]¶ Set primary key for a given resource in the package
-
insert_foreign_key
(self, row, resource_name, field_names, reference_resource_name, reference_field_names)[source]¶ Insert foreign key to a given resource in the package at a given row.
-
remove_primary_key
(self, resource, *primary_key)[source]¶ Remove the primary key for a given resource in the package
-