sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def set_centralized_assembled_values(self, a):
"""Set assembled matrix values on processor 0."""
if self.myid != 0:
return
assert a.size == self.id.nz
self._refs.update(a=a)
self.id.a = self.cast_array(a) | Set assembled matrix values on processor 0. | entailment |
def set_distributed_assembled(self, irn_loc, jcn_loc, a_loc):
"""Set the distributed assembled matrix.
Distributed assembled matrices require setting icntl(18) != 0.
"""
self.set_distributed_assembled_rows_cols(irn_loc, jcn_loc)
self.set_distributed_assembled_values(a_loc) | Set the distributed assembled matrix.
Distributed assembled matrices require setting icntl(18) != 0. | entailment |
def set_distributed_assembled_rows_cols(self, irn_loc, jcn_loc):
"""Set the distributed assembled matrix row & column numbers.
Distributed assembled matrices require setting icntl(18) != 0.
"""
assert irn_loc.size == jcn_loc.size
self._refs.update(irn_loc=irn_loc, jcn_loc=jcn_l... | Set the distributed assembled matrix row & column numbers.
Distributed assembled matrices require setting icntl(18) != 0. | entailment |
def set_distributed_assembled_values(self, a_loc):
"""Set the distributed assembled matrix values.
Distributed assembled matrices require setting icntl(18) != 0.
"""
assert a_loc.size == self._refs['irn_loc'].size
self._refs.update(a_loc=a_loc)
self.id.a_loc = self.cast_... | Set the distributed assembled matrix values.
Distributed assembled matrices require setting icntl(18) != 0. | entailment |
def set_rhs(self, rhs):
"""Set the right hand side. This matrix will be modified in place."""
assert rhs.size == self.id.n
self._refs.update(rhs=rhs)
self.id.rhs = self.cast_array(rhs) | Set the right hand side. This matrix will be modified in place. | entailment |
def set_silent(self):
"""Silence most messages."""
self.set_icntl(1, -1) # output stream for error msgs
self.set_icntl(2, -1) # otuput stream for diagnostic msgs
self.set_icntl(3, -1) # output stream for global info
self.set_icntl(4, 0) | Silence most messages. | entailment |
def destroy(self):
"""Delete the MUMPS context and release all array references."""
if self.id is not None and self._mumps_c is not None:
self.id.job = -2 # JOB_END
self._mumps_c(self.id)
self.id = None
self._refs = None | Delete the MUMPS context and release all array references. | entailment |
def mumps(self):
"""Call MUMPS, checking for errors in the return code.
The desired job should have already been set using `ctx.set_job(...)`.
As a convenience, you may wish to call `ctx.run(job=...)` which sets
the job and calls MUMPS.
"""
self._mumps_c(self.id)
... | Call MUMPS, checking for errors in the return code.
The desired job should have already been set using `ctx.set_job(...)`.
As a convenience, you may wish to call `ctx.run(job=...)` which sets
the job and calls MUMPS. | entailment |
def modify_origin(self, from_state, from_key):
"""Set both from_state and from_key at the same time to modify data flow origin
:param str from_state: State id of the origin state
:param int from_key: Data port id of the origin port
:raises exceptions.ValueError: If parameters have wrong... | Set both from_state and from_key at the same time to modify data flow origin
:param str from_state: State id of the origin state
:param int from_key: Data port id of the origin port
:raises exceptions.ValueError: If parameters have wrong types or the new data flow is not valid | entailment |
def modify_target(self, to_state, to_key):
"""Set both to_state and to_key at the same time to modify data flow target
:param str to_state: State id of the target state
:param int to_key: Data port id of the target port
:raises exceptions.ValueError: If parameters have wrong types or th... | Set both to_state and to_key at the same time to modify data flow target
:param str to_state: State id of the target state
:param int to_key: Data port id of the target port
:raises exceptions.ValueError: If parameters have wrong types or the new data flow is not valid | entailment |
def register_actions(self, shortcut_manager):
"""Register callback methods for triggered actions
:param rafcon.gui.shortcut_manager.ShortcutManager shortcut_manager: Shortcut Manager Object holding mappings
between shortcuts and actions.
"""
shortcut_manager.add_callback_for... | Register callback methods for triggered actions
:param rafcon.gui.shortcut_manager.ShortcutManager shortcut_manager: Shortcut Manager Object holding mappings
between shortcuts and actions. | entailment |
def code_changed(self, source):
""" Apply checks and adjustments of the TextBuffer and TextView after every change in buffer.
The method re-apply the tag (style) for the buffer. It avoids changes while editable-property set to False
which are caused by a bug in the GtkSourceView2. GtkSourceVi... | Apply checks and adjustments of the TextBuffer and TextView after every change in buffer.
The method re-apply the tag (style) for the buffer. It avoids changes while editable-property set to False
which are caused by a bug in the GtkSourceView2. GtkSourceView2 is the default used TextView widget here... | entailment |
def apply_clicked(self, button):
"""Triggered when the Apply-Shortcut in the editor is triggered.
"""
if isinstance(self.model.state, LibraryState):
return
self.set_script_text(self.view.get_text()) | Triggered when the Apply-Shortcut in the editor is triggered. | entailment |
def set_text(self, text):
""" The method insert text into the text buffer of the text view and preserves the cursor location.
:param str text: which is insert into the text buffer.
:return:
"""
line_number, line_offset = self.get_cursor_position()
self.get_buffer().set_t... | The method insert text into the text buffer of the text view and preserves the cursor location.
:param str text: which is insert into the text buffer.
:return: | entailment |
def set_enabled(self, on, text=None):
""" Set the default input or deactivated (disabled) style scheme
The method triggers the signal 'changed' by using set_text. Therefore, the method use the while_in_set_enabled
flag to make activities of the method observable. If a method trigger this method... | Set the default input or deactivated (disabled) style scheme
The method triggers the signal 'changed' by using set_text. Therefore, the method use the while_in_set_enabled
flag to make activities of the method observable. If a method trigger this method and was triggered by a
changed-signal thi... | entailment |
def pre_init():
"""
The pre_init function of the plugin. Here rafcon-classes can be extended/monkey-patched or completely substituted.
A example is given with the rafcon_execution_hooks_plugin.
:return:
"""
logger.info("Run pre-initiation hook of {} plugin.".format(__file__.split(os.path.sep)[-... | The pre_init function of the plugin. Here rafcon-classes can be extended/monkey-patched or completely substituted.
A example is given with the rafcon_execution_hooks_plugin.
:return: | entailment |
def post_init(setup_config):
"""
The post_init function of the plugin. Here observer can be registered to the observables and other pre-init
functionality of the plugin should be triggered. A simple example is given with the rafcon_execution_hooks_plugin.
A complex example is given with the rafcon_monit... | The post_init function of the plugin. Here observer can be registered to the observables and other pre-init
functionality of the plugin should be triggered. A simple example is given with the rafcon_execution_hooks_plugin.
A complex example is given with the rafcon_monitoring_plugin.
:param setup_config:
... | entailment |
def reduce_to_parent_states(models):
"""Remove all models of states that have a state model with parent relation in the list
The function filters the list of models, so that for no model in the list, one of it (grand-)parents is also in
the list. E.g. if the input models consists of a hierarchy state with ... | Remove all models of states that have a state model with parent relation in the list
The function filters the list of models, so that for no model in the list, one of it (grand-)parents is also in
the list. E.g. if the input models consists of a hierarchy state with two of its child states, the resulting list
... | entailment |
def updates_selection(update_selection):
""" Decorator indicating that the decorated method could change the selection"""
def handle_update(selection, *args, **kwargs):
"""Check for changes in the selection
If the selection is changed by the decorated method, the internal core element lists are... | Decorator indicating that the decorated method could change the selection | entailment |
def extend_selection():
"""Checks is the selection is to be extended
The selection is to be extended, if a special modifier key (typically <Ctrl>) is being pressed.
:return: If to extend the selection
:rtype: True
"""
from rafcon.gui.singleton import main_window_controller
currently_presse... | Checks is the selection is to be extended
The selection is to be extended, if a special modifier key (typically <Ctrl>) is being pressed.
:return: If to extend the selection
:rtype: True | entailment |
def _check_model_types(self, models):
""" Check types of passed models for correctness and in case raise exception
:rtype: set
:returns: set of models that are valid for the class"""
if not hasattr(models, "__iter__"):
models = {models}
if not all([isinstance(model, ... | Check types of passed models for correctness and in case raise exception
:rtype: set
:returns: set of models that are valid for the class | entailment |
def add(self, models):
""" Adds the passed model(s) to the selection"""
if models is None:
return
models = self._check_model_types(models)
self._selected.update(models)
self._selected = reduce_to_parent_states(self._selected) | Adds the passed model(s) to the selection | entailment |
def remove(self, models):
""" Removed the passed model(s) from the selection"""
models = self._check_model_types(models)
for model in models:
if model in self._selected:
self._selected.remove(model) | Removed the passed model(s) from the selection | entailment |
def set(self, models):
""" Sets the selection to the passed model(s) """
# Do not add None values to selection
if models is None:
models = set()
models = self._check_model_types(models)
if len(models) > 1:
models = reduce_to_parent_states(models)
... | Sets the selection to the passed model(s) | entailment |
def handle_prepared_selection_of_core_class_elements(self, core_class, models):
"""Handles the selection for TreeStore widgets maintaining lists of a specific `core_class` elements
If widgets hold a TreeStore with elements of a specific `core_class`, the local selection of that element
type is ... | Handles the selection for TreeStore widgets maintaining lists of a specific `core_class` elements
If widgets hold a TreeStore with elements of a specific `core_class`, the local selection of that element
type is handled by that widget. This method is called to integrate the local selection with the ove... | entailment |
def handle_new_selection(self, models):
"""Handles the selection for generic widgets
This is a helper method for generic widgets that want to modify the selection. These widgets can pass a list
of newly selected (or clicked on) models.
The method looks at the previous selection, the pa... | Handles the selection for generic widgets
This is a helper method for generic widgets that want to modify the selection. These widgets can pass a list
of newly selected (or clicked on) models.
The method looks at the previous selection, the passed models and the list of pressed (modifier) keys... | entailment |
def focus(self, model):
"""Sets the passed model as focused element
:param ModelMT model: The element to be focused
"""
if model is None:
del self.focus
return
self._check_model_types(model)
self.add(model)
focus_msg = FocusSignalMsg(mode... | Sets the passed model as focused element
:param ModelMT model: The element to be focused | entailment |
def focus(self):
""" Unsets the focused element """
focus_msg = FocusSignalMsg(None, self._focus)
self._focus = None
self.focus_signal.emit(focus_msg) | Unsets the focused element | entailment |
def update_core_element_lists(self):
""" Maintains inner lists of selected elements with a specific core element class """
def get_selected_elements_of_core_class(core_class):
return set(element for element in self._selected if isinstance(element.core_element, core_class))
self._stat... | Maintains inner lists of selected elements with a specific core element class | entailment |
def get_selected_elements_of_core_class(self, core_element_type):
"""Returns all selected elements having the specified `core_element_type` as state element class
:return: Subset of the selection, only containing elements having `core_element_type` as state element class
:rtype: set
"""... | Returns all selected elements having the specified `core_element_type` as state element class
:return: Subset of the selection, only containing elements having `core_element_type` as state element class
:rtype: set | entailment |
def is_selected(self, model):
"""Checks whether the given model is selected
:param model:
:return: True if the model is within the selection, False else
:rtype: bool
"""
if model is None:
return len(self._selected) == 0
return model in self._selected | Checks whether the given model is selected
:param model:
:return: True if the model is within the selection, False else
:rtype: bool | entailment |
def execute_command_with_path_in_process(command, path, shell=False, cwd=None, logger=None):
"""Executes a specific command in a separate process with a path as argument.
:param command: the command to be executed
:param path: the path as first argument to the shell command
:param bool shell: Whether t... | Executes a specific command in a separate process with a path as argument.
:param command: the command to be executed
:param path: the path as first argument to the shell command
:param bool shell: Whether to use a shell
:param str cwd: The working directory of the command
:param logger: optional l... | entailment |
def execute_command_in_process(command, shell=False, cwd=None, logger=None):
""" Executes a specific command in a separate process
:param command: the command to be executed
:param bool shell: Whether to use a shell
:param str cwd: The working directory of the command
:param logger: optional logger... | Executes a specific command in a separate process
:param command: the command to be executed
:param bool shell: Whether to use a shell
:param str cwd: The working directory of the command
:param logger: optional logger instance which can be handed from other module
:return: None | entailment |
def _load_child_state_models(self, load_meta_data):
"""Adds models for each child state of the state
:param bool load_meta_data: Whether to load the meta data of the child state
"""
self.states = {}
# Create model for each child class
child_states = self.state.states
... | Adds models for each child state of the state
:param bool load_meta_data: Whether to load the meta data of the child state | entailment |
def _load_scoped_variable_models(self):
""" Adds models for each scoped variable of the state """
self.scoped_variables = []
for scoped_variable in self.state.scoped_variables.values():
self._add_model(self.scoped_variables, scoped_variable, ScopedVariableModel) | Adds models for each scoped variable of the state | entailment |
def _load_data_flow_models(self):
""" Adds models for each data flow of the state """
self.data_flows = []
for data_flow in self.state.data_flows.values():
self._add_model(self.data_flows, data_flow, DataFlowModel) | Adds models for each data flow of the state | entailment |
def _load_transition_models(self):
""" Adds models for each transition of the state """
self.transitions = []
for transition in self.state.transitions.values():
self._add_model(self.transitions, transition, TransitionModel) | Adds models for each transition of the state | entailment |
def prepare_destruction(self, recursive=True):
"""Prepares the model for destruction
Recursively un-registers all observers and removes references to child models. Extends the destroy method of
the base class by child elements of a container state.
"""
# logger.verbose("Prepare ... | Prepares the model for destruction
Recursively un-registers all observers and removes references to child models. Extends the destroy method of
the base class by child elements of a container state. | entailment |
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 (states, transitions, data flows) changes. Changes... | 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 (states, transitions, data flows) changes. Changes of the children cannot be observed directly,
theref... | entailment |
def update_child_models(self, _, name, info):
""" This method is always triggered when the state model changes
It keeps the following models/model-lists consistent:
transition models
data-flow models
state models
scoped variable models
"""
... | This method is always triggered when the state model changes
It keeps the following models/model-lists consistent:
transition models
data-flow models
state models
scoped variable models | entailment |
def get_scoped_variable_m(self, data_port_id):
"""Returns the scoped variable model for the given data port id
:param data_port_id: The data port id to search for
:return: The model of the scoped variable with the given id
"""
for scoped_variable_m in self.scoped_variables:
... | Returns the scoped variable model for the given data port id
:param data_port_id: The data port id to search for
:return: The model of the scoped variable with the given id | entailment |
def get_data_port_m(self, data_port_id):
"""Searches and returns the model of a data port of a given state
The method searches a port with the given id in the data ports of the given state model. If the state model
is a container state, not only the input and output data ports are looked at, bu... | Searches and returns the model of a data port of a given state
The method searches a port with the given id in the data ports of the given state model. If the state model
is a container state, not only the input and output data ports are looked at, but also the scoped variables.
:param data_po... | entailment |
def get_transition_m(self, transition_id):
"""Searches and return the transition model with the given in the given container state model
:param transition_id: The transition id to be searched
:return: The model of the transition or None if it is not found
"""
for transition_m in... | Searches and return the transition model with the given in the given container state model
:param transition_id: The transition id to be searched
:return: The model of the transition or None if it is not found | entailment |
def get_data_flow_m(self, data_flow_id):
"""Searches and return the data flow model with the given in the given container state model
:param data_flow_id: The data flow id to be searched
:return: The model of the data flow or None if it is not found
"""
for data_flow_m in self.d... | Searches and return the data flow model with the given in the given container state model
:param data_flow_id: The data flow id to be searched
:return: The model of the data flow or None if it is not found | entailment |
def store_meta_data(self, copy_path=None):
"""Store meta data of container states to the filesystem
Recursively stores meta data of child states. For further insides read the description of also called respective
super class method.
:param str copy_path: Optional copy path if meta data... | Store meta data of container states to the filesystem
Recursively stores meta data of child states. For further insides read the description of also called respective
super class method.
:param str copy_path: Optional copy path if meta data is not stored to the file system path of state machin... | entailment |
def copy_meta_data_from_state_m(self, source_state_m):
"""Dismiss current meta data and copy meta data from given state model
In addition to the state model method, also the meta data of container states is copied. Then, the meta data
of child states are recursively copied.
:param sour... | Dismiss current meta data and copy meta data from given state model
In addition to the state model method, also the meta data of container states is copied. Then, the meta data
of child states are recursively copied.
:param source_state_m: State model to load the meta data from | entailment |
def _generate_element_meta_data(self, meta_data):
"""Generate meta data for state elements and add it to the given dictionary
This method retrieves the meta data of the container state elements (data flows, transitions) and adds it
to the given meta data dictionary.
:param meta_data: D... | Generate meta data for state elements and add it to the given dictionary
This method retrieves the meta data of the container state elements (data flows, transitions) and adds it
to the given meta data dictionary.
:param meta_data: Dictionary of meta data | entailment |
def open_folder(query, default_path=None):
"""Shows a user dialog for folder selection
A dialog is opened with the prompt `query`. The current path is set to the last path that was opened/created. The
roots of all libraries is added to the list of shortcut folders.
:param str query: Prompt as... | Shows a user dialog for folder selection
A dialog is opened with the prompt `query`. The current path is set to the last path that was opened/created. The
roots of all libraries is added to the list of shortcut folders.
:param str query: Prompt asking the user for a specific folder
:param str... | entailment |
def create_folder(query, default_name=None, default_path=None):
"""Shows a user dialog for folder creation
A dialog is opened with the prompt `query`. The current path is set to the last path that was opened/created. The
roots of all libraries is added to the list of shortcut folders.
:param ... | Shows a user dialog for folder creation
A dialog is opened with the prompt `query`. The current path is set to the last path that was opened/created. The
roots of all libraries is added to the list of shortcut folders.
:param str query: Prompt asking the user for a specific folder
:param str ... | entailment |
def add_state_machine(widget, event=None):
"""Create a new state-machine when the user clicks on the '+' next to the tabs"""
logger.debug("Creating new state-machine...")
root_state = HierarchyState("new root state")
state_machine = StateMachine(root_state)
rafcon.core.singleton.state_machine_manage... | Create a new state-machine when the user clicks on the '+' next to the tabs | entailment |
def register_view(self, view):
"""Called when the View was registered"""
super(StateMachinesEditorController, self).register_view(view)
self.view['notebook'].connect('switch-page', self.on_switch_page)
# Add all already open state machines
for state_machine in self.model.state_m... | Called when the View was registered | entailment |
def register_actions(self, shortcut_manager):
"""Register callback methods fot triggered actions.
:param rafcon.gui.shortcut_manager.ShortcutManager shortcut_manager: Shortcut Manager Object holding mappings
between shortcuts and actions.
"""
shortcut_manager.add_callback_fo... | Register callback methods fot triggered actions.
:param rafcon.gui.shortcut_manager.ShortcutManager shortcut_manager: Shortcut Manager Object holding mappings
between shortcuts and actions. | entailment |
def close_state_machine(self, widget, page_number, event=None):
"""Triggered when the close button in the tab is clicked
"""
page = widget.get_nth_page(page_number)
for tab_info in self.tabs.values():
if tab_info['page'] is page:
state_machine_m = tab_info['st... | Triggered when the close button in the tab is clicked | entailment |
def on_close_shortcut(self, *args):
"""Close selected state machine (triggered by shortcut)"""
state_machine_m = self.model.get_selected_state_machine_model()
if state_machine_m is None:
return
self.on_close_clicked(None, state_machine_m, None, force=False) | Close selected state machine (triggered by shortcut) | entailment |
def add_graphical_state_machine_editor(self, state_machine_m):
"""Add to for new state machine
If a new state machine was added, a new tab is created with a graphical editor for this state machine.
:param StateMachineModel state_machine_m: The new state machine model
"""
assert... | Add to for new state machine
If a new state machine was added, a new tab is created with a graphical editor for this state machine.
:param StateMachineModel state_machine_m: The new state machine model | entailment |
def notification_selected_sm_changed(self, model, prop_name, info):
"""If a new state machine is selected, make sure the tab is open"""
selected_state_machine_id = self.model.selected_state_machine_id
if selected_state_machine_id is None:
return
page_id = self.get_page_num(s... | If a new state machine is selected, make sure the tab is open | entailment |
def update_state_machine_tab_label(self, state_machine_m):
""" Updates tab label if needed because system path, root state name or marked_dirty flag changed
:param StateMachineModel state_machine_m: State machine model that has changed
:return:
"""
sm_id = state_machine_m.state_... | Updates tab label if needed because system path, root state name or marked_dirty flag changed
:param StateMachineModel state_machine_m: State machine model that has changed
:return: | entailment |
def on_close_clicked(self, event, state_machine_m, result, force=False):
"""Triggered when the close button of a state machine tab is clicked
Closes state machine if it is saved. Otherwise gives the user the option to 'Close without Saving' or to 'Cancel
the Close Operation'
:param sta... | Triggered when the close button of a state machine tab is clicked
Closes state machine if it is saved. Otherwise gives the user the option to 'Close without Saving' or to 'Cancel
the Close Operation'
:param state_machine_m: The selected state machine model. | entailment |
def close_all_pages(self):
"""Closes all tabs of the state machines editor."""
state_machine_m_list = [tab['state_machine_m'] for tab in self.tabs.values()]
for state_machine_m in state_machine_m_list:
self.on_close_clicked(None, state_machine_m, None, force=True) | Closes all tabs of the state machines editor. | entailment |
def refresh_state_machines(self, state_machine_ids):
""" Refresh list af state machine tabs
:param list state_machine_ids: List of state machine ids to be refreshed
:return:
"""
# remember current selected state machine id
currently_selected_sm_id = None
if self.... | Refresh list af state machine tabs
:param list state_machine_ids: List of state machine ids to be refreshed
:return: | entailment |
def refresh_all_state_machines(self):
""" Refreshes all state machine tabs
"""
self.refresh_state_machines(list(self.model.state_machine_manager.state_machines.keys())) | Refreshes all state machine tabs | entailment |
def switch_state_machine_execution_engine(self, new_state_machine_execution_engine):
"""
Switch the state machine execution engine the main window controller listens to.
:param new_state_machine_execution_engine: the new state machine execution engine for this controller
:return:
... | Switch the state machine execution engine the main window controller listens to.
:param new_state_machine_execution_engine: the new state machine execution engine for this controller
:return: | entailment |
def execution_engine_model_changed(self, model, prop_name, info):
"""High light active state machine. """
notebook = self.view['notebook']
active_state_machine_id = self.model.state_machine_manager.active_state_machine_id
if active_state_machine_id is None:
# un-mark all st... | High light active state machine. | entailment |
def get_state_tuple(state, state_m=None):
""" Generates a tuple that holds the state as yaml-strings and its meta data in a dictionary.
The tuple consists of:
[0] json_str for state,
[1] dict of child_state tuples,
[2] dict of model_meta-data of self and elements
[3] path of state in state machi... | Generates a tuple that holds the state as yaml-strings and its meta data in a dictionary.
The tuple consists of:
[0] json_str for state,
[1] dict of child_state tuples,
[2] dict of model_meta-data of self and elements
[3] path of state in state machine
[4] script_text
[5] file system path
... | entailment |
def meta_dump_or_deepcopy(meta):
"""Function to observe meta data vivi-dict copy process and to debug it at one point"""
if DEBUG_META_REFERENCES: # debug copy
from rafcon.gui.helpers.meta_data import meta_data_reference_check
meta_data_reference_check(meta)
return copy.deepcopy(meta) | Function to observe meta data vivi-dict copy process and to debug it at one point | entailment |
def undo(self):
""" General Undo, that takes all elements in the parent and
:return:
"""
# logger.verbose("#H# STATE_MACHINE_UNDO STARTED")
state = self.state_machine.root_state
self.set_root_state_to_version(state, self.before_storage) | General Undo, that takes all elements in the parent and
:return: | entailment |
def get_cached_image(self, width, height, zoom, parameters=None, clear=False):
"""Get ImageSurface object, if possible, cached
The method checks whether the image was already rendered. This is done by comparing the passed size and
parameters with those of the last image. If they are equal, the ... | Get ImageSurface object, if possible, cached
The method checks whether the image was already rendered. This is done by comparing the passed size and
parameters with those of the last image. If they are equal, the cached image is returned. Otherwise,
a new ImageSurface with the specified dimensi... | entailment |
def copy_image_to_context(self, context, position, rotation=0, zoom=None):
"""Draw a cached image on the context
:param context: The Cairo context to draw on
:param position: The position od the image
"""
if not zoom:
zoom = self.__zoom
zoom_multiplicator = z... | Draw a cached image on the context
:param context: The Cairo context to draw on
:param position: The position od the image | entailment |
def get_context_for_image(self, zoom):
"""Creates a temporary cairo context for the image surface
:param zoom: The current scaling factor
:return: Cairo context to draw on
"""
cairo_context = Context(self.__image)
cairo_context.scale(zoom * self.multiplicator, zoom * sel... | Creates a temporary cairo context for the image surface
:param zoom: The current scaling factor
:return: Cairo context to draw on | entailment |
def __compare_parameters(self, width, height, zoom, parameters):
"""Compare parameters for equality
Checks if a cached image is existing, the the dimensions agree and finally if the properties are equal. If
so, True is returned, else False,
:param width: The width of the image
:... | Compare parameters for equality
Checks if a cached image is existing, the the dimensions agree and finally if the properties are equal. If
so, True is returned, else False,
:param width: The width of the image
:param height: The height of the image
:param zoom: The current scale... | entailment |
def post_setup_plugins(parser_result):
"""Calls the post init hubs
:param dict parser_result: Dictionary with the parsed arguments
"""
if not isinstance(parser_result, dict):
parser_result = vars(parser_result)
plugins.run_post_inits(parser_result) | Calls the post init hubs
:param dict parser_result: Dictionary with the parsed arguments | entailment |
def setup_environment():
"""Ensures that the environmental variable RAFCON_LIB_PATH is existent
"""
try:
from gi.repository import GLib
user_data_folder = GLib.get_user_data_dir()
except ImportError:
user_data_folder = join(os.path.expanduser("~"), ".local", "share")
rafcon_r... | Ensures that the environmental variable RAFCON_LIB_PATH is existent | entailment |
def parse_state_machine_path(path):
"""Parser for argparse checking pfor a proper state machine path
:param str path: Input path from the user
:return: The path
:raises argparse.ArgumentTypeError: if the path does not contain a statemachine.json file
"""
sm_root_file = join(path, storage.STATEM... | Parser for argparse checking pfor a proper state machine path
:param str path: Input path from the user
:return: The path
:raises argparse.ArgumentTypeError: if the path does not contain a statemachine.json file | entailment |
def setup_argument_parser():
"""Sets up teh parser with the required arguments
:return: The parser object
"""
default_config_path = filesystem.get_default_config_path()
filesystem.create_path(default_config_path)
parser = core_singletons.argument_parser
parser.add_argument('-o', '--open', ... | Sets up teh parser with the required arguments
:return: The parser object | entailment |
def setup_configuration(config_path):
"""Loads the core configuration from the specified path and uses its content for further setup
:param config_path: Path to the core config file
"""
if config_path is not None:
config_path, config_file = filesystem.separate_folder_path_and_file_name(config_p... | Loads the core configuration from the specified path and uses its content for further setup
:param config_path: Path to the core config file | entailment |
def open_state_machine(state_machine_path):
"""Executes the specified state machine
:param str state_machine_path: The file path to the state machine
:return StateMachine: The loaded state machine
"""
sm = storage.load_state_machine_from_path(state_machine_path)
core_singletons.state_machine_ma... | Executes the specified state machine
:param str state_machine_path: The file path to the state machine
:return StateMachine: The loaded state machine | entailment |
def wait_for_state_machine_finished(state_machine):
""" wait for a state machine to finish its execution
:param state_machine: the statemachine to synchronize with
:return:
"""
global _user_abort
from rafcon.core.states.execution_state import ExecutionState
if not isinstance(state_machine.... | wait for a state machine to finish its execution
:param state_machine: the statemachine to synchronize with
:return: | entailment |
def stop_reactor_on_state_machine_finish(state_machine):
""" Wait for a state machine to be finished and stops the reactor
:param state_machine: the state machine to synchronize with
"""
wait_for_state_machine_finished(state_machine)
from twisted.internet import reactor
if reactor.running:
... | Wait for a state machine to be finished and stops the reactor
:param state_machine: the state machine to synchronize with | entailment |
async def wait_until_ready(
self, timeout: Optional[float] = None, no_raise: bool = False
) -> bool:
"""
Waits for the underlying node to become ready.
If no_raise is set, returns false when a timeout occurs instead of propogating TimeoutError.
A timeout of None means to wai... | Waits for the underlying node to become ready.
If no_raise is set, returns false when a timeout occurs instead of propogating TimeoutError.
A timeout of None means to wait indefinitely. | entailment |
async def connect(self):
"""
Connects to the voice channel associated with this Player.
"""
await self.node.join_voice_channel(self.channel.guild.id, self.channel.id) | Connects to the voice channel associated with this Player. | entailment |
async def move_to(self, channel: discord.VoiceChannel):
"""
Moves this player to a voice channel.
Parameters
----------
channel : discord.VoiceChannel
"""
if channel.guild != self.channel.guild:
raise TypeError("Cannot move to a different guild.")
... | Moves this player to a voice channel.
Parameters
----------
channel : discord.VoiceChannel | entailment |
async def disconnect(self, requested=True):
"""
Disconnects this player from it's voice channel.
"""
if self.state == PlayerState.DISCONNECTING:
return
await self.update_state(PlayerState.DISCONNECTING)
if not requested:
log.debug(
... | Disconnects this player from it's voice channel. | entailment |
async def handle_event(self, event: "node.LavalinkEvents", extra):
"""
Handles various Lavalink Events.
If the event is TRACK END, extra will be TrackEndReason.
If the event is TRACK EXCEPTION, extra will be the string reason.
If the event is TRACK STUCK, extra will be the thr... | Handles various Lavalink Events.
If the event is TRACK END, extra will be TrackEndReason.
If the event is TRACK EXCEPTION, extra will be the string reason.
If the event is TRACK STUCK, extra will be the threshold ms.
Parameters
----------
event : node.LavalinkEvents
... | entailment |
async def handle_player_update(self, state: "node.PlayerState"):
"""
Handles player updates from lavalink.
Parameters
----------
state : websocket.PlayerState
"""
if state.position > self.position:
self._is_playing = True
self.position = state... | Handles player updates from lavalink.
Parameters
----------
state : websocket.PlayerState | entailment |
def add(self, requester: discord.User, track: Track):
"""
Adds a track to the queue.
Parameters
----------
requester : discord.User
User who requested the track.
track : Track
Result from any of the lavalink track search methods.
"""
... | Adds a track to the queue.
Parameters
----------
requester : discord.User
User who requested the track.
track : Track
Result from any of the lavalink track search methods. | entailment |
async def play(self):
"""
Starts playback from lavalink.
"""
if self.repeat and self.current is not None:
self.queue.append(self.current)
self.current = None
self.position = 0
self._paused = False
if not self.queue:
await self.sto... | Starts playback from lavalink. | entailment |
async def stop(self):
"""
Stops playback from lavalink.
.. important::
This method will clear the queue.
"""
await self.node.stop(self.channel.guild.id)
self.queue = []
self.current = None
self.position = 0
self._paused = False | Stops playback from lavalink.
.. important::
This method will clear the queue. | entailment |
async def pause(self, pause: bool = True):
"""
Pauses the current song.
Parameters
----------
pause : bool
Set to ``False`` to resume.
"""
self._paused = pause
await self.node.pause(self.channel.guild.id, pause) | Pauses the current song.
Parameters
----------
pause : bool
Set to ``False`` to resume. | entailment |
async def set_volume(self, volume: int):
"""
Sets the volume of Lavalink.
Parameters
----------
volume : int
Between 0 and 150
"""
self._volume = max(min(volume, 150), 0)
await self.node.volume(self.channel.guild.id, self.volume) | Sets the volume of Lavalink.
Parameters
----------
volume : int
Between 0 and 150 | entailment |
async def seek(self, position: int):
"""
If the track allows it, seeks to a position.
Parameters
----------
position : int
Between 0 and track length.
"""
if self.current.seekable:
position = max(min(position, self.current.length), 0)
... | If the track allows it, seeks to a position.
Parameters
----------
position : int
Between 0 and track length. | entailment |
async def create_player(self, channel: discord.VoiceChannel) -> Player:
"""
Connects to a discord voice channel.
This function is safe to repeatedly call as it will return an existing
player if there is one.
Parameters
----------
channel
Returns
... | Connects to a discord voice channel.
This function is safe to repeatedly call as it will return an existing
player if there is one.
Parameters
----------
channel
Returns
-------
Player
The created Player object. | entailment |
def get_player(self, guild_id: int) -> Player:
"""
Gets a Player object from a guild ID.
Parameters
----------
guild_id : int
Discord guild ID.
Returns
-------
Player
Raises
------
KeyError
If that guild d... | Gets a Player object from a guild ID.
Parameters
----------
guild_id : int
Discord guild ID.
Returns
-------
Player
Raises
------
KeyError
If that guild does not have a Player, e.g. is not connected to any
voi... | entailment |
async def disconnect(self):
"""
Disconnects all players.
"""
for p in tuple(self.players):
await p.disconnect(requested=False)
log.debug("Disconnected players.") | Disconnects all players. | entailment |
def resource_filename(package_or_requirement, resource_name):
"""
Similar to pkg_resources.resource_filename but if the resource it not found via pkg_resources
it also looks in a predefined list of paths in order to find the resource
:param package_or_requirement: the module in which the resource resid... | Similar to pkg_resources.resource_filename but if the resource it not found via pkg_resources
it also looks in a predefined list of paths in order to find the resource
:param package_or_requirement: the module in which the resource resides
:param resource_name: the name of the resource
:return: the pat... | entailment |
def resource_exists(package_or_requirement, resource_name):
"""
Similar to pkg_resources.resource_exists but if the resource it not found via pkg_resources
it also looks in a predefined list of paths in order to find the resource
:param package_or_requirement: the module in which the resource resides
... | Similar to pkg_resources.resource_exists but if the resource it not found via pkg_resources
it also looks in a predefined list of paths in order to find the resource
:param package_or_requirement: the module in which the resource resides
:param resource_name: the name of the resource
:return: a flag if... | entailment |
def resource_string(package_or_requirement, resource_name):
"""
Similar to pkg_resources.resource_string but if the resource it not found via pkg_resources
it also looks in a predefined list of paths in order to find the resource
:param package_or_requirement: the module in which the resource resides
... | Similar to pkg_resources.resource_string but if the resource it not found via pkg_resources
it also looks in a predefined list of paths in order to find the resource
:param package_or_requirement: the module in which the resource resides
:param resource_name: the name of the resource
:return: the file ... | entailment |
def resource_listdir(package_or_requirement, relative_path):
"""
Similar to pkg_resources.resource_listdir but if the resource it not found via pkg_resources
it also looks in a predefined list of paths in order to find the resource
:param package_or_requirement: the module in which the resource resides... | Similar to pkg_resources.resource_listdir but if the resource it not found via pkg_resources
it also looks in a predefined list of paths in order to find the resource
:param package_or_requirement: the module in which the resource resides
:param relative_path: the relative path to the resource
:return:... | entailment |
def load_plugins():
"""Loads all plugins specified in the RAFCON_PLUGIN_PATH environment variable
"""
plugins = os.environ.get('RAFCON_PLUGIN_PATH', '')
plugin_list = set(plugins.split(os.pathsep))
global plugin_dict
for plugin_path in plugin_list:
if not plugin_path:
continu... | Loads all plugins specified in the RAFCON_PLUGIN_PATH environment variable | entailment |
def run_hook(hook_name, *args, **kwargs):
"""Runs the passed hook on all registered plugins
The function checks, whether the hook is available in the plugin.
:param hook_name: Name of the hook, corresponds to the function name being called
:param args: Arguments
:param kwargs: Keyword arguments
... | Runs the passed hook on all registered plugins
The function checks, whether the hook is available in the plugin.
:param hook_name: Name of the hook, corresponds to the function name being called
:param args: Arguments
:param kwargs: Keyword arguments | entailment |
def get_state_model_class_for_state(state):
"""Determines the model required for the given state class
:param state: Instance of a state (ExecutionState, BarrierConcurrencyState, ...)
:return: The model class required for holding such a state instance
"""
from rafcon.gui.models.state import StateMo... | Determines the model required for the given state class
:param state: Instance of a state (ExecutionState, BarrierConcurrencyState, ...)
:return: The model class required for holding such a state instance | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.