output
stringlengths
1
928k
instruction
stringlengths
7
928k
system
stringlengths
0
104k
Relieve all registered models
How would you explain what the following Python 3 function does def relieve_all_models(self): map(self.relieve_model, list(self.__registered_models)) self.__registered_models.clear()
You are a Python code analyst, evaluating scripts for potential improvements.
Checks whether the passed default value suits to the passed data type.
Can you generate a brief explanation for the following Python 3 code def check_default_value(self, default_value, data_type=None): if data_type is None: data_type = self.data_type if default_value is not None: # If the default value is passed as string, we have to convert it to ...
As a Python code translator, you convert algorithms and pseudocode into Python.
Queries the user for a specific folder path to be opened.
Can you generate a brief explanation for the following Python 3 code def open_folder_cmd_line(query, default_path=None): user_input = input(query + ': ') if len(user_input) == 0: user_input = default_path if not user_input or not os.path.isdir(user_input): return None return user_input
As a Python code analyst, you investigate and solve complex coding mysteries
def create_folder_cmd_line(query, default_name=None, default_path=None): """Queries the user for a path to be created :param str query: Query that asks the user for a specific folder path to be created :param str default_name: Default name of the folder to be created :param str default_path: Path in w...
Write a Python 3 function that can query the user for a specific folder path to be created
You are a Python code architect, reviewing and designing scalable and efficient code
def save_folder_cmd_line(query, default_name=None, default_path=None): """Queries the user for a path or file to be saved into The folder or file has not to be created already and will not be created by this function. The parent directory of folder and file has to exist otherwise the function will return N...
Create a Python 3 function for querying the user for a path or file to be saved into the folder or file.
As a Python code composer, you craft elegant and concise scripts.
def register_view(self, view): """Called when the View was registered """ super(StateTransitionsListController, self).register_view(view) def cell_text(column, cell_renderer, model, iter, data): t_id = model.get_value(iter, self.ID_STORAGE_ID) in_external = 'exte...
Create a Python 3 function to call when the View was registered
You are a Python code generator, capable of creating scripts from specifications.
Removes respective core element of handed transition model
Here you have a function in Python 3, explain what it does def remove_core_element(self, model): assert model.transition.parent is self.model.state or model.transition.parent is self.model.parent.state gui_helper_state_machine.delete_core_element_of_model(model)
As a Python code analyst, you investigate and solve complex coding mysteries
This function returns a list of possible combos for a transition and its respective state.
Can you generate a brief explanation for the following Python 3 code def get_possible_combos_for_transition(trans, model, self_model, is_external=False): from_state_combo = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING) from_outcome_combo = Gtk.ListStore(GObject.TYPE_STRING) to_state_co...
You are a Python code architect, reviewing and designing scalable and efficient code
Updates internal data base based on the current state and model.
Here you have a function in Python 3, explain what it does def _update_internal_data_base(self): model = self.model # print("clean data base") ### FOR COMBOS # internal transitions # - take all internal states # - take all not used internal outcomes of this states ...
As a Python code translator, you convert algorithms and pseudocode into Python.
def _update_tree_store(self): """ Updates TreeStore of the Gtk.ListView according internal combo knowledge gained by _update_internal_data_base function call. """ self.list_store.clear() if self.view_dict['transitions_internal'] and isinstance(self.model, ContainerStateModel) an...
Write a Python 3 script for updating the TreeStore according internal combo knowledge gained by the internal data base function call.
You are a Python code analyst, evaluating scripts for potential improvements.
Register callback methods for triggered actions
Explain what the following Python 3 code does def register_actions(self, shortcut_manager): shortcut_manager.add_callback_for_action("delete", self.trans_list_ctrl.remove_action_callback) shortcut_manager.add_callback_for_action("add", self.trans_list_ctrl.add_action_callback)
You are a Python code generator, capable of creating scripts from specifications.
def move_dirty_lock_file(dirty_lock_file, sm_path): """ Move the dirt_lock file to the sm_path and thereby is not found by auto recovery of backup anymore """ if dirty_lock_file is not None \ and not dirty_lock_file == os.path.join(sm_path, dirty_lock_file.split(os.sep)[-1]): logger.debug("M...
How would you implement a function in Python 3 that moves the dirt_lock file to the state machine folder
As a Python code composer, you craft elegant and concise scripts.
Write the auto backup meta data into the current tmp - storage path
Can you generate the documentation for the following Python 3 function def write_backup_meta_data(self): auto_backup_meta_file = os.path.join(self._tmp_storage_path, FILE_NAME_AUTO_BACKUP) storage.storage_utils.write_dict_to_json(self.meta, auto_backup_meta_file)
As a python code expert, you are capable of creating scripts from specifications.
def update_last_backup_meta_data(self): """Update the auto backup meta data with internal recovery information""" self.meta['last_backup']['time'] = get_time_string_for_float(self.last_backup_time) self.meta['last_backup']['file_system_path'] = self._tmp_storage_path self.meta['last_back...
Can you write a function in Python 3 where it updates the auto backup meta data with the internal recovery information
You are a Python code generator, capable of creating scripts from specifications.
Update the auto backup meta data with information of the state machine origin
How would you explain what the following Python 3 function does def update_last_sm_origin_meta_data(self): # TODO finally maybe remove this when all backup features are integrated into one backup-structure # data also used e.g. to backup tabs self.meta['last_saved']['time'] = self.state_machine_...
You are a Python code architect, reviewing and designing scalable and efficient code
This method checks if the state - machine is already backupd and if so restarts the thread if it is not already backupd.
Explain what the following Python 3 code does def _check_for_dyn_timed_auto_backup(self): current_time = time.time() self.timer_request_lock.acquire() # sm = self.state_machine_model.state_machine # TODO check for self._timer_request_time is None to avoid and reset auto-backup in case an...
As a Python code translator, you convert algorithms and pseudocode into Python.
Private method to check for possible auto backup of the state - machine according duration till .
Explain what the following Python 3 code does def check_for_auto_backup(self, force=False): if not self.timed_temp_storage_enabled: return sm = self.state_machine_model.state_machine current_time = time.time() if not self.only_fix_interval and not self.marked_dirty: ...
You are a Python code architect, reviewing and designing scalable and efficient code
dragged state is inserted and its state_id sent to the receiver
Make a summary of the following Python 3 code def on_drag_data_get(self, widget, context, data, info, time): import rafcon.gui.helpers.state_machine as gui_helper_state_machine state = self._get_state() gui_helper_state_machine.add_state_by_drag_and_drop(state, data)
As a Python code analyst, you investigate and solve complex coding mysteries
state insertion on mouse click
Make a summary of the following Python 3 code def on_mouse_click(self, widget, event): import rafcon.gui.helpers.state_machine as gui_helper_state_machine if self.view.get_path_at_pos(int(event.x), int(event.y)) is not None \ and len(self.view.get_selected_items()) > 0: retur...
You are a Python code generator, capable of creating scripts from specifications.
get state instance which was clicked on
Here you have a function in Python 3, explain what it does def _get_state(self): selected = self.view.get_selected_items() if not selected: return shorthand, state_class = self.view.states[selected[0][0]] return state_class()
As a Python code analyst, you investigate and solve complex coding mysteries
def get_nice_info_dict_string(self, info, level='\t', overview=None): """ Inserts all elements of a notification info-dictionary of gtkmvc3 or a Signal into one string and indicates levels of calls defined by 'kwargs'. Additionally, the elements get structured into a dict that holds all levels o...
Create a Python 3 function for returning a string that contains all elements of a notification info - dictionary of gtkmvc3 or Signal and all levels of calls defined by kwargs.
As a Python code translator, you convert algorithms and pseudocode into Python.
Called when the view was registered
How would you explain what the following Python 3 function does def register_view(self, view): super(StateOutcomesListController, self).register_view(view) if isinstance(view, StateOutcomesTreeView): self.connect_signal(view['to_state_combo'], "edited", self.on_to_state_edited) s...
As a Python code composer, you craft elegant and concise scripts.
def apply_new_outcome_name(self, path, new_name): """Apply the newly entered outcome name it is was changed :param str path: The path string of the renderer :param str new_name: Newly entered outcome name """ # Don't do anything if outcome name didn't change if new_name ...
Can you write a function in Python 3 where it applies the newly entered outcome name it is was changed
You are a Python code generator, capable of creating scripts from specifications.
Connects the outcome with a transition to the newly set state
Here you have a function in Python 3, explain what it does def on_to_state_edited(self, renderer, path, new_state_identifier): def do_self_transition_check(t_id, new_state_identifier): # add self transition meta data if 'self' in new_state_identifier.split('.'): insert_se...
You are a Python code analyst, evaluating scripts for potential improvements.
def on_to_outcome_edited(self, renderer, path, new_outcome_identifier): """Connects the outcome with a transition to the newly set outcome :param Gtk.CellRendererText renderer: The cell renderer that was edited :param str path: The path string of the renderer :param str new_outcome_iden...
Implement a function in Python 3 to connect the outcome with a transition to the newly set outcome
As a Python code composer, you craft elegant and concise scripts.
def remove_core_element(self, model): """Remove respective core element of handed outcome model :param OutcomeModel model: Outcome model which core element should be removed :return: """ assert model.outcome.parent is self.model.state gui_helper_state_machine.delete_core...
How would you code a function in Python 3 to remove respective core element of handed outcome model
As a python code expert, you are capable of creating scripts from specifications.
Called when the view was registered
Given the following Python 3 function, write the documentation def register_view(self, view): super(StateOutcomesEditorController, self).register_view(view) if isinstance(view, StateOutcomesEditorView): self.connect_signal(view['add_button'], "clicked", self.oc_list_ctrl.on_add) ...
You are a Python code analyst, evaluating scripts for potential improvements.
def bring_tab_to_the_top(self, tab_label): """Find tab with label tab_label in list of notebook's and set it to the current page. :param tab_label: String containing the label of the tab to be focused """ page = self.page_dict[tab_label] for notebook in self.notebook_names: ...
How would you code a function in Python 3 to find tab with label tab_label in list of notebook s and set it to the current page.
You are a Python code architect, reviewing and designing scalable and efficient code
Triggered upon updating the list of global variables alphabetically.
Explain what the following Python 3 code does def compare_variables(tree_model, iter1, iter2, user_data=None): path1 = tree_model.get_path(iter1)[0] path2 = tree_model.get_path(iter2)[0] # get key of first variable name1 = tree_model[path1][0] # get key of second variable ...
As a python code expert, you are capable of creating scripts from specifications.
Checks if one of the state machines contains the marked_dirty flag set to True.
Given the following Python 3 function, write the documentation def has_dirty_state_machine(self): for sm in self.state_machines.values(): if sm.marked_dirty: return True return False
As a Python code translator, you convert algorithms and pseudocode into Python.
def reset_dirty_flags(self): """Set all marked_dirty flags of the state machine to false.""" for sm_id, sm in self.state_machines.items(): sm.marked_dirty = False
Can you implement a function in Python 3 that resets all marked_dirty flags of all state machines to false.
As a python code expert, you are capable of creating scripts from specifications.
def add_state_machine(self, state_machine): """Add a state machine to the list of managed state machines. If there is no active state machine set yet, then set as active state machine. :param state_machine: State Machine Object :raises exceptions.AttributeError: if the passed state ...
Can you create a Python 3 function that adds a state machine to the list of managed state machines.
As a Python code translator, you convert algorithms and pseudocode into Python.
def remove_state_machine(self, state_machine_id): """Remove the state machine for a specified state machine id from the list of registered state machines. :param state_machine_id: the id of the state machine to be removed """ import rafcon.core.singleton as core_singletons remov...
Create a Python 3 function to remove the state machine with the specified id from the list of registered state machines.
As a python code expert, you are capable of creating scripts from specifications.
Return a reference to the active state - machine
Make a summary of the following Python 3 code def get_active_state_machine(self): if self._active_state_machine_id in self._state_machines: return self._state_machines[self._active_state_machine_id] else: return None
You are a Python code generator, capable of creating scripts from specifications.
def get_open_state_machine_of_file_system_path(self, file_system_path): """Return a reference to the state machine with respective path if open """ for sm in self.state_machines.values(): if sm.file_system_path == file_system_path: return sm
How would you implement a function in Python 3 that returns a reference to the state machine with the given file system path if open
As a Python code composer, you craft elegant and concise scripts.
Triggered whenever a notebook tab is switched in the left bar.
Can you tell what is the following Python 3 function doing def reset_title(self, title, notebook_identifier): current_title = self.get_top_widget().get_title() upper_title = current_title.split('/')[0].strip() lower_title = current_title.split('/')[1].strip() if notebook_identifier == 'u...
You are a Python code analyst, evaluating scripts for potential improvements.
def negative_check_for_model_in_expected_future_models(target_state_m, model, msg, delete=True, with_logger=None): """ Checks if the expected future models list/set includes still a specific model Return False if the handed model is still in and also creates a warning message as feedback. :param StateMode...
Can you write a function in Python 3 where it checks if the expected_future_models list contains still a specific model
As a Python code analyst, you investigate and solve complex coding mysteries
def check_expected_future_model_list_is_empty(target_state_m, msg, delete=True, with_logger=None): """ Checks if the expected future models list/set is empty Return False if there are still elements in and also creates a warning message as feedback. :param StateModel target_state_m: The state model which ...
Implement a Python 3 function for checking if the list of expected future models is empty.
As a Python code composer, you craft elegant and concise scripts.
Recursively creates all and all Models
Given the following Python 3 function, write the documentation def update_models_recursively(state_m, expected=True): assert isinstance(state_m, AbstractStateModel) if isinstance(state_m, LibraryStateModel): if not state_m.state_copy_initialized: if not expected: logger.war...
As a Python code analyst, you investigate and solve complex coding mysteries
def add_state(container_state_m, state_type): """Add a state to a container state Adds a state of type state_type to the given container_state :param rafcon.gui.models.container_state.ContainerState container_state_m: A model of a container state to add the new state to :param rafcon.core.enums....
Write a Python 3 script to add a state to a container state
You are a Python code analyst, evaluating scripts for potential improvements.
This function duplicates a state with a new type and returns a new state that is a new type.
Make a summary of the following Python 3 code def create_new_state_from_state_with_type(source_state, target_state_class): current_state_is_container = isinstance(source_state, ContainerState) new_state_is_container = issubclass(target_state_class, ContainerState) if current_state_is_container and new_sta...
You are a Python code architect, reviewing and designing scalable and efficient code
This function extracts the child models of the given state model into a dict.
Can you tell what is the following Python 3 function doing def extract_child_models_of_state(state_m, new_state_class): # check if root state and which type of state assert isinstance(state_m, StateModel) assert issubclass(new_state_class, State) orig_state = state_m.state # only here to get the input ...
You are a Python code generator, capable of creating scripts from specifications.
Create a new state model with the defined properties
Can you generate a brief explanation for the following Python 3 code def create_state_model_for_state(new_state, meta, state_element_models): from rafcon.gui.models.abstract_state import get_state_model_class_for_state state_m_class = get_state_model_class_for_state(new_state) new_state_m = state_m_class(ne...
As a Python code composer, you craft elegant and concise scripts.
Prepares and scales the meta data to fit into actual size of the state.
Can you generate the documentation for the following Python 3 function def prepare_state_m_for_insert_as(state_m_to_insert, previous_state_size): # TODO check how much code is duplicated or could be reused for library fit functionality meta data helper # TODO DO REFACTORING !!! and move maybe the hole method to...
As a Python code composer, you craft elegant and concise scripts.
Add a state into a target state
Explain what the following Python 3 code does def insert_state_as(target_state_m, state, as_template): if not isinstance(target_state_m, ContainerStateModel) or \ not isinstance(target_state_m.state, ContainerState): logger.error("States can only be inserted in container states") return...
As a Python code translator, you convert algorithms and pseudocode into Python.
def substitute_state(target_state_m, state_m_to_insert, as_template=False): """ Substitutes the target state Both, the state to be replaced (the target state) and the state to be inserted (the new state) are passed via parameters. The new state adapts the size and position of the target state. Stat...
Write a Python 3 function for substituting the target state with the new state.
You are a Python code architect, reviewing and designing scalable and efficient code
def substitute_state_as(target_state_m, state, as_template, keep_name=False): """ Substitute a target state with a handed state The method generates a state model for the state to be inserted and use function substitute_state to finally substitute the state. In case the state to be inserted is a Librar...
Implement a function in Python 3 to substitute a target state with a handed state
As a Python code analyst, you investigate and solve complex coding mysteries
def orify(e, changed_callback): """Add another event to the multi_event :param e: the event to be added to the multi_event :param changed_callback: a method to call if the event status changes, this method has access to the multi_event :return: """ if not hasattr(e, "callbacks"): # Event has n...
Create a Python 3 function to add another event to the multi_event
As a python code expert, you are capable of creating scripts from specifications.
def create(*events): """Creates a new multi_event The multi_event listens to all events passed in the "events" parameter. :param events: a list of threading.Events :return: The multi_event :rtype: threading.Event """ or_event = threading.Event() def changed(): if any([event.is...
Can you create a Python 3 function that creates a new multi_event object with all events passed in the events parameter.
You are a Python code architect, reviewing and designing scalable and efficient code
React to configuration changes Update internal hold enable state propagates it to view and refresh the text buffer.
How would you explain what the following Python 3 function does def model_changed(self, model, prop_name, info): current_enables = self._get_config_enables() if not self._enables == current_enables: # check if filtered buffer update needed filtered_buffer_update_needed = True ...
As a Python code translator, you convert algorithms and pseudocode into Python.
Handle double click event.
Explain what the following Python 3 code does def _handle_double_click(self, event): if event.get_button()[1] == 1: # Left mouse button path_info = self.view.tree_view.get_path_at_pos(int(event.x), int(event.y)) if path_info: # Valid entry was clicked on path = path_inf...
You are a Python code analyst, evaluating scripts for potential improvements.
def create_path(path): """Creates a absolute path in the file system. :param path: The path to be created """ import os if not os.path.exists(path): os.makedirs(path)
How would you implement a function in Python 3 that creates a absolute path in the file system.
You are a Python code generator, capable of creating scripts from specifications.
Calculates the MD5 hash of a file
Can you generate the documentation for the following Python 3 function def get_md5_file_hash(filename): import hashlib BLOCKSIZE = 65536 hasher = hashlib.md5() with open(filename, 'rb') as afile: buf = afile.read(BLOCKSIZE) while len(buf) > 0: hasher.update(buf) b...
You are a Python code generator, capable of creating scripts from specifications.
def file_needs_update(target_file, source_file): """Checks if target_file is not existing or differing from source_file :param target_file: File target for a copy action :param source_file: File to be copied :return: True, if target_file not existing or differing from source_file, else False :rtype...
Create a Python 3 function for checking if target_file is not existing or differing from source_file
As a Python code composer, you craft elegant and concise scripts.
Copies source_file to target_file if latter one in not existing or outdated
Explain what the following Python 3 code does def copy_file_if_update_required(source_file, target_file): if file_needs_update(target_file, source_file): shutil.copy(source_file, target_file)
As a Python code translator, you convert algorithms and pseudocode into Python.
def read_file(file_path, filename=None): """ Open file by path and optional filename If no file name is given the path is interpreted as direct path to the file to be read. If there is no file at location the return value will be None to offer a option for case handling. :param str file_path: Path str...
Implement a Python 3 function for opening file by path and optional filename and return content of the file.
You are a Python code analyst, evaluating scripts for potential improvements.
def clean_file_system_paths_from_not_existing_paths(file_system_paths): """Cleans list of paths from elements that do not exist If a path is no more valid/existing, it is removed from the list. :param list[str] file_system_paths: list of file system paths to be checked for existing """ paths_to_de...
Create a Python 3 function to clean list of paths from elements that do not exist
As a Python code composer, you craft elegant and concise scripts.
Reloads the input data port models from the state
Can you generate a brief explanation for the following Python 3 code def _load_input_data_port_models(self): self.input_data_ports = [] for input_data_port in self.state.input_data_ports.values(): self._add_model(self.input_data_ports, input_data_port, DataPortModel)
You are a Python code generator, capable of creating scripts from specifications.
Reloads the output data port models from the state
Here you have a function in Python 3, explain what it does def _load_output_data_port_models(self): self.output_data_ports = [] for output_data_port in self.state.output_data_ports.values(): self._add_model(self.output_data_ports, output_data_port, DataPortModel)
You are a Python code analyst, evaluating scripts for potential improvements.
def _load_income_model(self): """ Create income model from core income """ self._add_model(self.income, self.state.income, IncomeModel)
Can you create a Python 3 function that loads the income model from the core income
You are a Python code architect, reviewing and designing scalable and efficient code
Load outcome models from core outcomes
Given the following Python 3 function, write the documentation def _load_outcome_models(self): self.outcomes = [] for outcome in self.state.outcomes.values(): self._add_model(self.outcomes, outcome, OutcomeModel)
As a Python code translator, you convert algorithms and pseudocode into Python.
def re_initiate_model_list(self, model_list_or_dict, core_objects_dict, model_name, model_class, model_key): """Recreate model list The method re-initiate a handed list or dictionary of models with the new dictionary of core-objects. :param model_list_or_dict: could be a list or dictionary of ...
Implement a Python 3 function for recreating model list The method re-initiate a handed list or dictionary of models with the new dictionary of core-objects. :param model_list_or_dict: could be a list or dictionary of one model type :param core_objects_dict: new dictionary of one type of core-elements (rafcon.core) :pa...
As a Python code translator, you convert algorithms and pseudocode into Python.
Adds one model for a given core element.
Make a summary of the following Python 3 code def _add_model(self, model_list_or_dict, core_element, model_class, model_key=None, load_meta_data=True): found_model = self._get_future_expected_model(core_element) if found_model: found_model.parent = self if model_class is IncomeMode...
You are a Python code architect, reviewing and designing scalable and efficient code
This method will add one missing model to the state object if it does not exist.
Explain what the following Python 3 code does def add_missing_model(self, model_list_or_dict, core_elements_dict, model_name, model_class, model_key): def core_element_has_model(core_object): for model_or_key in model_list_or_dict: model = model_or_key if model_key is None else model...
You are a Python code analyst, evaluating scripts for potential improvements.
def remove_additional_model(self, model_list_or_dict, core_objects_dict, model_name, model_key, destroy=True): """Remove one unnecessary model The method will search for the first model-object out of model_list_or_dict that represents no core-object in the dictionary of core-objects handed by c...
Can you create a Python 3 function that removes one unnecessary model The method will search for the first model-object out of model_list_or_dict that represents no core-object in the dictionary of core-objects handed by core_objects_dict, remove it and return without continue to search for more model-objects which may...
As a python code expert, you are capable of creating scripts from specifications.
def _get_future_expected_model(self, core_element): """Hand model for an core element from expected model list and remove the model from this list""" for model in self.expected_future_models: if model.core_element is core_element: # print("expected_future_model found -> remov...
Implement a Python 3 function for handing model for an core element from expected model list and remove the model from this list
As a python code expert, you are capable of creating scripts from specifications.
def as_dict(self, use_preliminary=False): """Create a copy of the config in form of a dict :param bool use_preliminary: Whether to include the preliminary config :return: A dict with the copy of the config :rtype: dict """ config = dict() for key in self.config.k...
How would you code a function in Python 3 to create a copy of the config in form of a dict
You are a Python code analyst, evaluating scripts for potential improvements.
def update_config(self, config_dict, config_file): """Update the content and reference of the config :param dict config_dict: The new configuration :param str config_file: The new file reference """ config_path = path.dirname(config_file) self.config.config_file_path = c...
Write a Python 3 script to update the content and reference of the config object with the new configuration dictionary.
You are a Python code analyst, evaluating scripts for potential improvements.
def get_current_config_value(self, config_key, use_preliminary=True, default=None): """Returns the current config value for the given config key :param str config_key: Config key who's value is requested :param bool use_preliminary: Whether the preliminary config should be queried first ...
Write a Python 3 script for returning the current config value for the given config key
You are a Python code analyst, evaluating scripts for potential improvements.
Stores a config value as preliminary new value
Can you generate the documentation for the following Python 3 function def set_preliminary_config_value(self, config_key, config_value): if config_value != self.config.get_config_value(config_key): self.preliminary_config[config_key] = config_value # If the value was reverted to its original...
You are a Python code architect, reviewing and designing scalable and efficient code
def apply_preliminary_config(self, save=True): """Applies the preliminary config to the configuration :param bool save: Whether the config file is be be written to the file system :return: Whether the applied changes require a refresh of the state machines :rtype: bool """ ...
Create a Python 3 function to apply the preliminary config to the configuration and returns True if the applied changes require a refresh of the state machines.
You are a Python code analyst, evaluating scripts for potential improvements.
Setter for the parent state of the state element
Can you generate a brief explanation for the following Python 3 code def parent(self, parent): if parent is None: self._parent = None else: from rafcon.core.states.state import State assert isinstance(parent, State) old_parent = self.parent se...
You are a Python code analyst, evaluating scripts for potential improvements.
Checks the validity of the state element s properties
Make a summary of the following Python 3 code def _check_validity(self): from rafcon.core.states.state import State if not self.parent: return True, "no parent" if not isinstance(self.parent, State): return True, "no parental check" return self.parent.check_child...
As a Python code composer, you craft elegant and concise scripts.
The method register self as observer newly added StateMachineModels after those were added to the list of state_machines hold by observable StateMachineMangerModel. state_machines.
Here you have a function in Python 3, explain what it does def register_new_state_machines(self, model, prop_name, info): if info['method_name'] == '__setitem__': self.observe_model(info['args'][1]) self.logger.info(NotificationOverview(info)) elif info['method_name'] == '__delit...
As a python code expert, you are capable of creating scripts from specifications.
The method relies observed root_state models and observes newly assigned root_state models.
Can you generate the documentation for the following Python 3 function def observe_root_state_assignments(self, model, prop_name, info): if info['old']: self.relieve_model(info['old']) if info['new']: self.observe_model(info['new']) self.logger.info("Exchange observed...
As a Python code composer, you craft elegant and concise scripts.
This method prints the structure of all meta_signal - notifications as log - messages.
Make a summary of the following Python 3 code def observe_meta_signal_changes(self, changed_model, prop_name, info): self.logger.info(NotificationOverview(info))
As a Python code translator, you convert algorithms and pseudocode into Python.
def set_dict(self, new_dict): """Sets the dictionary of the Vividict The method is able to handle nested dictionaries, by calling the method recursively. :param new_dict: The dict that will be added to the own dict """ for key, value in new_dict.items(): if isinstan...
Implement a Python 3 function for setting the dictionary of the Vividict COOKIE
As a python code expert, you are capable of creating scripts from specifications.
Called when the view was registered
Given the following Python 3 function, write the documentation def register_view(self, view): super(SemanticDataEditorController, self).register_view(view) if isinstance(self.model.state, LibraryState) or self.model.state.get_next_upper_library_root_state(): self.set_editor_lock(True) ...
You are a Python code analyst, evaluating scripts for potential improvements.
Sets the locked flag for the external editor.
Can you tell what is the following Python 3 function doing def set_editor_lock(self, locked=True): self.view['new_entry'].set_sensitive(not locked) self.view['new_dict_entry'].set_sensitive(not locked) self.view['delete_entry'].set_sensitive(not locked) # self.view['open_externally'].set...
As a python code expert, you are capable of creating scripts from specifications.
Gets the selected object in the treeview
Can you tell what is the following Python 3 function doing def get_selected_object(self): model, paths = self.tree_view.get_selection().get_selected_rows() if len(paths) == 1: return self.tree_store.get_iter(paths[0]), paths[0] else: return None, paths
As a Python code translator, you convert algorithms and pseudocode into Python.
def on_add(self, widget, new_dict=False): """" Adds a new entry to the semantic data of a state. Reloads the tree store. :param widget: The source widget of the action :param bool new_dict: A flag to indicate if the new value is of type dict :return: """ self.semantic_da...
Write a Python 3 function for adding a new entry to the semantic data of a state.
You are a Python code generator, capable of creating scripts from specifications.
Removes an entry of semantic data of a state.
Can you tell what is the following Python 3 function doing def on_remove(self, widget, data=None): treeiter, path = self.get_selected_object() if not treeiter: return # check if an element is selected dict_path_as_list = self.tree_store[path][self.ID_STORAGE_ID] logg...
As a Python code analyst, you investigate and solve complex coding mysteries
Adds all values of the input dictionary to the tree store.
Make a summary of the following Python 3 code def add_items_to_tree_iter(self, input_dict, treeiter, parent_dict_path=None): if parent_dict_path is None: parent_dict_path = [] self.get_view_selection() for key, value in sorted(input_dict.items()): element_dict_path = copy...
You are a Python code analyst, evaluating scripts for potential improvements.
def reload_tree_store_data(self): """ Reloads the data of the tree store :return: """ model, paths = self.tree_view.get_selection().get_selected_rows() self.tree_store.clear() self.add_items_to_tree_iter(self.model.state.semantic_data, None) self.tree_view.expan...
Write a Python 3 function that can reload the data of the tree store.
As a Python code composer, you craft elegant and concise scripts.
def copy_action_callback(self, *event): """Add a copy of all selected row dict value pairs to the clipboard""" if react_to_event(self.view, self.tree_view, event) and self.active_entry_widget is None: _, dict_paths = self.get_view_selection() selected_data_list = [] f...
Can you create a Python 3 function that adds a copy of all selected row dict value pairs to the clipboard
As a Python code translator, you convert algorithms and pseudocode into Python.
Paste the clipboard into all selected sub - dictionary
Make a summary of the following Python 3 code def paste_action_callback(self, *event): if react_to_event(self.view, self.tree_view, event) and self.active_entry_widget is None: _, dict_paths = self.get_view_selection() selected_data_list = rafcon.gui.clipboard.global_clipboard.get_semant...
You are a Python code generator, capable of creating scripts from specifications.
Add a copy and cut all selected row dict value pairs to the clipboard
Can you generate a brief explanation for the following Python 3 code def cut_action_callback(self, *event): if react_to_event(self.view, self.tree_view, event) and self.active_entry_widget is None: _, dict_paths = self.get_view_selection() stored_data_list = [] for dict_path_...
As a Python code analyst, you investigate and solve complex coding mysteries
Edits the key of a semantic data entry
How would you explain what the following Python 3 function does def key_edited(self, path, new_key_str): tree_store_path = self.create_tree_store_path_from_key_string(path) if isinstance(path, string_types) else path if self.tree_store[tree_store_path][self.KEY_STORAGE_ID] == new_key_str: re...
As a python code expert, you are capable of creating scripts from specifications.
Adds the value of the semantic data entry to the model state
Explain what the following Python 3 code does def value_edited(self, path, new_value_str): tree_store_path = self.create_tree_store_path_from_key_string(path) if isinstance(path, string_types) else path if self.tree_store[tree_store_path][self.VALUE_STORAGE_ID] == new_value_str: return ...
As a Python code translator, you convert algorithms and pseudocode into Python.
Get the path to the row representing the core element described by handed core_element_id
Explain what the following Python 3 code does def get_path_for_core_element(self, core_element_id): def check_function(row_iter, iter_found): row_id = self.tree_store.get_value(row_iter, self.ID_STORAGE_ID) if len(row_id) == len(core_element_id): if row_id == core_element...
As a Python code translator, you convert algorithms and pseudocode into Python.
Saves the semantic data to a file in the specified path.
Explain what the following Python 3 code does def save_file_data(self, path): try: # just create file with empty text first; this command also creates the whole path to the file filesystem.write_file(os.path.join(path, storage.SCRIPT_FILE), "", create_full_path=True) storage_...
As a Python code analyst, you investigate and solve complex coding mysteries
Loads the semantic data file and sets the content of the semantic data object in the state.
Can you tell what is the following Python 3 function doing def load_and_set_file_content(self, file_system_path): semantic_data = load_data_file(os.path.join(file_system_path, storage.SEMANTIC_DATA_FILE)) self.model.state.semantic_data = semantic_data
As a Python code composer, you craft elegant and concise scripts.
def store_widget_properties(self, widget, widget_name): """Sets configuration values for widgets If the widget is a window, then the size and position are stored. If the widget is a pane, then only the position is stored. If the window is maximized the last insert position before being maximize...
Implement a Python 3 function for storing the properties of a widget in the configuration file.
You are a Python code analyst, evaluating scripts for potential improvements.
Updates the list of recently opened state machines with the file system path of handed state machine.
Can you generate the documentation for the following Python 3 function def update_recently_opened_state_machines_with(self, state_machine): if state_machine.file_system_path: # check if path is in recent path already # logger.info("update recent state machine: {}".format(sm.file_system_p...
As a Python code translator, you convert algorithms and pseudocode into Python.
Updates the list with all in the state machine manager opened state machines
Make a summary of the following Python 3 code def extend_recently_opened_by_current_open_state_machines(self): from rafcon.gui.singleton import state_machine_manager_model as state_machine_manager_m for sm_m in state_machine_manager_m.state_machines.values(): self.update_recently_opened_stat...
As a python code expert, you are capable of creating scripts from specifications.
Reduce number of paths in the recent opened state machines to limit from gui config
Here you have a function in Python 3, explain what it does def prepare_recently_opened_state_machines_list_for_storage(self): from rafcon.gui.singleton import global_gui_config num = global_gui_config.get_config_value('NUMBER_OF_RECENT_OPENED_STATE_MACHINES_STORED') state_machine_paths = self.ge...
As a Python code analyst, you investigate and solve complex coding mysteries
def clean_recently_opened_state_machines(self): """Remove state machines who's file system path does not exist""" state_machine_paths = self.get_config_value('recently_opened_state_machines', []) filesystem.clean_file_system_paths_from_not_existing_paths(state_machine_paths) self.set_con...
How would you code a function in Python 3 to remove state machines who s file system path does not exist
As a Python code analyst, you investigate and solve complex coding mysteries
def pause(self): """Set the execution mode to paused """ if self.state_machine_manager.active_state_machine_id is None: logger.info("'Pause' is not a valid action to initiate state machine execution.") return if self.state_machine_manager.get_active_state_machine(...
Create a Python 3 function to set the execution mode to paused
You are a Python code architect, reviewing and designing scalable and efficient code
Returns a boolean indicating whether the condition check is finished or stopped.
Make a summary of the following Python 3 code def finished_or_stopped(self): return (self._status.execution_mode is StateMachineExecutionStatus.STOPPED) or \ (self._status.execution_mode is StateMachineExecutionStatus.FINISHED)
As a Python code analyst, you investigate and solve complex coding mysteries
def start(self, state_machine_id=None, start_state_path=None): """ Start state machine If no state machine is running start a specific state machine. If no state machine is provided the currently active state machine is started. If there is already a state machine running, just resume i...
Write a Python 3 function that can start a specific state machine.
As a Python code analyst, you investigate and solve complex coding mysteries