spinetoolbox.project_items.shared.helpers

Helper functions and classes.

authors:
  1. Marin (KTH)
date:

12.5.2020

Module Contents

Classes

CmdlineTag

Functions

create_log_file_timestamp() Creates a new timestamp string that is used as Combiner and Importer error log file.
serialize_checked_states(files, project_path) Serializes file paths and adds a boolean value
deserialize_checked_states(serialized, project_path) Reverse operation for serialize_checked_states above.
split_cmdline_args(arg_string) Splits a string of command line into a list of tokens.
expand_tags(args, optional_input_files, input_urls, output_urls)
spinetoolbox.project_items.shared.helpers.CMDLINE_TAG_EDGE = @@[source]
class spinetoolbox.project_items.shared.helpers.CmdlineTag[source]
URL[source]
URL_INPUTS[source]
URL_OUTPUTS[source]
OPTIONAL_INPUTS[source]
spinetoolbox.project_items.shared.helpers.create_log_file_timestamp()[source]

Creates a new timestamp string that is used as Combiner and Importer error log file.

Returns:Timestamp string or empty string if failed.
spinetoolbox.project_items.shared.helpers.serialize_checked_states(files, project_path)[source]

Serializes file paths and adds a boolean value for each, which indicates whether the path is selected or not. Used in saving checked file states to project.json.

Parameters:
  • files (list) – List of absolute file paths
  • project_path (str) – Absolute project directory path
Returns:

List of serialized paths with a boolean value

Return type:

list

spinetoolbox.project_items.shared.helpers.deserialize_checked_states(serialized, project_path)[source]

Reverse operation for serialize_checked_states above. Returns absolute file paths with their check state as boolean.

Parameters:
  • serialized (list) – List of serialized paths with a boolean value
  • project_path (str) – Absolute project directory path
Returns:

Dictionary with paths as keys and boolean check states as value

Return type:

dict

spinetoolbox.project_items.shared.helpers.split_cmdline_args(arg_string)[source]

Splits a string of command line into a list of tokens.

Things in single (‘’) and double (“”) quotes are kept as single tokens while the quotes themselves are stripped away. Thus, –file=”a long quoted ‘file’ name.txt becomes [“–file=a long quoted ‘file’ name.txt”]

Parameters:arg_string (str) – command line arguments as a string
Returns:a list of tokens
Return type:list
spinetoolbox.project_items.shared.helpers.expand_tags(args, optional_input_files, input_urls, output_urls)[source]

” Expands first @@ tags found in given list of command line arguments.

Parameters:
  • args (list) – a list of command line arguments
  • optional_input_files (list) – a list of Tool’s optional input file names
  • input_urls (dict) – a mapping from URL provider (input Data Store name) to URL string
  • output_urls (dict) – a mapping from URL provider (output Data Store name) to URL string
Returns:

a boolean flag, if True, indicates that tags were expanded and a list of

expanded command line arguments

Return type:

tuple