nomad_camels.utility package

Submodules

nomad_camels.utility.databroker_export module

class nomad_camels.utility.databroker_export.ExportH5_dialog(parent=None)

Bases: QDialog

accept(self) None
all_entries()
staticMetaObject = PySide6.QtCore.QMetaObject("ExportH5_dialog" inherits "QDialog": )
update_entries()
class nomad_camels.utility.databroker_export.NumpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Bases: JSONEncoder

default(obj)

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return super().default(o)
nomad_camels.utility.databroker_export.broker_to_NX(runs, filename, plot_data=None, additional_data=None, session_name='', export_to_csv=False, export_to_json=False, new_file_each_run=False)
Parameters:
  • runs

  • filename

  • plot_data – (Default value = None)

  • additional_data – (Default value = None)

  • session_name – (Default value = ‘’)

  • export_to_csv – (Default value = False)

  • export_to_json – (Default value = False)

nomad_camels.utility.databroker_export.broker_to_dict(runs, to_iso_time=True)

Puts the runs into a dictionary.

Parameters:
  • runs

  • to_iso_time – (Default value = True)

nomad_camels.utility.databroker_export.broker_to_hdf5(runs, filename, additional_data=None)

Puts the given runs into filename, containing the run’s metadata and the dataset.

Parameters:
  • runs

  • filename

  • additional_data – (Default value = None)

nomad_camels.utility.databroker_export.clean_filename(filename)

cleans the filename from characters that are not allowed

Parameters:

filename (str) – The filename to clean.

nomad_camels.utility.databroker_export.export_h5_group_to_csv(group, filename)
nomad_camels.utility.databroker_export.export_h5_to_csv_json(filename, entry_name=None, export_data=True, export_metadata=True, export_path=None)
nomad_camels.utility.databroker_export.export_run(filename, run_number=-1, plot_data=None, additional_data=None, session_name='', export_to_csv=False, export_to_json=False, catalog_name='CAMELS_CATALOG', new_file_each_run=False)

TODO

nomad_camels.utility.databroker_export.get_param_dict(param_values)
Parameters:

param_values

nomad_camels.utility.databroker_export.h5_group_to_dict(group)
Parameters:

group

nomad_camels.utility.databroker_export.recourse_entry_dict(entry, metadata)

Recoursively makes the metadata to a dictionary.

Parameters:
  • entry

  • metadata

nomad_camels.utility.databroker_export.sort_by_list(sort_list, other_lists)
Parameters:
  • sort_list

  • other_lists

nomad_camels.utility.databroker_export.timestamp_to_ISO8601(timestamp)
Parameters:

timestamp

nomad_camels.utility.device_handling module

This package provides utility for everything regarding devices/instruments connected to the main UI.

nomad_camels.utility.device_handling.local_packages

the loaded modules of local instrument drivers

Type:

dict{“<driver_name>”: python-module}

nomad_camels.utility.device_handling.running_devices

The devices that are already instantiated and currently running. All devices are given an attribute device_run_count which is increased by 1 each time a function tries to instantiate a device that is already running. Closing the device decreases the run-count by 1. It is only really closed, once the run-count reaches 0.

Type:

dict{“<device_name>”: ophyd.Device}

nomad_camels.utility.device_handling.last_path

The path that was last used to search for local drivers. This is used to only re-run loading the packages if something changed.

Type:

str, path

class nomad_camels.utility.device_handling.InstantiateDevicesThread(device_list, channels=False, skip_config=False)

Bases: QThread

Thread for starting devices in the background.

