helpers
¶
General helper functions and classes.
authors: |
|
---|---|
date: | 10.1.2018 |
Module Contents¶
-
helpers.
pyside2_version_check
()[source]¶ Check that PySide2 version is older than 5.12, since this is not supported yet. Issue #238 in GitLab.
qt_version is the Qt version used to compile PySide2 as string. E.g. “5.11.2” qt_version_info is a tuple with each version component of Qt used to compile PySide2. E.g. (5, 11, 2)
-
helpers.
spinedb_api_version_check
()[source]¶ Check if spinedb_api is the correct version and explain how to upgrade if it is not.
-
helpers.
busy_effect
(func)[source]¶ Decorator to change the mouse cursor to ‘busy’ while a function is processed.
Parameters: func – Decorated function.
-
helpers.
project_dir
(qsettings)[source]¶ Returns current project directory.
Parameters: qsettings (QSettings) – Settings object
-
helpers.
get_datetime
(show)[source]¶ Returns date and time string for appending into Event Log messages.
Parameters: show (boolean) – True returns date and time string. False returns empty string.
-
helpers.
create_dir
(base_path, folder='', verbosity=False)[source]¶ Create (input/output) directories recursively.
Parameters: - base_path (str) – Absolute path to wanted dir
- folder (str) – (Optional) Folder name. Usually short name of item.
- verbosity (bool) – True prints a message that tells if the directory already existed or if it was created.
Returns: True if directory already exists or if it was created successfully.
Raises: OSError if operation failed.
-
helpers.
create_output_dir_timestamp
()[source]¶ Creates a new timestamp string that is used as Tool output directory.
Returns: Timestamp string or empty string if failed.
-
helpers.
create_log_file_timestamp
()[source]¶ Creates a new timestamp string that is used as Data Interface and Data Store error log file.
Returns: Timestamp string or empty string if failed.
-
helpers.
copy_files
(src_dir, dst_dir, includes=None, excludes=None)[source]¶ Method for copying files. Does not copy folders.
Parameters: - src_dir (str) – Source directory
- dst_dir (str) – Destination directory
- includes (list) – Included files (wildcards accepted)
- excludes (list) – Excluded files (wildcards accepted)
Returns: Number of files copied
Return type: count (int)
-
helpers.
erase_dir
(path, verbosity=False)[source]¶ Delete directory and all its contents without prompt.
Parameters: - path (str) – Path to directory
- verbosity (bool) – Print logging messages or not
-
helpers.
copy_dir
(widget, src_dir, dst_dir)[source]¶ Make a copy of a directory. All files and folders are copied.
Parameters: - widget (QWidget) – Parent widget for QMessageBoxes
- src_dir (str) – Absolute path to directory that will be copied
- dst_dir (str) – Absolute path to new directory
-
helpers.
rename_dir
(widget, old_dir, new_dir)[source]¶ Rename directory. Note: This is not used in renaming projects due to unreliability. Looks like it works fine in renaming project items though.
Parameters: - widget (QWidget) – Parent widget for QMessageBoxes
- old_dir (str) – Absolute path to directory that will be renamed
- new_dir (str) – Absolute path to new directory
-
helpers.
fix_name_ambiguity
(name_list, offset=0)[source]¶ Modify repeated entries in name list by appending an increasing integer.
-
helpers.
tuple_itemgetter
(itemgetter_func, num_indexes)[source]¶ Change output of itemgetter to always be a tuple even for one index
-
helpers.
format_string_list
(str_list)[source]¶ Return an unordered html list with all elements in str_list. Intended to print error logs as returned by spinedb_api.
Parameters: str_list (list(str)) –
-
helpers.
get_db_map
(url, upgrade=False)[source]¶ Returns a DiffDatabaseMapping instance from url. If the db is not the latest version, asks the user if they want to upgrade it.
-
helpers.
do_get_db_map
(url, upgrade)[source]¶ Returns a DiffDatabaseMapping instance from url. Called by get_db_map.
-
helpers.
int_list_to_row_count_tuples
(int_list)[source]¶ Breaks a list of integers into a list of tuples (row, count) corresponding to chunks of successive elements.
-
class
helpers.
IconListManager
(icon_size)[source]¶ A class to manage icons for icon list widgets.
-
class
helpers.
IconManager
[source]¶ A class to manage object class icons for data store forms.
-
create_object_pixmap
(self, display_icon)[source]¶ Create a pixmap corresponding to display_icon, cache it, and return it.
-
setup_object_pixmaps
(self, object_classes)[source]¶ Called after adding or updating object classes. Create the corresponding object pixmaps and clear obsolete entries from the relationship class icon cache.
-
-
class
helpers.
CharIconEngine
(char, color)[source]¶ Bases:
PySide2.QtGui.QIconEngine
Specialization of QIconEngine used to draw font-based icons.
-
helpers.
make_icon_id
(icon_code, color_code)[source]¶ Take icon and color codes, and return equivalent integer.