code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
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_backup']['marked_dirty'] = self.state_machine_model.state_machine.marked_dirty | def update_last_backup_meta_data(self) | Update the auto backup meta data with internal recovery information | 5.336002 | 5.109794 | 1.04427 |
# 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_model.state_machine.last_update
self.meta['last_saved']['file_system_path'] = self.state_m... | def update_last_sm_origin_meta_data(self) | Update the auto backup meta data with information of the state machine origin | 11.997864 | 10.615766 | 1.130193 |
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 and fix it better
if self._timer_request_time is None:
# logger... | def _check_for_dyn_timed_auto_backup(self) | The method implements the timed storage feature.
The method re-initiating a new timed thread if the state-machine not already stored to backup
(what could be caused by the force_temp_storage_interval) or force the storing of the state-machine if there
is no new request for a timed backup. Ne... | 3.718313 | 3.211678 | 1.157748 |
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:
# logger.info("adjust last_backup_time " + str(sm.state_machine_id))
... | def check_for_auto_backup(self, force=False) | The method implements the checks for possible auto backup of the state-machine according duration till
the last change together with the private method _check_for_dyn_timed_auto_backup.
If the only_fix_interval is True this function is called ones in the beginning and is called by a timed-
thre... | 3.337414 | 2.943444 | 1.133847 |
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) | def on_drag_data_get(self, widget, context, data, info, time) | dragged state is inserted and its state_id sent to the receiver
:param widget:
:param context:
:param data: SelectionData: contains state_id
:param info:
:param time: | 7.581092 | 7.879707 | 0.962103 |
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:
return gui_helper_state_machine.insert_state_into_selected_state(self._get_state(),... | def on_mouse_click(self, widget, event) | state insertion on mouse click
:param widget:
:param Gdk.Event event: mouse click event | 5.71496 | 5.622715 | 1.016406 |
path = self.view.get_path_at_pos(int(event.x), int(event.y))
if path is not None:
self.view.select_path(path)
else:
self.view.unselect_all() | def on_mouse_motion(self, widget, event) | selection on mouse over
:param widget:
:param Gdk.Event event: mouse motion event | 2.158859 | 2.386676 | 0.904546 |
selected = self.view.get_selected_items()
if not selected:
return
shorthand, state_class = self.view.states[selected[0][0]]
return state_class() | def _get_state(self) | get state instance which was clicked on
:return: State that represents the icon which was clicked on
:rtype: rafcon.core.states.State | 8.892522 | 6.743179 | 1.318743 |
super(StateOutcomesListController, self).register_view(view)
if isinstance(view, StateOutcomesTreeView):
self.connect_signal(view['to_state_combo'], "edited", self.on_to_state_edited)
self.connect_signal(view['to_outcome_combo'], "edited", self.on_to_outcome_edited)
... | def register_view(self, view) | Called when the View was registered
Can be used e.g. to connect signals. Here, the destroy signal is connected to close the application | 5.623219 | 5.985964 | 0.939401 |
# Don't do anything if outcome name didn't change
if new_name == self.list_store[path][self.NAME_STORAGE_ID]:
return
outcome = self.list_store[path][self.CORE_STORAGE_ID]
try:
outcome.name = new_name
logger.debug("Outcome name changed to '{0}... | 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 | 3.264154 | 3.343894 | 0.976154 |
def do_self_transition_check(t_id, new_state_identifier):
# add self transition meta data
if 'self' in new_state_identifier.split('.'):
insert_self_transition_meta_data(self.model, t_id, 'outcomes_widget', combined_action=True)
outcome_id = self.list_sto... | def on_to_state_edited(self, renderer, path, new_state_identifier) | Connects the outcome with a transition to the newly set state
:param Gtk.CellRendererText renderer: The cell renderer that was edited
:param str path: The path string of the renderer
:param str new_state_identifier: An identifier for the new state that was selected | 2.996645 | 3.025341 | 0.990515 |
if self.model.parent is None:
return
outcome_id = self.list_store[path][self.ID_STORAGE_ID]
transition_parent_state = self.model.parent.state
if outcome_id in self.dict_to_other_state or outcome_id in self.dict_to_other_outcome:
if outcome_id in self.dict... | 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_identifier: An identifier for the new outcome that was selected | 2.829276 | 2.823498 | 1.002047 |
assert model.outcome.parent is self.model.state
gui_helper_state_machine.delete_core_element_of_model(model) | 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: | 19.936125 | 18.038078 | 1.105224 |
super(StateOutcomesEditorController, self).register_view(view)
if isinstance(view, StateOutcomesEditorView):
self.connect_signal(view['add_button'], "clicked", self.oc_list_ctrl.on_add)
self.connect_signal(view['remove_button'], "clicked", self.oc_list_ctrl.on_remove)
... | def register_view(self, view) | Called when the View was registered
Can be used e.g. to connect signals. Here, the destroy signal is connected to close the application | 4.32689 | 4.737585 | 0.913311 |
if react_to_event(self.view, self.oc_list_ctrl.tree_view, event) and self.oc_list_ctrl.active_entry_widget is None:
global_clipboard.paste(self.model, limited=['outcomes'])
return True | def paste_action_callback(self, *event) | Callback method for paste action | 17.794533 | 18.260422 | 0.974486 |
page = self.page_dict[tab_label]
for notebook in self.notebook_names:
page_num = self[notebook].page_num(page)
if not page_num == -1:
self[notebook].set_current_page(page_num)
break | 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 | 3.71471 | 3.947094 | 0.941125 |
config_key = info['args'][1]
if "LOGGING" in config_key:
self.update_log_button_state() | def on_config_value_changed(self, config_m, prop_name, info) | Callback when a config value has been changed
:param ConfigModel config_m: The config model that has been changed
:param str prop_name: Should always be 'config'
:param dict info: Information e.g. about the changed config key | 8.764543 | 11.871803 | 0.738265 |
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
name2 = tree_model[path2][0]
name1_as_bits = ' '.join(format(ord(x), 'b') for x in name1)
... | def compare_variables(tree_model, iter1, iter2, user_data=None) | Triggered upon updating the list of global variables
Helper method to sort global variables alphabetically.
:param tree_model: Tree model implementing the Gtk.TreeSortable interface.
:param iter1: Points at a row.
:param iter2: Points at a row. | 1.914294 | 1.894447 | 1.010476 |
for sm in self.state_machines.values():
if sm.marked_dirty:
return True
return False | def has_dirty_state_machine(self) | Checks if one of the registered sm has the marked_dirty flag set to True (i.e. the sm was recently modified,
without being saved)
:return: True if contains state machine that is marked dirty, False otherwise. | 4.926479 | 3.152666 | 1.562639 |
for sm_id, sm in self.state_machines.items():
sm.marked_dirty = False | def reset_dirty_flags(self) | Set all marked_dirty flags of the state machine to false. | 8.338237 | 3.680462 | 2.265541 |
if not isinstance(state_machine, StateMachine):
raise AttributeError("State machine must be of type StateMachine")
if state_machine.file_system_path is not None:
if self.is_state_machine_open(state_machine.file_system_path):
raise AttributeError("The stat... | 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 machine was already added of is of a wrong type | 2.328585 | 2.425019 | 0.960234 |
import rafcon.core.singleton as core_singletons
removed_state_machine = None
if state_machine_id in self._state_machines:
logger.debug("Remove state machine with id {0}".format(state_machine_id))
removed_state_machine = self._state_machines.pop(state_machine_id)
... | 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 | 3.306173 | 3.464864 | 0.9542 |
if self._active_state_machine_id in self._state_machines:
return self._state_machines[self._active_state_machine_id]
else:
return None | def get_active_state_machine(self) | Return a reference to the active state-machine | 2.346524 | 2.136935 | 1.098079 |
for sm in self.state_machines.values():
if sm.file_system_path == file_system_path:
return sm | 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 | 2.909512 | 2.383909 | 1.220479 |
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 == 'upper':
new_title = title + ' / ' + lower_title
else:
new_title = uppe... | def reset_title(self, title, notebook_identifier) | Triggered whenever a notebook tab is switched in the left bar.
Resets the title of the un-docked window to the format 'upper_open_tab / lower_open_tab'
:param title: The name of the newly selected tab
:param notebook: string taking one of two values 'upper' or 'lower' indicating which notebook... | 3.208903 | 2.72036 | 1.179588 |
if with_logger is None:
with_logger = logger
# check that the model in the list expected_future_model was used
if model in target_state_m.expected_future_models:
with_logger.warning("{0} -> still in is: {1} Please inform the developer how to reproduce this."
... | 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 StateModel target_state_m: The state model which expected_future_models attribute should be checked
:param Model model: Model to... | 5.705021 | 5.686272 | 1.003297 |
if with_logger is None:
with_logger = logger
# check that the model in the list expected_future_model was used
if target_state_m.expected_future_models:
with_logger.warning("{0} -> still in are: {1} Please inform the developer how to reproduce this."
"".forma... | 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 expected_future_models attribute should be checked
:param str msg: Message for the logger if a model is... | 5.735546 | 5.462115 | 1.05006 |
assert isinstance(state_m, AbstractStateModel)
if isinstance(state_m, LibraryStateModel):
if not state_m.state_copy_initialized:
if not expected:
logger.warning("State {0} generates unexpected missing state copy models.".format(state_m))
state_m.recursive_g... | def update_models_recursively(state_m, expected=True) | If a state model is reused the model depth maybe is to low. Therefore this method checks if all
library state models are created with reliable depth
:param bool expected: Define newly generated library models as expected or triggers logger warnings if False | 5.264719 | 4.784908 | 1.100276 |
if container_state_m is None:
logger.error("Cannot add a state without a parent.")
return False
if not isinstance(container_state_m, StateModel) or \
(isinstance(container_state_m, StateModel) and not isinstance(container_state_m, ContainerStateModel)):
logger.error("Pa... | 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.StateType state_type: The type of state that should b... | 3.238471 | 3.144871 | 1.029763 |
# 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 parameter of the Core-function
current_state_is_container = isinstance(orig_state, ContainerState)
new_sta... | def extract_child_models_of_state(state_m, new_state_class) | Retrieve child models of state model
The function extracts the child state and state element models of the given state model into a dict. It only
extracts those properties that are required for a state of type `new_state_class`. Transitions are always left out.
:param state_m: state model of which childre... | 4.098021 | 4.035623 | 1.015462 |
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(new_state, meta=meta, load_meta_data=False, expected_future_models=state_element_models)
error_msg = "New state has not re-used all han... | def create_state_model_for_state(new_state, meta, state_element_models) | Create a new state model with the defined properties
A state model is created for a state of the type of new_state. All child models in state_element_models (
model list for port, connections and states) are added to the new model.
:param StateModel new_state: The new state object with the correct type
... | 5.594019 | 6.185542 | 0.90437 |
# 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 meta data and rename it
if isinstance(state_m_to_insert, AbstractStateModel) and \
not gui_helper_meta_data.model_has_empty_... | def prepare_state_m_for_insert_as(state_m_to_insert, previous_state_size) | Prepares and scales the meta data to fit into actual size of the state. | 4.670111 | 4.559931 | 1.024163 |
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 False
state_m = get_state_model_class_for_state(state)(state)
if not as_template:
... | def insert_state_as(target_state_m, state, as_template) | Add a state into a target state
In case the state to be insert is a LibraryState it can be chosen to be insert as template.
:param rafcon.gui.models.container_state.ContainerStateModel target_state_m: State model of the target state
:param rafcon.core.states.State state: State to be insert as template or ... | 5.785487 | 5.505568 | 1.050843 |
state_m = get_state_model_class_for_state(state)(state)
# If inserted as template, we have to extract the state_copy and model otherwise keep original name
if as_template:
assert isinstance(state_m, LibraryStateModel)
state_m = state_m.state_copy
state_m.state.parent = None
... | 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 LibraryState it can be chosen to be inserted as template.
It can be chosen that the inse... | 4.249379 | 4.053846 | 1.048234 |
if not hasattr(e, "callbacks"): # Event has not been orified yet
e._set = e.set
e._clear = e.clear
e.set = lambda: or_set(e)
e.clear = lambda: or_clear(e)
e.callbacks = list()
# Keep track of one callback per multi event
e.callbacks.append(changed_callback) | 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: | 4.444309 | 4.515992 | 0.984127 |
or_event = threading.Event()
def changed():
if any([event.is_set() for event in events]):
or_event.set()
else:
or_event.clear()
for e in events:
orify(e, changed)
changed()
return or_event | 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 | 4.194518 | 4.963641 | 0.845049 |
current_enables = self._get_config_enables()
if not self._enables == current_enables:
# check if filtered buffer update needed
filtered_buffer_update_needed = True
if all(self._enables[key] == current_enables[key] for key in ['VERBOSE', 'DEBUG', 'INFO', 'WARN... | def model_changed(self, model, prop_name, info) | React to configuration changes
Update internal hold enable state, propagates it to view and refresh the text buffer. | 3.870905 | 3.48464 | 1.110848 |
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_info[0]
item_iter = self.tree_store.get_iter(path)
... | def _handle_double_click(self, event) | Double click with left mouse button focuses the state and toggles the collapse status | 3.493763 | 3.121344 | 1.119314 |
import os
if not os.path.exists(path):
os.makedirs(path) | def create_path(path) | Creates a absolute path in the file system.
:param path: The path to be created | 2.743053 | 4.07847 | 0.672569 |
import hashlib
BLOCKSIZE = 65536
hasher = hashlib.md5()
with open(filename, 'rb') as afile:
buf = afile.read(BLOCKSIZE)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(BLOCKSIZE)
return hasher.hexdigest() | def get_md5_file_hash(filename) | Calculates the MD5 hash of a file
:param str filename: The filename (including the path) of the file
:return: Md5 hash of the file
:rtype: str | 1.367882 | 1.531252 | 0.893309 |
if not os.path.isfile(target_file) or get_md5_file_hash(target_file) != get_md5_file_hash(source_file):
return True
return False | 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: False | 2.275 | 2.614564 | 0.870126 |
if file_needs_update(target_file, source_file):
shutil.copy(source_file, target_file) | def copy_file_if_update_required(source_file, target_file) | Copies source_file to target_file if latter one in not existing or outdated
:param source_file: Source file of the copy operation
:param target_file: Target file of the copy operation | 3.033923 | 4.335145 | 0.699843 |
file_path = os.path.realpath(file_path)
if filename:
file_path = os.path.join(file_path, filename)
file_content = None
if os.path.isfile(file_path):
with open(file_path, 'r') as file_pointer:
file_content = file_pointer.read()
return file_content | 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 string.
:param str filename: File name of the fi... | 1.80162 | 2.066096 | 0.871993 |
paths_to_delete = []
for path in file_system_paths:
if not os.path.exists(path):
paths_to_delete.append(path)
for path in paths_to_delete:
file_system_paths.remove(path) | 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 | 1.538751 | 2.272075 | 0.677245 |
# If this model has been changed (and not one of its child states), then we have to update all child models
# This must be done before notifying anybody else, because other may relay on the updated models
if 'after' in info and self.state == info['instance']:
self.update_mod... | def model_changed(self, model, prop_name, info) | This method notifies the model lists and the parent state about changes
The method is called each time, the model is changed. This happens, when the state itself changes or one of
its children (outcomes, ports) changes. Changes of the children cannot be observed directly,
therefore children not... | 4.50668 | 4.092483 | 1.101209 |
if info.method_name in ["add_input_data_port", "remove_input_data_port", "input_data_ports"]:
(model_list, data_list, model_name, model_class, model_key) = self.get_model_info("input_data_port")
elif info.method_name in ["add_output_data_port", "remove_output_data_port", "output_da... | def update_models(self, model, name, info) | This method is always triggered when the core state changes
It keeps the following models/model-lists consistent:
input-data-port models
output-data-port models
outcome models | 2.006921 | 1.855123 | 1.081826 |
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) | def _load_input_data_port_models(self) | Reloads the input data port models directly from the the state | 3.301885 | 2.630121 | 1.255411 |
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) | def _load_output_data_port_models(self) | Reloads the output data port models directly from the the state | 3.145849 | 2.571175 | 1.223506 |
self._add_model(self.income, self.state.income, IncomeModel) | def _load_income_model(self) | Create income model from core income | 13.780355 | 11.030473 | 1.249299 |
self.outcomes = []
for outcome in self.state.outcomes.values():
self._add_model(self.outcomes, outcome, OutcomeModel) | def _load_outcome_models(self) | Create outcome models from core outcomes | 5.307142 | 4.261694 | 1.245313 |
if model_name == "income":
if self.income.income != self.state.income:
self._add_model(self.income, self.state.income, IncomeModel)
return
for _ in range(len(model_list_or_dict)):
self.remove_additional_model(model_list_or_dict, core_objects_... | 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 one model type
:param core_objects_dict: new dictionary of one type of core-elements (rafcon.core)
:para... | 3.183142 | 3.280618 | 0.970287 |
found_model = self._get_future_expected_model(core_element)
if found_model:
found_model.parent = self
if model_class is IncomeModel:
self.income = found_model if found_model else IncomeModel(core_element, self)
return
if model_key is None:
... | def _add_model(self, model_list_or_dict, core_element, model_class, model_key=None, load_meta_data=True) | Adds one model for a given core element.
The method will add a model for a given core object and checks if there is a corresponding model object in the
future expected model list. The method does not check if an object with corresponding model has already been
inserted.
:param model_li... | 2.652775 | 2.600891 | 1.019949 |
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_list_or_dict[model_or_key]
if core_object is getattr(model, model_name):
return True
return F... | def add_missing_model(self, model_list_or_dict, core_elements_dict, model_name, model_class, model_key) | Adds one missing model
The method will search for the first core-object out of core_object_dict
not represented in the list or dict of models handed by model_list_or_dict, adds it and returns without continue
to search for more objects which maybe are missing in model_list_or_dict with respect ... | 3.673967 | 3.40586 | 1.078719 |
if model_name == "income":
self.income.prepare_destruction()
self.income = None
return
for model_or_key in model_list_or_dict:
model = model_or_key if model_key is None else model_list_or_dict[model_or_key]
found = False
f... | 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 core_objects_dict,
remove it and return without continue to search for more model-objects which maybe are unnecessa... | 2.431779 | 2.577736 | 0.943378 |
for model in self.expected_future_models:
if model.core_element is core_element:
# print("expected_future_model found -> remove model:", model, [model], id(model))
self.expected_future_models.remove(model)
return model
return None | 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 | 5.10504 | 4.193556 | 1.217353 |
config = dict()
for key in self.config.keys:
if use_preliminary and key in self.preliminary_config:
value = self.preliminary_config[key]
else:
value = self.config.get_config_value(key)
config[key] = value
return config | 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 | 2.434812 | 2.820232 | 0.863337 |
config_path = path.dirname(config_file)
self.config.config_file_path = config_file
self.config.path = config_path
for config_key, config_value in config_dict.items():
if config_value != self.config.get_config_value(config_key):
self.set_preliminary_co... | 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 | 2.976599 | 3.370052 | 0.88325 |
if use_preliminary and config_key in self.preliminary_config:
return copy(self.preliminary_config[config_key])
return copy(self.config.get_config_value(config_key, default)) | 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
:param default: The value to return if config key does not exist
:return: Copy of the ... | 2.333762 | 2.661667 | 0.876805 |
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 value, we can remove the entry
elif config_key in self.preliminary_config:
del self.preliminary_config[conf... | def set_preliminary_config_value(self, config_key, config_value) | Stores a config value as preliminary new value
The config value is not yet applied to the configuration. If the value is identical to the one from the
configuration, the entry is deleted from the preliminary config.
:param str config_key: Key of the entry
:param config_value: New value | 2.729748 | 2.834342 | 0.963097 |
state_machine_refresh_required = False
for config_key, config_value in self.preliminary_config.items():
self.config.set_config_value(config_key, config_value)
if config_key in self.config.keys_requiring_state_machine_refresh:
state_machine_refresh_require... | 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 | 3.132161 | 2.947645 | 1.062598 |
if parent is None:
self._parent = None
else:
from rafcon.core.states.state import State
assert isinstance(parent, State)
old_parent = self.parent
self._parent = ref(parent)
valid, message = self._check_validity()
... | def parent(self, parent) | Setter for the parent state of the state element
:param rafcon.core.states.state.State parent: Parent state or None | 4.479972 | 4.185813 | 1.070275 |
assert isinstance(property_name, string_types)
old_value = getattr(self, property_name)
setattr(self, property_name, value)
valid, message = self._check_validity()
if not valid:
setattr(self, property_name, old_value)
class_name = self.__class__.... | def _change_property_with_validity_check(self, property_name, value) | Helper method to change a property and reset it if the validity check fails
:param str property_name: The name of the property to be changed, e.g. '_data_flow_id'
:param value: The new desired value for this property
:raises exceptions.ValueError: if a property could not be changed | 3.005175 | 2.969237 | 1.012103 |
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_validity(self) | def _check_validity(self) | Checks the validity of the state element's properties
Some validity checks can only be performed by the parent. Thus, the existence of a parent and a check
function must be ensured and this function be queried.
:return: validity and messages
:rtype: bool, str | 7.527901 | 5.632175 | 1.336588 |
if info['method_name'] == '__setitem__':
self.observe_model(info['args'][1])
self.logger.info(NotificationOverview(info))
elif info['method_name'] == '__delitem__':
pass
else:
self.logger.warning(NotificationOverview(info)) | def register_new_state_machines(self, model, prop_name, info) | The method register self as observer newly added StateMachineModels after those were added to the list of
state_machines hold by observed StateMachineMangerModel. The method register as observer of observable
StateMachineMangerModel.state_machines. | 6.199864 | 5.394391 | 1.149317 |
if info['method_name'] == '__setitem__':
pass
elif info['method_name'] == '__delitem__':
self.relieve_model(self.state_machine_manager_model.state_machines[info['args'][0]])
self.logger.info(NotificationOverview(info))
else:
self.logger.wa... | def relieve_state_machines(self, model, prop_name, info) | The method relieves observed models before those get removed from the list of state_machines hold by
observed StateMachineMangerModel. The method register as observer of observable
StateMachineMangerModel.state_machines. | 5.601601 | 4.626611 | 1.210735 |
self.logger.debug(NotificationOverview(info)) | def all_after_notification(self, model, prop_name, info) | The method logs all changes that notified recursively trough the hierarchies of the states after the change
occurs in the rafcon.core object. The method register as observer of observable
StateMachineModel.state_machine of any observed StateMachineModel.
:param model: StateMachineModel that is r... | 71.038895 | 67.502197 | 1.052394 |
if info['method_name'] == '__setitem__':
pass
elif info['method_name'] == '__delitem__':
self.relieve_model(self.state_machine_manager_model.state_machines[info['args'][0]])
if self.state_machine_manager_model.state_machines[info['args'][0]].root_state:
... | def relieve_state_machines(self, model, prop_name, info) | The method relieves observed models before those get removed from the list of state_machines hold by
observed StateMachineMangerModel. The method register as observer of observable
StateMachineMangerModel.state_machines. | 4.266912 | 3.838979 | 1.111471 |
if info['old']:
self.relieve_model(info['old'])
if info['new']:
self.observe_model(info['new'])
self.logger.info("Exchange observed old root_state model with newly assigned one. sm_id: {}"
"".format(info['new'].state.parent.state_... | def observe_root_state_assignments(self, model, prop_name, info) | The method relieves observed root_state models and observes newly assigned root_state models. | 8.778965 | 5.648288 | 1.55427 |
self.logger.info(NotificationOverview(info)) | def observe_meta_signal_changes(self, changed_model, prop_name, info) | The method prints the structure of all meta_signal-notifications as log-messages. | 95.785141 | 35.310871 | 2.712625 |
for key, value in new_dict.items():
if isinstance(value, dict):
self[str(key)] = Vividict(value)
else:
self[str(key)] = value | 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 | 2.695193 | 2.178832 | 1.23699 |
try:
from numpy import ndarray
except ImportError:
ndarray = dict
dictionary = {}
def np_to_native(np_val):
if isinstance(np_val, dict):
for key, value in np_val.items():
np_val[key] = np_to_n... | def vividict_to_dict(vividict) | Helper method to create Python dicts from arbitrary Vividict objects
:param Vividict vividict: A Vividict to be converted
:return: A Python dict
:rtype: dict | 3.380221 | 3.382192 | 0.999417 |
dictionary = cls.vividict_to_dict(vividict)
node = dumper.represent_mapping(cls.yaml_tag, dictionary)
return node | def to_yaml(cls, dumper, vividict) | Implementation for the abstract method of the base class YAMLObject | 3.69681 | 3.652318 | 1.012182 |
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)
view['open_externally'].connect('clicked', self.open_externally_clicked)
... | def register_view(self, view) | Called when the View was registered
Can be used e.g. to connect signals. Here, the destroy signal is connected to close the application
:param rafcon.gui.views.state_editor.semantic_data_editor.SemanticDataEditorView view: An view to show all
semantic data of a state | 4.712724 | 4.608432 | 1.022631 |
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_sensitive(not locked)
for current_column in self.view['semantic_data_tree_view']... | def set_editor_lock(self, locked=True) | Implements the abstract method of the ExternalEditor class. | 3.709158 | 3.651891 | 1.015681 |
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 | def get_selected_object(self) | Gets the selected object in the treeview
:return: | 3.247005 | 3.554169 | 0.913576 |
self.semantic_data_counter += 1
treeiter, path = self.get_selected_object()
value = dict() if new_dict else "New Value"
# get target dict path
if treeiter:
target_dict_path_as_list = self.tree_store[path][self.ID_STORAGE_ID]
if not self.tree_sto... | 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: | 4.006395 | 3.658224 | 1.095175 |
if react_to_event(self.view, self.tree_view, event=(key_value, modifier_mask)) and self.active_entry_widget is None:
self.on_add(None, a_dict)
return True | def add_action_callback(self, key_value, modifier_mask, a_dict=False) | Callback method for add action | 9.12168 | 9.227287 | 0.988555 |
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]
logger.debug("Deleting semantic data entry with name {}!".format(dict_path_as_list[-1]))
... | def on_remove(self, widget, data=None) | Removes an entry of semantic data of a state.
:param widget:
:return: | 3.578223 | 3.534506 | 1.012369 |
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.copy(parent_dict_path) + [key]
if isinstance(value, dict):
new_iter = self.tree_store.a... | def add_items_to_tree_iter(self, input_dict, treeiter, parent_dict_path=None) | Adds all values of the input dict to self.tree_store
:param input_dict: The input dictionary holds all values, which are going to be added.
:param treeiter: The pointer inside the tree store to add the input dict
:return: | 2.029893 | 2.11306 | 0.960642 |
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.expand_all()
try:
for path in paths:
self.tree_view.get_selection().se... | def reload_tree_store_data(self) | Reloads the data of the tree store
:return: | 3.573493 | 4.052927 | 0.881707 |
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 = []
for dict_path_as_list in dict_paths:
value = self.model.state.semantic_data
for... | def copy_action_callback(self, *event) | Add a copy of all selected row dict value pairs to the clipboard | 6.50771 | 6.469712 | 1.005873 |
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_semantic_dictionary_list()
# enforce paste on root level if semantic da... | def paste_action_callback(self, *event) | Add clipboard key value pairs into all selected sub-dictionary | 4.882238 | 4.810861 | 1.014837 |
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_list in dict_paths:
if dict_path_as_list:
value = self.model... | def cut_action_callback(self, *event) | Add a copy and cut all selected row dict value pairs to the clipboard | 5.348942 | 5.2071 | 1.02724 |
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:
return
dict_path = self.tree_store[tree_store_path][self.ID_STORAGE_ID]
old_value... | def key_edited(self, path, new_key_str) | Edits the key of a semantic data entry
:param path: The path inside the tree store to the target entry
:param str new_key_str: The new value of the target cell
:return: | 3.925197 | 3.841934 | 1.021672 |
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
dict_path = self.tree_store[tree_store_path][self.ID_STORAGE_ID]
self.... | def value_edited(self, path, new_value_str) | Adds the value of the semantic data entry
:param path: The path inside the tree store to the target entry
:param str new_value_str: The new value of the target cell
:return: | 4.343109 | 4.160552 | 1.043878 |
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_id:
iter_found.append(self.tree_store.get_path(row_iter))
fou... | def get_path_for_core_element(self, core_element_id) | Get path to the row representing core element described by handed core_element_id
:param list core_element_id: Core element identifier used in the respective list store column
:rtype: tuple
:return: path | 4.13318 | 3.865121 | 1.069353 |
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_utils.write_dict_to_json(self.model.state.semantic_data, os.path.join... | def save_file_data(self, path) | Implements the abstract method of the ExternalEditor class. | 8.650927 | 8.559268 | 1.010709 |
semantic_data = load_data_file(os.path.join(file_system_path, storage.SEMANTIC_DATA_FILE))
self.model.state.semantic_data = semantic_data | def load_and_set_file_content(self, file_system_path) | Implements the abstract method of the ExternalEditor class. | 5.816371 | 5.435691 | 1.070033 |
if isinstance(widget, Gtk.Window):
maximized = bool(widget.is_maximized())
self.set_config_value('{0}_MAXIMIZED'.format(widget_name), maximized)
if maximized:
return
size = widget.get_size()
self.set_config_value('{0}_SIZE'.for... | 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 maximized is keep in the
config and the maximized flag set to True.... | 2.181672 | 2.054367 | 1.061968 |
if state_machine.file_system_path:
# check if path is in recent path already
# logger.info("update recent state machine: {}".format(sm.file_system_path))
recently_opened_state_machines = self.get_config_value('recently_opened_state_machines', [])
if state... | def update_recently_opened_state_machines_with(self, state_machine) | Update recently opened list with file system path of handed state machine model
The inserts handed state machine file system path into the recent opened state machines or moves it to be the
first element in the list.
:param rafcon.core.state_machine.StateMachine state_machine: State machine to... | 2.171988 | 2.195754 | 0.989176 |
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_state_machines_with(sm_m.state_machine) | def extend_recently_opened_by_current_open_state_machines(self) | Update list with all in the state machine manager opened state machines | 5.538432 | 4.478902 | 1.23656 |
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.get_config_value('recently_opened_state_machines', [])
self.set_config_value('recently_opened_state_machines', ... | def prepare_recently_opened_state_machines_list_for_storage(self) | Reduce number of paths in the recent opened state machines to limit from gui config | 4.215915 | 3.24735 | 1.298263 |
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_config_value('recently_opened_state_machines', state_machine_paths) | def clean_recently_opened_state_machines(self) | Remove state machines who's file system path does not exist | 3.739852 | 2.888517 | 1.294731 |
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() is not None:
self.state_machine_manager.get_active... | def pause(self) | Set the execution mode to paused | 5.332567 | 5.07366 | 1.05103 |
return (self._status.execution_mode is StateMachineExecutionStatus.STOPPED) or \
(self._status.execution_mode is StateMachineExecutionStatus.FINISHED) | def finished_or_stopped(self) | Condition check on finished or stopped status
The method returns a value which is equivalent with not 'active' status of the current state machine.
:return: outcome of condition check stopped or finished
:rtype: bool | 6.362561 | 5.746265 | 1.107251 |
if not self.finished_or_stopped():
logger.debug("Resume execution engine ...")
self.run_to_states = []
if self.state_machine_manager.get_active_state_machine() is not None:
self.state_machine_manager.get_active_state_machine().root_state.recursively_... | 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 it without taking the passed state_machine_id argument
into account.... | 3.021614 | 3.053294 | 0.989624 |
logger.debug("Stop the state machine execution ...")
if self.state_machine_manager.get_active_state_machine() is not None:
self.state_machine_manager.get_active_state_machine().root_state.recursively_preempt_states()
self.__set_execution_mode_to_stopped()
# Notifies... | def stop(self) | Set the execution mode to stopped | 6.584535 | 6.184182 | 1.064738 |
if self.__wait_for_finishing_thread:
if not timeout:
# signal handlers won't work if timeout is None and the thread is joined
while True:
self.__wait_for_finishing_thread.join(0.5)
if not self.__wait_for_finishing_threa... | def join(self, timeout=None) | Blocking wait for the execution to finish
:param float timeout: Maximum time to wait or None for infinitely
:return: True if the execution finished, False if no state machine was started or a timeout occurred
:rtype: bool | 3.550066 | 3.182288 | 1.11557 |
# Create new concurrency queue for root state to be able to synchronize with the execution
self.__running_state_machine = self.state_machine_manager.get_active_state_machine()
if not self.__running_state_machine:
logger.error("The running state machine must not be None")
... | def _run_active_state_machine(self) | Store running state machine and observe its status | 4.390923 | 4.194674 | 1.046785 |
self.state_machine_running = True
self.__running_state_machine.join()
self.__set_execution_mode_to_finished()
self.state_machine_manager.active_state_machine_id = None
plugins.run_on_state_machine_execution_finished()
# self.__set_execution_mode_to_stopped()
... | def _wait_for_finishing(self) | Observe running state machine and stop engine if execution has finished | 6.051257 | 4.974315 | 1.216501 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.