exception_raised
run(self) None
staticMetaObject = PySide6.QtCore.QMetaObject("InstantiateDevicesThread" inherits "QThread": Methods:   #12 type=Signal, signature=exception_raised(PyObject), parameters=PyObject   #13 type=Signal, signature=successful() )
successful
nomad_camels.utility.device_handling.close_devices(device_list)

Closes the given devices (calling their finalize_steps), or decreases their run-count by 1.

Parameters:

device_list (list[str]) – The devices (as they are named in CAMELS) that should be closed

nomad_camels.utility.device_handling.close_single_device(dev)
nomad_camels.utility.device_handling.get_channel_from_string(channel)

Returns the component of the ophyd device that corresponds to the given channel. The device has to be instantiated at this point.

Parameters:

channel (str) – The name of the channel (i.e. “<device>.<channel>”)

Returns:

The signal / channel found from the string

Return type:

ophyd.Signal

nomad_camels.utility.device_handling.get_channels_from_string_list(channel_list, as_dict=False)

Goes through the given channel_list and if they are valid channels in CAMELS, their ophyd representation is called by get_channel_from_string.

Parameters:
  • channel_list (list[str]) – List of the channels in CAMELS-representation (i.e. “<device_name>_<channel_name>”)

  • as_dict (bool) – (Default value = False) if True, the returned channels will be a dictionary with the original list serving as keys

Returns:

A list of the ophyd representations of channel_list. If as_dict is True, it is a dictionary with the shape {‘channel_name’: ophyd.Signal}

Return type:

list[ophyd.Signal], dict

nomad_camels.utility.device_handling.get_functions_from_string_list(func_list)
nomad_camels.utility.device_handling.get_funtion_from_string(func_name)
nomad_camels.utility.device_handling.instantiate_devices(device_list, skip_config=False)

Starts the given devices, or increases their run-count by 1 and returns them together with their settings.

Parameters:

device_list (list[str]) – The devices (as they are named in CAMELS) that should be started

Returns:

  • devices (dict{“<device_name>”: ophyd.Device}) – Dictionary of the started devices (or if they were already running, their currently running instance)

  • device_config (dict{“<device_name>”: dict}) – Dictionary of the devices’ metadata (i.e. config, settings…)

nomad_camels.utility.device_handling.load_local_packages(tell_local=False)

Loads the packages of local instrument drivers and returns a dictionary with them. If tell_local, then the keys will be “local <driver_name>”, otherwise just “<driver_name>”.

Parameters:

tell_local (True) – (Default value = False)

Returns:

Contains the packages with the driver name as keys.

Return type:

dict

nomad_camels.utility.device_handling.start_devices_from_channel_list(channel_list, skip_config=False)

Instantiates the ophyd devices that are needed by the given channels. Returns the ophyd devices and their metadata.

Parameters:

channel_list (list[str]) – List of the channels, for which the devices should be started.

Returns:

  • devs (dict{“<device_name>”: ophyd.Device}) – Dictionary of the started devices (or if they were already running, their currently running instance)

  • dev_data (dict{“<device_name>”: dict}) – Dictionary of the devices’ metadata (i.e. config, settings…)

nomad_camels.utility.dict_recursive_string module

nomad_camels.utility.dict_recursive_string.dict_recursive_string(data, indent=0)

Recursively adds the given dictionary data to a string in the format “key: value” where each key-value pair has its own line and nested dictionaries are indented. Returns the resulting string.

nomad_camels.utility.exception_hook module

class nomad_camels.utility.exception_hook.ErrorMessage(exc_info, parent=None)

Bases: QMessageBox

A popUp-box describing an Error.

Parameters:
  • msg (str) – the error message

  • info_text (str) – A longer text, explaining the error (usually traceback)

  • parent (QWidget) – The parent widget of this Messagebox

show_more_info()
staticMetaObject = PySide6.QtCore.QMetaObject("ErrorMessage" inherits "QMessageBox": )
nomad_camels.utility.exception_hook.exception_hook(*exc_info)

Used to overwrite sys.excepthook, so that an exception does not terminate the program, but simply shows a Message with the exception. If the Exception is a KeyboardInterrupt, it does nothing, so that the interrupt may actually stop the program execution.

Parameters:

*exc_info (tuple(class, Exception, traceback)) – The information for the exception.

nomad_camels.utility.fit_variable_renaming module

Provides a function to rename typical names for fit-variables to valid python-names

nomad_camels.utility.fit_variable_renaming.replace_name(var_name)

Replaces mathematical symbols with text so that the variable name becomes a valid name.

Parameters:

var_name (str) – The variable that should be renamed.

nomad_camels.utility.load_save_functions module

Provides helping functions to load and save all settings inside CAMELS.

nomad_camels.utility.load_save_functions.appdata_path

The path to the local appdata of NOMAD CAMELS

Type:

str, path

nomad_camels.utility.load_save_functions.preset_path

the path, where CAMELS saves the presets, a subfolder of appdata_path

Type:

str, path

nomad_camels.utility.load_save_functions.backup_path

the path, where CAMELS saves backups of presets, a subfolder of preset_path

Type:

str, path

nomad_camels.utility.load_save_functions.save_string_list

a list of QWidget-classes, for which the current string they display should be saved

Type:

list[class]

nomad_camels.utility.load_save_functions.save_dict_skip

a list of QWidget-classes, that should be ignored when saving

Type:

list[class]

nomad_camels.utility.load_save_functions.standard_pref

dictionary of the default preferences used if nothing is changed by the user

Type:

dict

nomad_camels.utility.load_save_functions.autosave_preset(preset: str, preset_data, do_backup=True)

Saves the given preset and makes a backup of the former one in the backup-folder (if do_backup).

Parameters:
  • preset (str) – the name of the preset

  • preset_data (dict) – data of the preset, formatted into a dictionary

  • do_backup (bool, default=True) – if True, the old preset file will be copied into the backup folder, with timestamp

nomad_camels.utility.load_save_functions.check_config_path()
nomad_camels.utility.load_save_functions.get_most_recent_presets(return_all=False)

Goes through all files in the preset_path and returns the newest preset.

Returns:

preset – the name of the newest preset

Return type:

str

nomad_camels.utility.load_save_functions.get_preferences()

If a file ‘preferences.json’ exists in the appdata_path, its content will be loaded and returned, if no file exists, it will be created with an empty dictionary. Keys that are in the standard_pref, but not in the loaded preferences will be added with their default value.

Returns:

prefs – the loaded preferences dictionary

Return type:

dict

nomad_camels.utility.load_save_functions.get_preset_list()

DEPRECATED

returns a two list of available presets, once for devices, once for measurements. (files with “.predev” or “.premeas” in appdata_path. If the directory does not exist, it is created.

nomad_camels.utility.load_save_functions.get_save_str(obj)

Utility function to create the string with which to save the object-data. If the object has the attribute __save_dict__, it is the return value. Objects of the types specified in save_dict_skip return None. QComboBox and QLineEdit return their current text. If obj is a dictionary or has the attribute __dict__, the values of the dictionary will be recursively read by get_save_str. Types str, bool and numbers are not converted. Arrays are converted to lists.

Parameters:

obj – The object that should be represented as string.

Return type:

the string-representation of obj

nomad_camels.utility.load_save_functions.load_devices_dict(string_dict, devices_dict)

Specific function to load the dictionary of devices/instruments. Uses the instruments’ name to import the corresponding module and create the instance of the instrument.

Parameters:
  • string_dict (dict{"<name>": dict}) – containing the names and information of the instruments

  • devices_dict (dict) – the dictionary, where to put the loaded instruments

nomad_camels.utility.load_save_functions.load_protocol(path)

Loads the protocol-json from the given path and converts it to a CAMELS Measurement_Protocol instance.

Parameters:

path (str, path) – the path, where protocol file can be found

Returns:

the protocol constructed from the data in the loaded file

Return type:

Measurement_Protocol

nomad_camels.utility.load_save_functions.load_protocols_dict(string_dict, prot_dict)

Specific function to construct protocols from a json string-dictionary. Loads the attributes of a Measurement_Protocol from the corresponding keys.

Parameters:
  • string_dict (dict{"<protocol_name>": dict}) – the dictionary with the information about the protocols (which is are dictinaries again)

  • prot_dict (dict) – dictionary of the finished protocols

nomad_camels.utility.load_save_functions.load_save_dict(string_dict: dict, object_dict: dict, update_missing_key=False, remove_extra_key=False)

For all keys both given dictionaries have in common, the value of the object in object_dict will be updated to the corresponding value of the string in string_dict. Depending on the type of the objects already in object_dict, the values may be processed differently. The different possibilities are:

  • QComboBox: the value will be set as current text

  • QLineEdit: the value will be set as text

  • key==”protocols_dict”: calls load_protocols_dict

  • key in [“active_devices_dict”, “active_instruments”]: calls load_devices_dict

  • dict or hasattr “__save_dict__” or “__dict__”: calls load_save_dict recursively

  • list: appends all the values in the list of the strings

Parameters:
  • string_dict (dict) – A dictionary containing mostly strings as loaded from a json as values.

  • object_dict (dict) – The dictionary to be loaded into.

  • update_missing_key (bool) – (Default value = False) If True, keys that are only in string_dict, but not in object_dict will be added as well.

  • remove_extra_key (bool) – (Default value = False) If True, keys that are only in object_dict, but not in string_dict will be removed.

nomad_camels.utility.load_save_functions.make_backup(preset_file: str)

Puts a copy of the given preset_file into the backup-folder of the preset. The current datetime is added to the filename.

Parameters:

preset_file (str) – The name of the preset file. The file needs to be in the preset_path.

nomad_camels.utility.load_save_functions.make_save_dict(obj)

Utility function to update the __save_dict__ of the given obj. Goes through all the keys in __dict__ and calls get_save_str on the object. Thus working recursively if an attribute of obj also has a __save_dict__.

Parameters:

obj – The object of which the __save_dict__ should be updated.

nomad_camels.utility.load_save_functions.save_dictionary(path, dictionary: dict)

Processes the given dictionary using get_save_str, then saves it as json to the given path.

Parameters:
  • path (str, path) – where to save the dictionary

  • dictionary (dict) – the dictionary to be saved as json

nomad_camels.utility.load_save_functions.save_preferences(prefs: dict)

Saves the given dictionary prefs as ‘preferences.json’ in the appdata_path

Parameters:

prefs (dict) – the preferences dictionary to be saved as json

nomad_camels.utility.load_save_functions.save_preset(path, preset_data: dict)

Saves the given preset_data under the specified path. Further, autosave_preset is called.

Parameters:
  • path (str, path) – where to save the preset

  • preset_data (dict) – the data of the preset, to be dumped as json

nomad_camels.utility.load_save_functions.update_config_path(path)

nomad_camels.utility.load_save_helper_functions module

Helping functions for loading/saving. These are not in load_save_functions, so they may also be imported by modules that are imported by load_save_functions.

nomad_camels.utility.load_save_helper_functions.load_plots(plots: list, plot_data)

Loads the data from plot_data into Plot_Info objects. Then adds them to the plots list.

Parameters:
  • plots (list) – the list, where to add the plot information

  • plot_data (list[dict]) – list of dictionaries containing the necessary information for Plot_Info

Returns:

plots – the modified list with the loaded plots added

Return type:

list

nomad_camels.utility.logging_settings module

This module takes care of all the settings regarding logging to a logfile. The logfile is put into the appdata_path, a filehandler with specific formatting is added to logging’s app_log

nomad_camels.utility.logging_settings.update_log_settings()

Reads the logging settings from the current preferences and sets them for the logfile-handler. Including: the level of logging, the maximum size for the logfile, the number of old logfiles, when one is full.

nomad_camels.utility.number_formatting module

nomad_camels.utility.number_formatting.format_number(value)

Format a number-string the way it is specified in the preferences.

Parameters:

value (float, int) – The number that should be displayed as string.

Returns:

The formatted string of the number.

Return type:

str

nomad_camels.utility.password_widgets module

class nomad_camels.utility.password_widgets.Password_Dialog(parent=None, double_pass=False, compare_hash=None)

Bases: QDialog

Dialog to enter a password or create a new one. If double_pass is True or compare_hash is None, after accepting the dialog, the entered password can be accessed via the password attribute.

Parameters:
  • parent (QWidget) – Parent widget.

  • double_pass (bool, optional) – Whether to ask for a password twice, by default False. Use this, if the user should create a new password.

  • compare_hash (str, optional) – Hashed password to compare with, by default None. Use this, if the entered password should be compared directly.

accept(self) None
staticMetaObject = PySide6.QtCore.QMetaObject("Password_Dialog" inherits "QDialog": )
nomad_camels.utility.password_widgets.hash_password(password)

nomad_camels.utility.plot_placement module

This module helps to place the plots on the screen without too much overlap between the plots. The positions are saved into the global variables, since this module may be imported by several other modules.

nomad_camels.utility.plot_placement.current_screen

the number of the currently used screen to place plots

Type:

int

nomad_camels.utility.plot_placement.current_pos

the x and y coordinates of the current placement

Type:

list[int, int]

nomad_camels.utility.plot_placement.max_height_in_row

the maximum height a plot window has within the currently populated row

Type:

int

nomad_camels.utility.plot_placement.iteration

if the screens were full once, it is increased and the next plots are slightly shifted

Type:

int

nomad_camels.utility.plot_placement.horizontal_margin

the horizontal distance between the plot windows

Type:

int

nomad_camels.utility.plot_placement.vertical_margin

the vertical distance between the plot windows

Type:

int

nomad_camels.utility.plot_placement.place_widget(widget: QWidget)

This function places the given widget on the next free spot on the screen. First all widgets are placed next to each other in a row, until one would be outside the screen, then the next row is started. If it would “flow out” the bottom of the screen, a second screen (if available) is used. If all available screens are full, it restarts on the first screen, slightly shifting the widgets in comparison to the first ones.

Parameters:

widget (QWidget) – the widget that should be placed

nomad_camels.utility.plot_placement.reset_variables()

nomad_camels.utility.qthreads module

CURRENTLY DEPRECATED MODULE, NOTHING IS USED This module contains various threads that may be run from the main UI.

class nomad_camels.utility.qthreads.Additional_Imports_Thread(parent=None)

Bases: QThread

run() None
staticMetaObject = PySide6.QtCore.QMetaObject("Additional_Imports_Thread" inherits "QThread": )
class nomad_camels.utility.qthreads.Manual_Device_Thread(device, ophyd_class)

Bases: QThread

DEPRECATED

staticMetaObject = PySide6.QtCore.QMetaObject("Manual_Device_Thread" inherits "QThread": )
update_config_settings(config=None, settings=None)
Parameters:
  • config – (Default value = None)

  • settings – (Default value = None)

nomad_camels.utility.theme_changing module

This module is used to change the UI-theme of CAMELS. It provides some default color palettes light_palette and dark_palette.

nomad_camels.utility.theme_changing.change_theme(theme, main_app=None, material_theme=None, dark_mode=False)
Parameters:
  • theme (str) – The name of the used theme. Possible values are the themes from QStyleFactory and “qt-material”.

  • main_app (QMainWindow) – (Default value = None) The main UI-window. If it is None, it is looked for with QApplication.instance().

  • material_theme (str) – (Default value = None) If theme==”qt-material”, the qt-material color palette is chosen with this theme name.

  • dark_mode (bool) – (Default value = False) If True, the color palettes are switched to dark mode.

nomad_camels.utility.tqdm_progress_bar module

class nomad_camels.utility.tqdm_progress_bar.ProgressBar(n_steps)

Bases: object

Provides a progress bar for protocols run directly from the script. With the emit method, the bar can be updated the same way signals are used when running the protocol from the UI.

n_steps

the number of total (expected) steps of the protocol

Type:

int

bar

the actual progress bar

Type:

tqdm

emit(n)

Updates the progress bar to the next step. The parameter n is only so the function has the same shape as the emit function for the signal used with the main UI.

Parameters:

n (int) – has no function, only there to be able to give this method a value

nomad_camels.utility.treeView_functions module

nomad_camels.utility.treeView_functions.getItemIndex(item_model, data: str, starts_with=False)

Iteration over the item_model to return the index of an item with given data.

Parameters:
  • item_model (QStandardItemModel) – the searched item_model

  • data (str :) – the data which the looked-for item has

  • starts_with (bool, default False) – also return an item, if it only starts with the searched data (Default value = False)

  • data

nomad_camels.utility.treeView_functions.get_substeps(parent)

Helper function, to get the substeps of loop_step with children.

Parameters:

parent

nomad_camels.utility.treeView_functions.iterItem(item, data, startWith=False)

Iteration over the children of the given item to return the index of an item with given data. Called by getItemIndex. Runs recursively, if the children-items also have children.

Parameters:
  • item (QStandardItem) – item whose children are iterated over

  • data (str) – the data which the looked-for item has

  • startWith (bool, default False) – also return an item, if it only starts with the searched data (Default value = False)

nomad_camels.utility.update_camels module

A module used to update CAMELS. The import of nomad_camels is necessary, since otherwise it would not show in the imported distributions for reading its current version.

nomad_camels.utility.update_camels.auto_update(parent)

Called if auto-update is set in the preferences. If the currently installed version is not up to date, question_message_box is called.

Parameters:

parent (QWidget) – (Default value = None) The parent widget to be used for the message boxes.

nomad_camels.utility.update_camels.check_up_to_date()

Gets the installed and available version of CAMELS and checks whether they are the same. Returns the outcome as a bool.

nomad_camels.utility.update_camels.get_latest_version()

Checks the latest version of nomad-camels and returns it.

nomad_camels.utility.update_camels.get_version()

checks the installed version of nomad-camels and returns it.

nomad_camels.utility.update_camels.question_message_box(parent=None)

Retrieves the currently installed version and the available version of nomad-camels. If the are the same, a message is displayed, and function exits. Otherwise, a question-box appears, whether the user wants to install the newer version of CAMELS. If yes, first update_camels and then restart_camels are called.

Parameters:

parent (QWidget) – (Default value = None) The parent widget to be used for the message boxes.

nomad_camels.utility.update_camels.restart_camels(parent=None, ask_restart=True)

Restarts CAMELS. If ask_restart, a question-messagebox appears first, to make sure the user actually wants to restart.

Parameters:
  • parent (QWidget) – (Default value = None) The parent widget to be used for the message boxes.

  • ask_restart (bool) – (Default value = True) If True, the user is asked whether to restart CAMELS.

nomad_camels.utility.update_camels.show_release_notes()
nomad_camels.utility.update_camels.update_camels()

Calls a subprocess that updates CAMELS via pip.

nomad_camels.utility.variables_handling module

This module helps to synchronize information between different modules. To this aim, it holds several variables that may be read from different places. Furthermore, some functions to work with those variables are provided.

nomad_camels.utility.variables_handling.preset

The name of the currently used preset of CAMELS.

Type:

str

nomad_camels.utility.variables_handling.device_driver_path

The path, where to find local drivers.

Type:

str, path

nomad_camels.utility.variables_handling.meas_files_path

The path, where to write the measurement files, i.e. data.

Type:

str, path

nomad_camels.utility.variables_handling.CAMELS_path

The path to the current installation of CAMELS.

Type:

str, path

nomad_camels.utility.variables_handling.preferences

The currently used preferences.

Type:

dict

nomad_camels.utility.variables_handling.protocols

The available protocols.

Type:

dict{“<protocol_name>”: protocol}

nomad_camels.utility.variables_handling.protocol_variables

The variables provided by the currently viewed protocol.

Type:

dict{“<name>”: <value>}

nomad_camels.utility.variables_handling.channels

All available channels provided by the configured instruments.

Type:

dict{“<name>”: channel}

nomad_camels.utility.variables_handling.loop_step_variables

The variables provided by the steps of the currently viewed protocol.

Type:

dict{“<name>”: <value>}

nomad_camels.utility.variables_handling.devices

All configured instruments/devices.

Type:

dict

current_protocol = Measurement_Protocol

The protocol, that is currently being used.

nomad_camels.utility.variables_handling.dark_mode

Whether dark-mode is currently active.

Type:

bool

nomad_camels.utility.variables_handling.copied_step

The last step, that was copied.

Type:

Loop_Step

nomad_camels.utility.variables_handling.read_channel_sets

Sets of the different channel-compositions for read-channels. Used to distinguish different reads with different channels for bluesky

Type:

list[set]

nomad_camels.utility.variables_handling.read_channel_names

Names of the different read-channel steps in use. Used to distinguish the different reads.

Type:

list[str]

nomad_camels.utility.variables_handling.evaluation_functions_names

Used to provide the right-click menu to use mathematical functions.

Type:

dict

nomad_camels.utility.variables_handling.operator_names

Used to provide the right-click menu to use mathematical operators.

Type:

dict

nomad_camels.utility.variables_handling.add_actions_from_dict(dictionary, actions, connect_function, add_string='')

The values of dictionary are handed to the connect_function when clicking on the respective action named with the keys of the dictionary. The created actions are added to actions.

Parameters:
  • dictionary (dict) – the keys become the names of the actions, the values are handed to the connect_function

  • actions (list) – the created actions will be added to this list

  • connect_function (callable) – this function is called, when one of the actions is clicked

  • add_string (str) – (Default value = ‘’) added in front of the values of the dictionary for the connect_function

nomad_camels.utility.variables_handling.check_data_type(s)

Returns the datatype of the string-evaluation of s.

Parameters:

s (str) – the string that should be checked

nomad_camels.utility.variables_handling.check_eval(s)

Checks, whether the string s can be evaluated. Returns True if it is possible, otherwise False.

Parameters:

s (str) – the string that should be checked

nomad_camels.utility.variables_handling.check_variable_name(name, raise_not_warn=False, parent=None)

Checks whether name is a valid name for a variable. It checks, whether the name mirrors a builtin function or keyword. If not, it is tried with ast to parse the statement <name> = None, i.e. whether it works as a variable name. If anything fails, either an exception is raised (if raise_not_warn) or a WarnPopup is called.

Parameters:
  • name (str) – the name that should be checked

  • raise_not_warn (bool) – (Default value = False) if True, an exception is raised if a check fails, otherwise a WarnPopup

  • parent (QWidget) – (Default value = None) the parent widget for a possibly called WarnPopup

nomad_camels.utility.variables_handling.get_color(color='', string=False)

Returns the respective QColor or rgb-code(if string) for color, taking dark-mode into account.

Parameters:
  • color (str) – (Default value = ‘’) The name of the color asked for. Possible values are “red” / “r”, “strong_red”, “green” / “g”, “dark_green”, “grey” / “gray”, “blue” / “b” “black” (white if dark_mode), “orange”. Otherwise white (or black, if dark_mode) is returned.

  • string (bool) – (Default value = False) If True, only the string of the rgb will be returned, not the QColor.

nomad_camels.utility.variables_handling.get_data(s)

Used instead of get_eval when there is no specific namespace. It simply uses ast.literal_eval and if it does not work, the string s is returned.

Parameters:

s (str) – the string to be evaluated

nomad_camels.utility.variables_handling.get_eval(s)

Evaluates the string s with the namespace of protocol_variables and loop_step_variables in addition to evaluation_helper.base_namespace. Returns the evaluated value.

Parameters:

s (str) – the string that should be evaluated

nomad_camels.utility.variables_handling.get_menus(connect_function, pretext='Insert')

Providing QMenus with the connect_function for each action, containing all the variables, channels, functions and operators.

Parameters:
  • connect_function (callable) – The function that should be executed when the action is clicked. It gets the variable’s name as a value.

  • pretext (str) – (Default value = ‘Insert’) This string will be written in front of the menus.

Returns:

  • menus (list[QMenu]) – the created menus

  • actions (list[list[QAction]]) – lists of the individual actions in the menus

nomad_camels.utility.variables_handling.get_non_channel_functions()
nomad_camels.utility.variables_handling.get_output_channels()

Goes through all channels and returns a list of the names of those, that are outputs.

nomad_camels.utility.variables_handling.get_write_from_data_type(s)

Used for writing longer strings. Since the strings should stay strings in the written files, if the evaluated datatype of s is str, quotation marks will be added around the value, otherwise nothing is done.

Open a link in the default program. Should work in all operating systems.

Parameters:

link (str) – The link to open.

Module contents