sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def setup_forward_or_backward_execution(self):
""" Sets up the execution of the concurrency states dependent on if the state is executed forward of backward.
:return:
"""
if self.backward_execution:
# pop the return item of this concurrency state to get the correct scoped da... | Sets up the execution of the concurrency states dependent on if the state is executed forward of backward.
:return: | entailment |
def start_child_states(self, concurrency_history_item, do_not_start_state=None):
""" Utility function to start all child states of the concurrency state.
:param concurrency_history_item: each concurrent child branch gets an execution history stack of this
concurr... | Utility function to start all child states of the concurrency state.
:param concurrency_history_item: each concurrent child branch gets an execution history stack of this
concurrency history item
:param do_not_start_state: optionally the id of a state can be pass... | entailment |
def join_state(self, state, history_index, concurrency_history_item):
""" a utility function to join a state
:param state: the state to join
:param history_index: the index of the execution history stack in the concurrency history item
for the given state
... | a utility function to join a state
:param state: the state to join
:param history_index: the index of the execution history stack in the concurrency history item
for the given state
:param concurrency_history_item: the concurrency history item that stores the exe... | entailment |
def finalize_backward_execution(self):
""" Utility function to finalize the backward execution of the concurrency state.
:return:
"""
# backward_execution needs to be True to signal the parent container state the backward execution
self.backward_execution = True
# pop th... | Utility function to finalize the backward execution of the concurrency state.
:return: | entailment |
def finalize_concurrency_state(self, outcome):
""" Utility function to finalize the forward execution of the concurrency state.
:param outcome:
:return:
"""
final_outcome = outcome
self.write_output_data()
self.check_output_data_type()
self.execution_hist... | Utility function to finalize the forward execution of the concurrency state.
:param outcome:
:return: | entailment |
def _head_length(self, port):
"""Distance from the center of the port to the perpendicular waypoint"""
if not port:
return 0.
parent_state_v = self.get_parent_state_v()
if parent_state_v is port.parent: # port of connection's parent state
return port.port_size[1]... | Distance from the center of the port to the perpendicular waypoint | entailment |
def register_view(self, view):
"""Called when the View was registered"""
super(DataPortListController, self).register_view(view)
view['name_col'].add_attribute(view['name_text'], 'text', self.NAME_STORAGE_ID)
view['data_type_col'].add_attribute(view['data_type_text'], 'text', self.DATA_... | Called when the View was registered | entailment |
def on_use_runtime_value_toggled(self, widget, path):
"""Try to set the use runtime value flag to the newly entered one
"""
try:
data_port_id = self.list_store[path][self.ID_STORAGE_ID]
self.toggle_runtime_value_usage(data_port_id)
except TypeError as e:
... | Try to set the use runtime value flag to the newly entered one | entailment |
def _default_value_cell_data_func(self, tree_view_column, cell, model, iter, data=None):
"""Function set renderer properties for every single cell independently
The function controls the editable and color scheme for every cell in the default value column according
the use_runtime_value flag an... | Function set renderer properties for every single cell independently
The function controls the editable and color scheme for every cell in the default value column according
the use_runtime_value flag and whether the state is a library state.
:param tree_view_column: the Gtk.TreeViewColumn to ... | entailment |
def _reload_data_port_list_store(self):
"""Reloads the input data port list store from the data port models"""
tmp = self._get_new_list_store()
for data_port_m in self.data_port_model_list:
data_port_id = data_port_m.data_port.data_port_id
data_type = data_port_m.data_po... | Reloads the input data port list store from the data port models | entailment |
def _apply_new_data_port_name(self, path, new_name):
"""Applies the new name of the data port defined by path
:param str path: The path identifying the edited data port
:param str new_name: New name
"""
try:
data_port_id = self.list_store[path][self.ID_STORAGE_ID]
... | Applies the new name of the data port defined by path
:param str path: The path identifying the edited data port
:param str new_name: New name | entailment |
def _apply_new_data_port_type(self, path, new_data_type_str):
"""Applies the new data type of the data port defined by path
:param str path: The path identifying the edited data port
:param str new_data_type_str: New data type as str
"""
try:
data_port_id = self.list... | Applies the new data type of the data port defined by path
:param str path: The path identifying the edited data port
:param str new_data_type_str: New data type as str | entailment |
def _apply_new_data_port_default_value(self, path, new_default_value_str):
"""Applies the new default value of the data port defined by path
:param str path: The path identifying the edited variable
:param str new_default_value_str: New default value as string
"""
try:
... | Applies the new default value of the data port defined by path
:param str path: The path identifying the edited variable
:param str new_default_value_str: New default value as string | entailment |
def _data_ports_changed(self, model):
"""Reload list store and reminds selection when the model was changed"""
if not isinstance(model, AbstractStateModel):
return
# store port selection
path_list = None
if self.view is not None:
model, path_list = self.tr... | Reload list store and reminds selection when the model was changed | entailment |
def runtime_values_changed(self, model, prop_name, info):
"""Handle cases for the library runtime values"""
if ("_input_runtime_value" in info.method_name or
info.method_name in ['use_runtime_value_input_data_ports',
'input_data_port_runtime_values'])... | Handle cases for the library runtime values | entailment |
def add_new_data_port(self):
"""Add a new port with default values and select it"""
try:
new_data_port_ids = gui_helper_state_machine.add_data_port_to_selected_states('OUTPUT', int, [self.model])
if new_data_port_ids:
self.select_entry(new_data_port_ids[self.model... | Add a new port with default values and select it | entailment |
def add_callback_for_action(self, action, callback):
"""Adds a callback function to an action
The method checks whether both action and callback are valid. If so, the callback is added to the list of
functions called when the action is triggered.
:param str action: An action like 'add'... | Adds a callback function to an action
The method checks whether both action and callback are valid. If so, the callback is added to the list of
functions called when the action is triggered.
:param str action: An action like 'add', 'copy', 'info'
:param callback: A callback function, w... | entailment |
def remove_callback_for_action(self, action, callback):
""" Remove a callback for a specific action
This is mainly for cleanup purposes or a plugin that replaces a GUI widget.
:param str action: the cation of which the callback is going to be remove
:param callback: the callback to be ... | Remove a callback for a specific action
This is mainly for cleanup purposes or a plugin that replaces a GUI widget.
:param str action: the cation of which the callback is going to be remove
:param callback: the callback to be removed | entailment |
def trigger_action(self, action, key_value, modifier_mask):
"""Calls the appropriate callback function(s) for the given action
:param str action: The name of the action that was triggered
:param key_value: The key value of the shortcut that caused the trigger
:param modifier_mask: The m... | Calls the appropriate callback function(s) for the given action
:param str action: The name of the action that was triggered
:param key_value: The key value of the shortcut that caused the trigger
:param modifier_mask: The modifier mask of the shortcut that caused the trigger
:return: W... | entailment |
def check_info_on_no_update_flags(self, info):
"""Stop updates while multi-actions"""
# TODO that could need a second clean up
# avoid updates because of state destruction
if 'before' in info and info['method_name'] == "remove_state":
if info.instance is self.model.state:
... | Stop updates while multi-actions | entailment |
def before_notification_state_machine_observation_control(self, model, prop_name, info):
"""Check for multi-actions and set respective no update flags. """
if is_execution_status_update_notification_from_state_machine_model(prop_name, info):
return
# do not update while multi-actions... | Check for multi-actions and set respective no update flags. | entailment |
def store_value(self, name, value, parameters=None):
"""Stores the value of a certain variable
The value of a variable with name 'name' is stored together with the parameters that were used for the
calculation.
:param str name: The name of the variable
:param value: The value t... | Stores the value of a certain variable
The value of a variable with name 'name' is stored together with the parameters that were used for the
calculation.
:param str name: The name of the variable
:param value: The value to be cached
:param dict parameters: The parameters on wh... | entailment |
def get_value(self, name, parameters=None):
"""Return the value of a cached variable if applicable
The value of the variable 'name' is returned, if no parameters are passed or if all parameters are identical
to the ones stored for the variable.
:param str name: Name of teh variable
... | Return the value of a cached variable if applicable
The value of the variable 'name' is returned, if no parameters are passed or if all parameters are identical
to the ones stored for the variable.
:param str name: Name of teh variable
:param dict parameters: Current parameters or None... | entailment |
def _normalize_number_values(self, parameters):
"""Assures equal precision for all number values"""
for key, value in parameters.items():
if isinstance(value, (int, float)):
parameters[key] = str(Decimal(value).normalize(self._context)) | Assures equal precision for all number values | entailment |
def register_view(self, view):
"""Register callbacks for button press events and selection changed"""
super(AbstractTreeViewController, self).register_view(view)
self.signal_handlers.append((self._tree_selection,
self._tree_selection.connect('changed', self.s... | Register callbacks for button press events and selection changed | entailment |
def get_view_selection(self):
"""Get actual tree selection object and all respective models of selected rows"""
if not self.MODEL_STORAGE_ID:
return None, None
# avoid selection requests on empty tree views -> case warnings in gtk3
if len(self.store) == 0:
paths ... | Get actual tree selection object and all respective models of selected rows | entailment |
def get_selections(self):
"""Get current model selection status in state machine selection (filtered according the purpose of the widget)
and tree selection of the widget"""
sm_selection, sm_filtered_selected_model_set = self.get_state_machine_selection()
tree_selection, selected_model_l... | Get current model selection status in state machine selection (filtered according the purpose of the widget)
and tree selection of the widget | entailment |
def state_machine_selection_changed(self, state_machine_m, signal_name, signal_msg):
"""Notify tree view about state machine selection"""
if self.CORE_ELEMENT_CLASS in signal_msg.arg.affected_core_element_classes:
self.update_selection_sm_prior() | Notify tree view about state machine selection | entailment |
def add_action_callback(self, *event):
"""Callback method for add action"""
if react_to_event(self.view, self.tree_view, event) and self.active_entry_widget is None:
self.on_add(None)
return True | Callback method for add action | entailment |
def remove_action_callback(self, *event):
"""Callback method for remove action
The method checks whether a shortcut ('Delete') is in the gui config model which shadow the delete functionality
of maybe active a entry widget. If a entry widget is active the remove callback return with None.
... | Callback method for remove action
The method checks whether a shortcut ('Delete') is in the gui config model which shadow the delete functionality
of maybe active a entry widget. If a entry widget is active the remove callback return with None. | entailment |
def copy_action_callback(self, *event):
"""Callback method for copy action"""
if react_to_event(self.view, self.tree_view, event) and self.active_entry_widget is None:
sm_selection, sm_selected_model_list = self.get_state_machine_selection()
# only list specific elements are copi... | Callback method for copy action | entailment |
def cut_action_callback(self, *event):
"""Callback method for copy action"""
if react_to_event(self.view, self.tree_view, event) and self.active_entry_widget is None:
sm_selection, sm_selected_model_list = self.get_state_machine_selection()
# only list specific elements are cut b... | Callback method for copy action | entailment |
def _apply_value_on_edited_and_focus_out(self, renderer, apply_method):
"""Sets up the renderer to apply changed when loosing focus
The default behaviour for the focus out event dismisses the changes in the renderer. Therefore we setup
handlers for that event, applying the changes.
:pa... | Sets up the renderer to apply changed when loosing focus
The default behaviour for the focus out event dismisses the changes in the renderer. Therefore we setup
handlers for that event, applying the changes.
:param Gtk.CellRendererText renderer: The cell renderer who's changes are to be applie... | entailment |
def tree_view_keypress_callback(self, widget, event):
"""General method to adapt widget view and controller behavior according the key press/release and
button release events
Here the scrollbar motion to follow key cursor motions in editable is already in.
:param Gtk.TreeView widge... | General method to adapt widget view and controller behavior according the key press/release and
button release events
Here the scrollbar motion to follow key cursor motions in editable is already in.
:param Gtk.TreeView widget: The tree view the controller use
:param Gdk.Event even... | entailment |
def register_view(self, view):
"""Register callbacks for button press events and selection changed"""
super(ListViewController, self).register_view(view)
self.tree_view.connect('button_press_event', self.mouse_click) | Register callbacks for button press events and selection changed | entailment |
def on_remove(self, widget, data=None):
"""Removes respective selected core elements and select the next one"""
path_list = None
if self.view is not None:
model, path_list = self.tree_view.get_selection().get_selected_rows()
old_path = self.get_path()
models = [self.... | Removes respective selected core elements and select the next one | entailment |
def get_state_machine_selection(self):
"""An abstract getter method for state machine selection
The method maybe has to be re-implemented by inherit classes and hands generally a filtered set of
selected elements.
:return: selection object it self, filtered set of selected elements
... | An abstract getter method for state machine selection
The method maybe has to be re-implemented by inherit classes and hands generally a filtered set of
selected elements.
:return: selection object it self, filtered set of selected elements
:rtype: rafcon.gui.selection.Selection, set | entailment |
def mouse_click(self, widget, event=None):
"""Implements shift- and control-key handling features for mouse button press events explicit
The method is implements a fully defined mouse pattern to use shift- and control-key for multi-selection in a
TreeView and a ListStore as model. It avoid pr... | Implements shift- and control-key handling features for mouse button press events explicit
The method is implements a fully defined mouse pattern to use shift- and control-key for multi-selection in a
TreeView and a ListStore as model. It avoid problems caused by special renderer types like the text ... | entailment |
def _handle_double_click(self, event):
""" Double click with left mouse button focuses the element"""
if event.get_button()[1] == 1: # Left mouse button
path_info = self.tree_view.get_path_at_pos(int(event.x), int(event.y))
if path_info: # Valid entry was clicked on
... | Double click with left mouse button focuses the element | entailment |
def update_selection_sm_prior(self):
"""State machine prior update of tree selection"""
if self._do_selection_update:
return
self._do_selection_update = True
tree_selection, selected_model_list, sm_selection, sm_selected_model_list = self.get_selections()
if tree_sele... | State machine prior update of tree selection | entailment |
def update_selection_self_prior(self):
"""Tree view prior update of state machine selection"""
if self._do_selection_update:
return
self._do_selection_update = True
tree_selection, selected_model_list, sm_selection, sm_selected_model_list = self.get_selections()
if is... | Tree view prior update of state machine selection | entailment |
def select_entry(self, core_element_id, by_cursor=True):
"""Selects the row entry belonging to the given core_element_id by cursor or tree selection"""
for row_num, element_row in enumerate(self.list_store):
# Compare data port ids
if element_row[self.ID_STORAGE_ID] == core_eleme... | Selects the row entry belonging to the given core_element_id by cursor or tree selection | entailment |
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 core_element_id: Core element identifier used in the respective list store column
:rtype: tuple
:return: path
"""
for row_num... | Get path to the row representing core element described by handed core_element_id
:param core_element_id: Core element identifier used in the respective list store column
:rtype: tuple
:return: path | entailment |
def tree_view_keypress_callback(self, widget, event):
"""Tab back and forward tab-key motion in list widget and the scrollbar motion to follow key cursor motions
The method introduce motion and edit functionality by using "tab"- or "shift-tab"-key for a Gtk.TreeView.
It is designed to work wi... | Tab back and forward tab-key motion in list widget and the scrollbar motion to follow key cursor motions
The method introduce motion and edit functionality by using "tab"- or "shift-tab"-key for a Gtk.TreeView.
It is designed to work with a Gtk.TreeView which model is a Gtk.ListStore and only uses te... | entailment |
def iter_tree_with_handed_function(self, function, *function_args):
"""Iterate tree view with condition check function"""
def iter_all_children(row_iter, function, function_args):
if isinstance(row_iter, Gtk.TreeIter):
function(row_iter, *function_args)
for n ... | Iterate tree view with condition check function | entailment |
def update_selection_sm_prior_condition(self, state_row_iter, selected_model_list, sm_selected_model_list):
"""State machine prior update of tree selection for one tree model row"""
selected_path = self.tree_store.get_path(state_row_iter)
tree_model_row = self.tree_store[selected_path]
m... | State machine prior update of tree selection for one tree model row | entailment |
def update_selection_self_prior_condition(self, state_row_iter, sm_selected_model_set, selected_model_list):
"""Tree view prior update of one model in the state machine selection"""
selected_path = self.tree_store.get_path(state_row_iter)
tree_model_row = self.tree_store[selected_path]
m... | Tree view prior update of one model in the state machine selection | entailment |
def update_selection_self_prior(self):
"""Tree view prior update of state machine selection"""
if self._do_selection_update:
return
self._do_selection_update = True
tree_selection, selected_model_list, sm_selection, sm_selected_model_set = self.get_selections()
if isi... | Tree view prior update of state machine selection | entailment |
def update_selection_sm_prior(self):
"""State machine prior update of tree selection"""
if self._do_selection_update:
return
self._do_selection_update = True
tree_selection, selected_model_list, sm_selection, sm_selected_model_list = self.get_selections()
if tree_sele... | State machine prior update of tree selection | entailment |
def select_entry(self, core_element_id, by_cursor=True):
"""Selects the row entry belonging to the given core_element_id by cursor or tree selection"""
path = self.get_path_for_core_element(core_element_id)
if path:
if by_cursor:
self.tree_view.set_cursor(path)
... | Selects the row entry belonging to the given core_element_id by cursor or tree selection | entailment |
def tree_view_keypress_callback(self, widget, event):
"""Tab back and forward tab-key motion in list widget and the scrollbar motion to follow key cursor motions
The method introduce motion and edit functionality by using "tab"- or "shift-tab"-key for a Gtk.TreeView.
It is designed to work wi... | Tab back and forward tab-key motion in list widget and the scrollbar motion to follow key cursor motions
The method introduce motion and edit functionality by using "tab"- or "shift-tab"-key for a Gtk.TreeView.
It is designed to work with a Gtk.TreeView which model is a Gtk.ListStore and only uses te... | entailment |
def contains_geometric_info(var):
""" Check whether the passed variable is a tuple with two floats or integers """
return isinstance(var, tuple) and len(var) == 2 and all(isinstance(val, (int, float)) for val in var) | Check whether the passed variable is a tuple with two floats or integers | entailment |
def generate_default_state_meta_data(parent_state_m, canvas=None, num_child_state=None, gaphas_editor=True):
"""Generate default meta data for a child state according its parent state
The function could work with the handed num_child_state if all child state are not drawn, till now.
The method checks if th... | Generate default meta data for a child state according its parent state
The function could work with the handed num_child_state if all child state are not drawn, till now.
The method checks if the parents meta data is consistent in canvas state view and model if a canvas instance is
handed.
:param r... | entailment |
def add_boundary_clearance(left, right, top, bottom, frame, clearance=0.1):
"""Increase boundary size
The function increase the space between top and bottom and between left and right parameters.
The increase performed on the biggest size/frame so max(size boundary, size frame)
:param float left: lowe... | Increase boundary size
The function increase the space between top and bottom and between left and right parameters.
The increase performed on the biggest size/frame so max(size boundary, size frame)
:param float left: lower x-axis value
:param float right: upper x-axis value
:param float top: low... | entailment |
def get_boundaries_of_elements_in_dict(models_dict, clearance=0.):
""" Get boundaries of all handed models
The function checks all model meta data positions to increase boundary starting with a state or scoped variables.
It is finally iterated over all states, data and logical port models and linkage if su... | Get boundaries of all handed models
The function checks all model meta data positions to increase boundary starting with a state or scoped variables.
It is finally iterated over all states, data and logical port models and linkage if sufficient for respective
graphical editor. At the end a clearance is add... | entailment |
def cal_frame_according_boundaries(left, right, top, bottom, parent_size, gaphas_editor=True, group=True):
""" Generate margin and relative position and size handed boundary parameter and parent size """
# print("parent_size ->", parent_size)
margin = cal_margin(parent_size)
# Add margin and ensure that... | Generate margin and relative position and size handed boundary parameter and parent size | entailment |
def offset_rel_pos_of_all_models_in_dict(models_dict, pos_offset, gaphas_editor=True):
""" Add position offset to all handed models in dict"""
# print("\n", "#"*30, "offset models", pos_offset, "#"*30)
# Update relative position of states within the container in order to maintain their absolute position
... | Add position offset to all handed models in dict | entailment |
def scale_library_ports_meta_data(state_m, gaphas_editor=True):
"""Scale the ports of library model accordingly relative to state_copy meta size.
The function assumes that the meta data of ports of the state_copy of the library was copied to
respective elements in the library and that those was not ad... | Scale the ports of library model accordingly relative to state_copy meta size.
The function assumes that the meta data of ports of the state_copy of the library was copied to
respective elements in the library and that those was not adjusted before. | entailment |
def scale_library_content(library_state_m, gaphas_editor=True):
"""Scales the meta data of the content of a LibraryState
The contents of the `LibraryStateModel` `library_state_m` (i.e., the `state_copy` and all it children/state
elements) to fit the current size of the `LibraryStateModel`.
:p... | Scales the meta data of the content of a LibraryState
The contents of the `LibraryStateModel` `library_state_m` (i.e., the `state_copy` and all it children/state
elements) to fit the current size of the `LibraryStateModel`.
:param LibraryStateModel library_state_m: The library who's content is to... | entailment |
def _resize_port_models_list(port_models, rel_pos_key, factor, gaphas_editor=True):
""" Resize relative positions a list of (data or logical) port models """
for port_m in port_models:
old_rel_pos = port_m.get_meta_data_editor(for_gaphas=gaphas_editor)[rel_pos_key]
port_m.set_meta_data_editor(re... | Resize relative positions a list of (data or logical) port models | entailment |
def _resize_connection_models_list(connection_models, factor, gaphas_editor=True):
""" Resize relative positions of way points of a list of connection/linkage models """
for connection_m in connection_models:
# print("old_waypoints", connection_m.get_meta_data_editor(for_gaphas=gaphas_editor), connectio... | Resize relative positions of way points of a list of connection/linkage models | entailment |
def resize_state_port_meta(state_m, factor, gaphas_editor=True):
""" Resize data and logical ports relative positions """
# print("scale ports", factor, state_m, gaphas_editor)
if not gaphas_editor and isinstance(state_m, ContainerStateModel):
port_models = state_m.input_data_ports[:] + state_m.outp... | Resize data and logical ports relative positions | entailment |
def resize_state_meta(state_m, factor, gaphas_editor=True):
""" Resize state meta data recursive what includes also LibraryStateModels meta data and its internal state_copy
"""
# print("START RESIZE OF STATE", state_m.get_meta_data_editor(for_gaphas=gaphas_editor), state_m)
old_rel_pos = state_m.get_met... | Resize state meta data recursive what includes also LibraryStateModels meta data and its internal state_copy | entailment |
def offset_rel_pos_of_models_meta_data_according_parent_state(models_dict):
""" Offset meta data of state elements according the area used indicated by the state meta data.
The offset_rel_pos_of_models_meta_data_according_parent_state offset the position of all handed old elements
in the dictionary.
:... | Offset meta data of state elements according the area used indicated by the state meta data.
The offset_rel_pos_of_models_meta_data_according_parent_state offset the position of all handed old elements
in the dictionary.
:param models_dict: dict that hold lists of meta data with state attribute consistent... | entailment |
def scale_meta_data_according_states(models_dict):
""" Offset meta data of state elements according the area used indicated by the states and
maybe scoped variables (in case of OpenGL editor) meta data.
Method is used by group states to set the offset for the elements in the new container state.
The me... | Offset meta data of state elements according the area used indicated by the states and
maybe scoped variables (in case of OpenGL editor) meta data.
Method is used by group states to set the offset for the elements in the new container state.
The method needs some generalisation to create methods to easily ... | entailment |
def scale_meta_data_according_state(models_dict, rel_pos=None, as_template=False, fill_up=False):
# TODO Documentation needed....
""" Scale elements in dict to fit into dict state key element.
If elements are already small enough no resize is performed.
"""
# TODO check about positions of input-dat... | Scale elements in dict to fit into dict state key element.
If elements are already small enough no resize is performed. | entailment |
def get_closest_sibling_state(state_m, from_logical_port=None):
""" Calculate the closest sibling also from optional logical port of handed state model
:param StateModel state_m: Reference State model the closest sibling state should be find for
:param str from_logical_port: The logical port of handed stat... | Calculate the closest sibling also from optional logical port of handed state model
:param StateModel state_m: Reference State model the closest sibling state should be find for
:param str from_logical_port: The logical port of handed state model to be used as reference.
:rtype: tuple
:return: distance... | entailment |
def get_action_arguments(self, target_state_m):
""" Collect argument attributes for action signal
Use non empty list dict to create arguments for action signal msg and logger messages. The action parent model
can be different then the target state model because logical and data port changes als... | Collect argument attributes for action signal
Use non empty list dict to create arguments for action signal msg and logger messages. The action parent model
can be different then the target state model because logical and data port changes also may influence the
linkage, see action-module (undo... | entailment |
def copy(self, selection, smart_selection_adaption=True):
""" Copy all selected items to the clipboard using smart selection adaptation by default
:param selection: the current selection
:param bool smart_selection_adaption: flag to enable smart selection adaptation mode
:return... | Copy all selected items to the clipboard using smart selection adaptation by default
:param selection: the current selection
:param bool smart_selection_adaption: flag to enable smart selection adaptation mode
:return: | entailment |
def cut(self, selection, smart_selection_adaption=False):
"""Cuts all selected items and copy them to the clipboard using smart selection adaptation by default
:param selection: the current selection
:param bool smart_selection_adaption: flag to enable smart selection adaptation mode
:r... | Cuts all selected items and copy them to the clipboard using smart selection adaptation by default
:param selection: the current selection
:param bool smart_selection_adaption: flag to enable smart selection adaptation mode
:return: | entailment |
def paste(self, target_state_m, cursor_position=None, limited=None, convert=False):
"""Paste objects to target state
The method checks whether the target state is a execution state or a container state and inserts respective
elements and notifies the user if the parts can not be insert to the t... | Paste objects to target state
The method checks whether the target state is a execution state or a container state and inserts respective
elements and notifies the user if the parts can not be insert to the target state.
- for ExecutionStates outcomes, input- and output-data ports can be insert... | entailment |
def reset_clipboard(self):
""" Resets the clipboard, so that old elements do not pollute the new selection that is copied into the
clipboard.
:return:
"""
# reset selections
for state_element_attr in ContainerState.state_element_attrs:
self.model_copies[s... | Resets the clipboard, so that old elements do not pollute the new selection that is copied into the
clipboard.
:return: | entailment |
def do_selection_reduction_to_one_parent(selection):
""" Find and reduce selection to one parent state.
:param selection:
:return: state model which is parent of selection or None if root state
"""
all_models_selected = selection.get_all()
# check if all elements select... | Find and reduce selection to one parent state.
:param selection:
:return: state model which is parent of selection or None if root state | entailment |
def do_smart_selection_adaption(selection, parent_m):
""" Reduce and extend transition and data flow element selection if already enclosed by selection
The smart selection adaptation checks and ignores directly data flows and transitions which are selected
without selected related origin or t... | Reduce and extend transition and data flow element selection if already enclosed by selection
The smart selection adaptation checks and ignores directly data flows and transitions which are selected
without selected related origin or targets elements. Additional the linkage (data flows and transition... | entailment |
def __create_core_and_model_object_copies(self, selection, smart_selection_adaption):
"""Copy all elements of a selection.
The method copies all objects and modifies the selection before copying the elements if the smart flag is true.
The smart selection adaption is by default enabled. In any... | Copy all elements of a selection.
The method copies all objects and modifies the selection before copying the elements if the smart flag is true.
The smart selection adaption is by default enabled. In any case the selection is reduced to have one parent
state that is used as the root of copy... | entailment |
def destroy_all_models_in_dict(target_dict):
""" Method runs the prepare destruction method of models
which are assumed in list or tuple as values within a dict
"""
if target_dict:
for model_list in target_dict.values():
if isinstance(model_list, (list, t... | Method runs the prepare destruction method of models
which are assumed in list or tuple as values within a dict | entailment |
def destroy(self):
""" Destroys the clipboard by relieving all model references.
"""
self.destroy_all_models_in_dict(self.model_copies)
self.model_copies = None
self.copy_parent_state_id = None
self.outcome_id_mapping_dict = None
self.port_id_mapping_dict = None
... | Destroys the clipboard by relieving all model references. | entailment |
def extend_extents(extents, factor=1.1):
"""Extend a given bounding box
The bounding box (x1, y1, x2, y2) is centrally stretched by the given factor.
:param extents: The bound box extents
:param factor: The factor for stretching
:return: (x1, y1, x2, y2) of the extended bounding box
"""
wi... | Extend a given bounding box
The bounding box (x1, y1, x2, y2) is centrally stretched by the given factor.
:param extents: The bound box extents
:param factor: The factor for stretching
:return: (x1, y1, x2, y2) of the extended bounding box | entailment |
def calc_rel_pos_to_parent(canvas, item, handle):
"""This method calculates the relative position of the given item's handle to its parent
:param canvas: Canvas to find relative position in
:param item: Item to find relative position to parent
:param handle: Handle of item to find relative position to
... | This method calculates the relative position of the given item's handle to its parent
:param canvas: Canvas to find relative position in
:param item: Item to find relative position to parent
:param handle: Handle of item to find relative position to
:return: Relative position (x, y) | entailment |
def assert_exactly_one_true(bool_list):
"""This method asserts that only one value of the provided list is True.
:param bool_list: List of booleans to check
:return: True if only one value is True, False otherwise
"""
assert isinstance(bool_list, list)
counter = 0
for item in bool_list:
... | This method asserts that only one value of the provided list is True.
:param bool_list: List of booleans to check
:return: True if only one value is True, False otherwise | entailment |
def get_state_id_for_port(port):
"""This method returns the state ID of the state containing the given port
:param port: Port to check for containing state ID
:return: State ID of state containing port
"""
parent = port.parent
from rafcon.gui.mygaphas.items.state import StateView
if isinsta... | This method returns the state ID of the state containing the given port
:param port: Port to check for containing state ID
:return: State ID of state containing port | entailment |
def get_port_for_handle(handle, state):
"""Looks for and returns the PortView to the given handle in the provided state
:param handle: Handle to look for port
:param state: State containing handle and port
:returns: PortView for handle
"""
from rafcon.gui.mygaphas.items.state import StateView
... | Looks for and returns the PortView to the given handle in the provided state
:param handle: Handle to look for port
:param state: State containing handle and port
:returns: PortView for handle | entailment |
def create_new_connection(from_port, to_port):
"""Checks the type of connection and tries to create it
If bot port are logical port,s a transition is created. If both ports are data ports (including scoped variable),
then a data flow is added. An error log is created, when the types are not compatible.
... | Checks the type of connection and tries to create it
If bot port are logical port,s a transition is created. If both ports are data ports (including scoped variable),
then a data flow is added. An error log is created, when the types are not compatible.
:param from_port: The starting port of the connectio... | entailment |
def add_data_flow_to_state(from_port, to_port):
"""Interface method between Gaphas and RAFCON core for adding data flows
The method checks the types of the given ports and their relation. From this the necessary parameters for the
add_dat_flow method of the RAFCON core are determined. Also the parent state... | Interface method between Gaphas and RAFCON core for adding data flows
The method checks the types of the given ports and their relation. From this the necessary parameters for the
add_dat_flow method of the RAFCON core are determined. Also the parent state is derived from the ports.
:param from_port: Port... | entailment |
def add_transition_to_state(from_port, to_port):
"""Interface method between Gaphas and RAFCON core for adding transitions
The method checks the types of the given ports (IncomeView or OutcomeView) and from this determines the necessary
parameters for the add_transition method of the RAFCON core. Also the ... | Interface method between Gaphas and RAFCON core for adding transitions
The method checks the types of the given ports (IncomeView or OutcomeView) and from this determines the necessary
parameters for the add_transition method of the RAFCON core. Also the parent state is derived from the ports.
:param from... | entailment |
def get_relative_positions_of_waypoints(transition_v):
"""This method takes the waypoints of a connection and returns all relative positions of these waypoints.
:param canvas: Canvas to check relative position in
:param transition_v: Transition view to extract all relative waypoint positions
:return: L... | This method takes the waypoints of a connection and returns all relative positions of these waypoints.
:param canvas: Canvas to check relative position in
:param transition_v: Transition view to extract all relative waypoint positions
:return: List with all relative positions of the given transition | entailment |
def update_meta_data_for_transition_waypoints(graphical_editor_view, transition_v, last_waypoint_list, publish=True):
"""This method updates the relative position meta data of the transitions waypoints if they changed
:param graphical_editor_view: Graphical Editor the change occurred in
:param transition_v... | This method updates the relative position meta data of the transitions waypoints if they changed
:param graphical_editor_view: Graphical Editor the change occurred in
:param transition_v: Transition that changed
:param last_waypoint_list: List of waypoints before change
:param bool publish: Whether to ... | entailment |
def update_meta_data_for_port(graphical_editor_view, item, handle):
"""This method updates the meta data of the states ports if they changed.
:param graphical_editor_view: Graphical Editor the change occurred in
:param item: State the port was moved in
:param handle: Handle of moved port or None if all... | This method updates the meta data of the states ports if they changed.
:param graphical_editor_view: Graphical Editor the change occurred in
:param item: State the port was moved in
:param handle: Handle of moved port or None if all ports are to be updated | entailment |
def update_meta_data_for_name_view(graphical_editor_view, name_v, publish=True):
"""This method updates the meta data of a name view.
:param graphical_editor_view: Graphical Editor view the change occurred in
:param name_v: The name view which has been changed/moved
:param publish: Whether to publish t... | This method updates the meta data of a name view.
:param graphical_editor_view: Graphical Editor view the change occurred in
:param name_v: The name view which has been changed/moved
:param publish: Whether to publish the changes of the meta data | entailment |
def update_meta_data_for_state_view(graphical_editor_view, state_v, affects_children=False, publish=True):
"""This method updates the meta data of a state view
:param graphical_editor_view: Graphical Editor view the change occurred in
:param state_v: The state view which has been changed/moved
:param a... | This method updates the meta data of a state view
:param graphical_editor_view: Graphical Editor view the change occurred in
:param state_v: The state view which has been changed/moved
:param affects_children: Whether the children of the state view have been resized or not
:param publish: Whether to pu... | entailment |
def remove(self):
"""Remove recursively all children and then the StateView itself
"""
self.canvas.get_first_view().unselect_item(self)
for child in self.canvas.get_children(self)[:]:
child.remove()
self.remove_income()
for outcome_v in self.outcomes[:]:
... | Remove recursively all children and then the StateView itself | entailment |
def set_enable_flag_keep_rect_within_constraints(self, enable):
""" Enable/disables the KeepRectangleWithinConstraint for child states """
for child_state_v in self.child_state_views():
self.keep_rect_constraints[child_state_v].enable = enable
child_state_v.keep_rect_constraints[... | Enable/disables the KeepRectangleWithinConstraint for child states | entailment |
def show_content(self, with_content=False):
"""Checks if the state is a library with the `show_content` flag set
:param with_content: If this parameter is `True`, the method return only True if the library represents a
ContainerState
:return: Whether the content of a library state is ... | Checks if the state is a library with the `show_content` flag set
:param with_content: If this parameter is `True`, the method return only True if the library represents a
ContainerState
:return: Whether the content of a library state is shown | entailment |
def _calculate_port_pos_on_line(self, port_num, side_length, port_width=None):
"""Calculate the position of a port on a line
The position depends on the number of element. Elements are equally spaced. If the end of the line is
reached, ports are stacked.
:param int port_num: The number ... | Calculate the position of a port on a line
The position depends on the number of element. Elements are equally spaced. If the end of the line is
reached, ports are stacked.
:param int port_num: The number of the port of that type
:param float side_length: The length of the side the elem... | entailment |
def write_dict_to_yaml(dictionary, path, **kwargs):
"""
Writes a dictionary to a yaml file
:param dictionary: the dictionary to be written
:param path: the absolute path of the target yaml file
:param kwargs: optional additional parameters for dumper
"""
with open(path, 'w') as f:
y... | Writes a dictionary to a yaml file
:param dictionary: the dictionary to be written
:param path: the absolute path of the target yaml file
:param kwargs: optional additional parameters for dumper | entailment |
def load_dict_from_yaml(path):
"""
Loads a dictionary from a yaml file
:param path: the absolute path of the target yaml file
:return:
"""
f = file(path, 'r')
dictionary = yaml.load(f)
f.close()
return dictionary | Loads a dictionary from a yaml file
:param path: the absolute path of the target yaml file
:return: | entailment |
def write_dict_to_json(dictionary, path, **kwargs):
"""
Write a dictionary to a json file.
:param path: The relative path to save the dictionary to
:param dictionary: The dictionary to get saved
:param kwargs: optional additional parameters for dumper
"""
result_string = json.dumps(dictionar... | Write a dictionary to a json file.
:param path: The relative path to save the dictionary to
:param dictionary: The dictionary to get saved
:param kwargs: optional additional parameters for dumper | entailment |
def load_objects_from_json(path, as_dict=False):
"""Loads a dictionary from a json file.
:param path: The relative path of the json file.
:return: The dictionary specified in the json file
"""
f = open(path, 'r')
if as_dict:
result = json.load(f)
else:
result = json.load(f, ... | Loads a dictionary from a json file.
:param path: The relative path of the json file.
:return: The dictionary specified in the json file | entailment |
def solve_for(self, var=None):
"""Ensure that the children is within its parent
"""
if not self.enable:
return
margin = self.margin_method()
def parent_width():
return self.parent_se[0].value - self.parent_nw[0].value
def parent_height():
... | Ensure that the children is within its parent | entailment |
def solve_for(self, var=None):
"""
Ensure that the children is within its parent
"""
margin = self.margin_method()
if self.parent_nw[0].value > self.child[0].value - margin:
_update(self.child[0], self.parent_nw[0].value + margin)
# Right edge (east)
i... | Ensure that the children is within its parent | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.