code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
from rafcon.core.singleton import state_machine_execution_engine, state_machine_manager
force = True if event is not None and hasattr(event, 'state') \
and event.get_state() & Gdk.ModifierType.SHIFT_MASK \
and event.get_state() & Gdk.ModifierType.... | 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 state_machine_m: The selected state machine model. | 3.162879 | 3.189078 | 0.991785 |
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) | def close_all_pages(self) | Closes all tabs of the state machines editor. | 5.27834 | 3.94169 | 1.339106 |
# remember current selected state machine id
currently_selected_sm_id = None
if self.model.get_selected_state_machine_model():
currently_selected_sm_id = self.model.get_selected_state_machine_model().state_machine.state_machine_id
# create a dictionary from state ma... | 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: | 3.665006 | 3.688939 | 0.993512 |
self.refresh_state_machines(list(self.model.state_machine_manager.state_machines.keys())) | def refresh_all_state_machines(self) | Refreshes all state machine tabs | 5.888175 | 5.463801 | 1.07767 |
# relieve old one
self.relieve_model(self.state_machine_execution_model)
# register new
self.state_machine_execution_model = new_state_machine_execution_engine
self.observe_model(self.state_machine_execution_model) | 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: | 3.954865 | 4.096571 | 0.965409 |
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 state machine that are marked with execution-running style class
for tab in self.tabs.values():... | def execution_engine_model_changed(self, model, prop_name, info) | High light active state machine. | 2.909643 | 2.758177 | 1.054915 |
state_str = json.dumps(state, cls=JSONObjectEncoder,
indent=4, check_circular=False, sort_keys=True)
state_tuples_dict = {}
if isinstance(state, ContainerState):
# print(state.states, "\n")
for child_state_id, child_state in state.states.items():
... | 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 machine
[4] script_text
[5] file system path
... | 3.590248 | 2.850234 | 1.259633 |
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) | def meta_dump_or_deepcopy(meta) | Function to observe meta data vivi-dict copy process and to debug it at one point | 10.443487 | 8.482962 | 1.231113 |
# logger.verbose("#H# STATE_MACHINE_UNDO STARTED")
state = self.state_machine.root_state
self.set_root_state_to_version(state, self.before_storage) | def undo(self) | General Undo, that takes all elements in the parent and
:return: | 24.483152 | 24.038605 | 1.018493 |
global MAX_ALLOWED_AREA
if not parameters:
parameters = {}
if self.__compare_parameters(width, height, zoom, parameters) and not clear:
return True, self.__image, self.__zoom
# Restrict image surface size to prevent excessive use of memory
while... | 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 cached image is returned. Otherwise,
a new ImageSurface with the specified dimensi... | 4.473712 | 4.20215 | 1.064625 |
if not zoom:
zoom = self.__zoom
zoom_multiplicator = zoom * self.multiplicator
context.save()
context.scale(1. / zoom_multiplicator, 1. / zoom_multiplicator)
image_position = round(position[0] * zoom_multiplicator), round(position[1] * zoom_multiplicator)
... | 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 | 2.395099 | 2.590511 | 0.924566 |
cairo_context = Context(self.__image)
cairo_context.scale(zoom * self.multiplicator, zoom * self.multiplicator)
return cairo_context | 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 | 4.890357 | 4.253887 | 1.149621 |
# Deactivated caching
if not global_gui_config.get_config_value('ENABLE_CACHING', True):
return False
# Empty cache
if not self.__image:
return False
# Changed image size
if self.__width != width or self.__height != height:
... | 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
:param height: The height of the image
:param zoom: The current scale... | 5.005902 | 4.823674 | 1.037778 |
if not isinstance(parser_result, dict):
parser_result = vars(parser_result)
plugins.run_post_inits(parser_result) | def post_setup_plugins(parser_result) | Calls the post init hubs
:param dict parser_result: Dictionary with the parsed arguments | 4.37417 | 5.253285 | 0.832654 |
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_root_path = dirname(realpath(rafcon.__file__))
user_library_folder = join(user_data_folder, "rafcon"... | def setup_environment() | Ensures that the environmental variable RAFCON_LIB_PATH is existent | 3.89986 | 3.664934 | 1.064101 |
sm_root_file = join(path, storage.STATEMACHINE_FILE)
if exists(sm_root_file):
return path
else:
sm_root_file = join(path, storage.STATEMACHINE_FILE_OLD)
if exists(sm_root_file):
return path
raise argparse.ArgumentTypeError("Failed to open {0}: {1} not found i... | 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 | 3.961509 | 3.941555 | 1.005062 |
default_config_path = filesystem.get_default_config_path()
filesystem.create_path(default_config_path)
parser = core_singletons.argument_parser
parser.add_argument('-o', '--open', type=parse_state_machine_path, dest='state_machine_path', metavar='path',
nargs='+', help="spe... | def setup_argument_parser() | Sets up teh parser with the required arguments
:return: The parser object | 5.127609 | 5.257357 | 0.975321 |
if config_path is not None:
config_path, config_file = filesystem.separate_folder_path_and_file_name(config_path)
global_config.load(config_file=config_file, path=config_path)
else:
global_config.load(path=config_path)
# Initialize libraries
core_singletons.library_manager.... | 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 | 4.373589 | 4.666557 | 0.93722 |
sm = storage.load_state_machine_from_path(state_machine_path)
core_singletons.state_machine_manager.add_state_machine(sm)
return sm | 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 | 4.978054 | 7.835473 | 0.635323 |
global _user_abort
from rafcon.core.states.execution_state import ExecutionState
if not isinstance(state_machine.root_state, ExecutionState):
while len(state_machine.execution_histories[0]) < 1:
time.sleep(0.1)
else:
time.sleep(0.5)
while state_machine.root_state.s... | 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: | 7.28126 | 7.343215 | 0.991563 |
wait_for_state_machine_finished(state_machine)
from twisted.internet import reactor
if reactor.running:
plugins.run_hook("pre_destruction")
reactor.callFromThread(reactor.stop) | 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 | 5.435555 | 6.232108 | 0.872186 |
if self.node.ready.is_set():
return True
try:
return await self.node.wait_until_ready(timeout=timeout)
except asyncio.TimeoutError:
if no_raise:
return False
else:
raise | 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 wait indefinitely. | 3.018954 | 2.395461 | 1.260281 |
await self.node.join_voice_channel(self.channel.guild.id, self.channel.id) | async def connect(self) | Connects to the voice channel associated with this Player. | 8.047158 | 3.864904 | 2.082111 |
if channel.guild != self.channel.guild:
raise TypeError("Cannot move to a different guild.")
self.channel = channel
await self.connect() | async def move_to(self, channel: discord.VoiceChannel) | Moves this player to a voice channel.
Parameters
----------
channel : discord.VoiceChannel | 5.267554 | 5.234927 | 1.006233 |
if self.state == PlayerState.DISCONNECTING:
return
await self.update_state(PlayerState.DISCONNECTING)
if not requested:
log.debug(
f"Forcing player disconnect for guild {self.channel.guild.id}"
f" due to player manager request."
... | async def disconnect(self, requested=True) | Disconnects this player from it's voice channel. | 3.612024 | 3.45063 | 1.046773 |
if event == LavalinkEvents.TRACK_END:
if extra == TrackEndReason.FINISHED:
await self.play()
else:
self._is_playing = False | 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 threshold ms.
Parameters
----------
event : node.LavalinkEvents
... | 4.710038 | 4.393629 | 1.072015 |
if state.position > self.position:
self._is_playing = True
self.position = state.position | async def handle_player_update(self, state: "node.PlayerState") | Handles player updates from lavalink.
Parameters
----------
state : websocket.PlayerState | 6.915217 | 6.914993 | 1.000032 |
track.requester = requester
self.queue.append(track) | 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. | 8.319868 | 7.334311 | 1.134376 |
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.stop()
else:
self._is_playing = True
if self.sh... | async def play(self) | Starts playback from lavalink. | 3.177421 | 2.895143 | 1.0975 |
await self.node.stop(self.channel.guild.id)
self.queue = []
self.current = None
self.position = 0
self._paused = False | async def stop(self) | Stops playback from lavalink.
.. important::
This method will clear the queue. | 6.02166 | 4.473517 | 1.346068 |
self._paused = pause
await self.node.pause(self.channel.guild.id, pause) | async def pause(self, pause: bool = True) | Pauses the current song.
Parameters
----------
pause : bool
Set to ``False`` to resume. | 9.041479 | 9.16879 | 0.986115 |
self._volume = max(min(volume, 150), 0)
await self.node.volume(self.channel.guild.id, self.volume) | async def set_volume(self, volume: int) | Sets the volume of Lavalink.
Parameters
----------
volume : int
Between 0 and 150 | 6.123977 | 4.447842 | 1.376842 |
if self.current.seekable:
position = max(min(position, self.current.length), 0)
await self.node.seek(self.channel.guild.id, position) | async def seek(self, position: int) | If the track allows it, seeks to a position.
Parameters
----------
position : int
Between 0 and track length. | 5.499233 | 4.985107 | 1.103132 |
if self._already_in_guild(channel):
p = self.get_player(channel.guild.id)
await p.move_to(channel)
else:
p = Player(self, channel)
await p.connect()
self._player_dict[channel.guild.id] = p
await self.refresh_player_state(p)... | 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
-------
Player
The created Player object. | 3.141396 | 3.329324 | 0.943554 |
if guild_id in self._player_dict:
return self._player_dict[guild_id]
raise KeyError("No such player for that guild.") | 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 does not have a Player, e.g. is not connected to any
voi... | 4.217839 | 4.822807 | 0.874561 |
for p in tuple(self.players):
await p.disconnect(requested=False)
log.debug("Disconnected players.") | async def disconnect(self) | Disconnects all players. | 12.0665 | 9.052072 | 1.33301 |
if pkg_resources.resource_exists(package_or_requirement, resource_name):
return pkg_resources.resource_filename(package_or_requirement, resource_name)
path = _search_in_share_folders(package_or_requirement, resource_name)
if path:
return path
raise RuntimeError("Resource {} not f... | 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 resides
:param resource_name: the name of the resource
:return: the pat... | 2.379328 | 2.574177 | 0.924306 |
if pkg_resources.resource_exists(package_or_requirement, resource_name):
return True
path = _search_in_share_folders(package_or_requirement, resource_name)
return True if path else False | 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
:param resource_name: the name of the resource
:return: a flag if... | 3.766976 | 3.89901 | 0.966136 |
with open(resource_filename(package_or_requirement, resource_name), 'r') as resource_file:
return resource_file.read() | 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
:param resource_name: the name of the resource
:return: the file ... | 2.16634 | 2.849715 | 0.760196 |
path = resource_filename(package_or_requirement, relative_path)
only_files = [f for f in listdir(path) if isfile(join(path, f))]
return only_files | 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
:param relative_path: the relative path to the resource
:return:... | 2.266669 | 3.243679 | 0.698796 |
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:
continue
plugin_path = os.path.expandvars(os.path.expanduser(plugin_path)).strip()
if not os.pat... | def load_plugins() | Loads all plugins specified in the RAFCON_PLUGIN_PATH environment variable | 2.030944 | 1.827513 | 1.111316 |
for module in plugin_dict.values():
if hasattr(module, "hooks") and callable(getattr(module.hooks, hook_name, None)):
getattr(module.hooks, hook_name)(*args, **kwargs) | 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 | 3.102901 | 3.29991 | 0.940299 |
from rafcon.gui.models.state import StateModel
from rafcon.gui.models.container_state import ContainerStateModel
from rafcon.gui.models.library_state import LibraryStateModel
if isinstance(state, ContainerState):
return ContainerStateModel
elif isinstance(state, LibraryState):
r... | 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 | 2.700167 | 3.032603 | 0.890379 |
self.is_start = self.state.is_root_state or \
self.parent is None or \
isinstance(self.parent.state, LibraryState) or \
self.state.state_id == self.state.parent.start_state_id | def update_is_start(self) | Updates the `is_start` property of the state
A state is a start state, if it is the root state, it has no parent, the parent is a LibraryState or the state's
state_id is identical with the ContainerState.start_state_id of the ContainerState it is within. | 5.240649 | 2.783693 | 1.882625 |
if self.state is None:
logger.verbose("Multiple calls of prepare destruction for {0}".format(self))
self.destruction_signal.emit()
try:
self.unregister_observer(self)
except KeyError: # Might happen if the observer was already unregistered
lo... | def prepare_destruction(self, recursive=True) | Prepares the model for destruction
Recursively un-registers all observers and removes references to child models | 4.354419 | 4.217768 | 1.032399 |
from rafcon.gui.singleton import state_machine_manager_model
state_machine = self.state.get_state_machine()
if state_machine:
if state_machine.state_machine_id in state_machine_manager_model.state_machines:
sm_m = state_machine_manager_model.state_machines[st... | def get_state_machine_m(self, two_factor_check=True) | Get respective state machine model
Get a reference of the state machine model the state model belongs to. As long as the root state model
has no direct reference to its state machine model the state machine manager model is checked respective model.
:rtype: rafcon.gui.models.state_machine.Stat... | 5.583745 | 4.182235 | 1.33511 |
for data_port_m in self.input_data_ports:
if data_port_m.data_port.data_port_id == data_port_id:
return data_port_m
return None | def get_input_data_port_m(self, data_port_id) | Returns the input data port model for the given data port id
:param data_port_id: The data port id to search for
:return: The model of the data port with the given id | 2.195073 | 2.48081 | 0.884821 |
for data_port_m in self.output_data_ports:
if data_port_m.data_port.data_port_id == data_port_id:
return data_port_m
return None | def get_output_data_port_m(self, data_port_id) | Returns the output data port model for the given data port id
:param data_port_id: The data port id to search for
:return: The model of the data port with the given id | 2.160776 | 2.426957 | 0.890323 |
from itertools import chain
data_ports_m = chain(self.input_data_ports, self.output_data_ports)
for data_port_m in data_ports_m:
if data_port_m.data_port.data_port_id == data_port_id:
return data_port_m
return None | 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, but also the scoped variables.
:param data_po... | 2.194075 | 2.292182 | 0.957199 |
for outcome_m in self.outcomes:
if outcome_m.outcome.outcome_id == outcome_id:
return outcome_m
return False | def get_outcome_m(self, outcome_id) | Returns the outcome model for the given outcome id
:param outcome_id: The outcome id to search for
:return: The model of the outcome with the given id | 3.305897 | 3.733655 | 0.885432 |
msg = info.arg
# print("action_signal_triggered state: ", self.state.state_id, model, prop_name, info)
if msg.action.startswith('sm_notification_'):
return
# # affected child propagation from state
# if hasattr(self, 'states'):
# for m in info['ar... | def action_signal_triggered(self, model, prop_name, info) | This method notifies the parent state and child state models about complex actions | 4.442173 | 4.336092 | 1.024465 |
msg = info.arg
# print("meta_changed state: ", model, prop_name, info)
if msg.notification is None:
# Meta data of this state was changed, add information about notification to the signal message
notification = Notification(model, prop_name, info)
msg... | def meta_changed(self, model, prop_name, info) | This method notifies the parent state about changes made to the meta data | 6.018604 | 5.765118 | 1.043969 |
# TODO: for an Execution state this method is called for each hierarchy level again and again, still?? check it!
# print("1AbstractState_load_meta_data: ", path, not path)
if not path:
path = self.state.file_system_path
# print("2AbstractState_load_meta_data: ", path... | def load_meta_data(self, path=None) | Load meta data of state model from the file system
The meta data of the state model is loaded from the file system and stored in the meta property of the model.
Existing meta data is removed. Also the meta data of all state elements (data ports, outcomes,
etc) are loaded, as those stored in the... | 4.793679 | 4.515299 | 1.061653 |
if copy_path:
meta_file_path_json = os.path.join(copy_path, self.state.get_storage_path(), storage.FILE_NAME_META_DATA)
else:
if self.state.file_system_path is None:
logger.error("Meta data of {0} can be stored temporary arbitrary but by default first aft... | def store_meta_data(self, copy_path=None) | Save meta data of state model to the file system
This method generates a dictionary of the meta data of the state together with the meta data of all state
elements (data ports, outcomes, etc.) and stores it on the filesystem.
Secure that the store meta data method is called after storing the co... | 4.530929 | 4.363619 | 1.038342 |
self.meta = deepcopy(source_state_m.meta)
for input_data_port_m in self.input_data_ports:
source_data_port_m = source_state_m.get_input_data_port_m(input_data_port_m.data_port.data_port_id)
input_data_port_m.meta = deepcopy(source_data_port_m.meta)
for output_d... | def copy_meta_data_from_state_m(self, source_state_m) | Dismiss current meta data and copy meta data from given state model
The meta data of the given state model is used as meta data for this state. Also the meta data of all state
elements (data ports, outcomes, etc.) is overwritten with the meta data of the elements of the given state.
:param sou... | 1.901546 | 1.806491 | 1.052618 |
# print("_parse meta data", meta_data)
for data_port_m in self.input_data_ports:
self._copy_element_meta_data_from_meta_file_data(meta_data, data_port_m, "input_data_port",
data_port_m.data_port.data_port_id)
for d... | def _parse_for_element_meta_data(self, meta_data) | Load meta data for state elements
The meta data of the state meta data file also contains the meta data for state elements (data ports,
outcomes, etc). This method parses the loaded meta data for each state element model. The meta data of the
elements is removed from the passed dictionary.
... | 2.3915 | 2.290008 | 1.04432 |
meta_data_element_id = element_name + str(element_id)
meta_data_element = meta_data[meta_data_element_id]
# print(meta_data_element_id, element_m, meta_data_element)
element_m.meta = meta_data_element
del meta_data[meta_data_element_id] | def _copy_element_meta_data_from_meta_file_data(meta_data, element_m, element_name, element_id) | Helper method to assign the meta of the given element
The method assigns the meta data of the elements from the given meta data dictionary. The copied meta data is
then removed from the dictionary.
:param meta_data: The loaded meta data
:param element_m: The element model that is suppo... | 2.238967 | 2.329868 | 0.960985 |
for data_port_m in self.input_data_ports:
self._copy_element_meta_data_to_meta_file_data(meta_data, data_port_m, "input_data_port",
data_port_m.data_port.data_port_id)
for data_port_m in self.output_data_ports:
s... | 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 state elements (data ports, outcomes, etc) and adds it to the
given meta data dictionary.
:param meta_data: Dictionary of meta data | 2.059892 | 1.948444 | 1.057199 |
sm = self.model.state.get_state_machine()
if sm.marked_dirty and not self.saved_initial:
try:
# Save the file before opening it to update the applied changes. Use option create_full_path=True
# to assure that temporary state_machines' script files are... | def save_file_data(self, path) | Implements the abstract method of the ExternalEditor class. | 11.530882 | 11.378546 | 1.013388 |
content = filesystem.read_file(file_system_path, storage.SCRIPT_FILE)
if content is not None:
self.set_script_text(content) | def load_and_set_file_content(self, file_system_path) | Implements the abstract method of the ExternalEditor class. | 6.060289 | 5.733503 | 1.056996 |
if isinstance(self.model.state, LibraryState):
logger.warning("It is not allowed to modify libraries.")
self.view.set_text("")
return
# Ugly workaround to give user at least some feedback about the parser
# Without the loop, this function would block... | def apply_clicked(self, button) | Triggered when the Apply button in the source editor is clicked. | 5.207549 | 5.11613 | 1.017869 |
assert isinstance(text_to_split, string_types)
try:
time, rest = text_to_split.split(': ', 1)
source, message = rest.split(':', 1)
except ValueError:
time = source = ""
message = text_to_split
return time.strip(), source.strip(), m... | def split_text(text_to_split) | Split text
Splits the debug text into its different parts: 'Time', 'LogLevel + Module Name', 'Debug message'
:param text_to_split: Text to split
:return: List containing the content of text_to_split split up | 3.611386 | 3.536308 | 1.021231 |
if self._enables['CONSOLE_FOLLOW_LOGGING']:
if self._auto_scroll_handler_id is None:
self._auto_scroll_handler_id = self.text_view.connect("size-allocate", self._auto_scroll)
else:
if self._auto_scroll_handler_id is not None:
self.text_vie... | def update_auto_scroll_mode(self) | Register or un-register signals for follow mode | 2.926714 | 2.553895 | 1.14598 |
adj = self['scrollable'].get_vadjustment()
adj.set_value(adj.get_upper() - adj.get_page_size()) | def _auto_scroll(self, *args) | Scroll to the end of the text view | 3.58897 | 3.504152 | 1.024205 |
line_number, _ = self.get_cursor_position()
text_buffer = self.text_view.get_buffer()
line_iter = text_buffer.get_iter_at_line(line_number)
# find closest before line with string within
before_line_number = None
while line_iter.backward_line():
if s ... | def get_line_number_next_to_cursor_with_string_within(self, s) | Find the closest occurrence of a string with respect to the cursor position in the text view | 1.727145 | 1.718945 | 1.00477 |
key = str(key) # Ensure that we have the same string type for all keys (under Python2 and 3!)
if self.variable_exist(key):
if data_type is None:
data_type = self.__global_variable_type_dictionary[key]
else:
if data_type is None:
d... | def set_variable(self, key, value, per_reference=False, access_key=None, data_type=None) | Sets a global variable
:param key: the key of the global variable to be set
:param value: the new value of the global variable
:param per_reference: a flag to decide if the variable should be stored per reference or per value
:param access_key: if the variable was explicitly locked with... | 2.958574 | 2.863571 | 1.033176 |
key = str(key)
if self.variable_exist(key):
unlock = True
if self.is_locked(key):
if self.__access_keys[key] == access_key:
unlock = False
else:
if not access_key:
access_key ... | def get_variable(self, key, per_reference=None, access_key=None, default=None) | Fetches the value of a global variable
:param key: the key of the global variable to be fetched
:param bool per_reference: a flag to decide if the variable should be stored per reference or per value
:param access_key: if the variable was explicitly locked with the rafcon.state lock_variable
... | 3.066973 | 2.801844 | 1.094627 |
key = str(key)
return key in self.__variable_references and self.__variable_references[key] | def variable_can_be_referenced(self, key) | Checks whether the value of the variable can be returned by reference
:param str key: Name of the variable
:return: True if value of variable can be returned by reference, False else | 4.965984 | 8.651166 | 0.574025 |
key = str(key)
if self.is_locked(key):
raise RuntimeError("Global variable is locked")
with self.__global_lock:
if key in self.__global_variable_dictionary:
access_key = self.lock_variable(key, block=True)
del self.__global_variab... | def delete_variable(self, key) | Deletes a global variable
:param key: the key of the global variable to be deleted
:raises exceptions.AttributeError: if the global variable does not exist | 3.407458 | 3.385591 | 1.006459 |
key = str(key)
# watch out for releasing the __dictionary_lock properly
try:
if key in self.__variable_locks:
# acquire without arguments is blocking
lock_successful = self.__variable_locks[key].acquire(False)
if lock_successfu... | def lock_variable(self, key, block=False) | Locks a global variable
:param key: the key of the global variable to be locked
:param block: a flag to specify if to wait for locking the variable in blocking mode | 5.31869 | 5.483051 | 0.970024 |
key = str(key)
if self.__access_keys[key] == access_key or force:
if key in self.__variable_locks:
if self.is_locked(key):
self.__variable_locks[key].release()
return True
else:
logger.error(... | def unlock_variable(self, key, access_key, force=False) | Unlocks a global variable
:param key: the key of the global variable to be unlocked
:param access_key: the access key to be able to unlock the global variable
:param force: if the variable should be unlocked forcefully
:raises exceptions.AttributeError: if the global variable does not e... | 3.484616 | 3.36745 | 1.034794 |
return self.set_variable(key, value, per_reference=False, access_key=access_key) | def set_locked_variable(self, key, access_key, value) | Set an already locked global variable
:param key: the key of the global variable to be set
:param access_key: the access key to the already locked global variable
:param value: the new value of the global variable | 6.34553 | 10.404436 | 0.609887 |
return self.get_variable(key, per_reference=False, access_key=access_key) | def get_locked_variable(self, key, access_key) | Returns the value of an global variable that is already locked
:param key: the key of the global variable
:param access_key: the access_key to the global variable that is already locked | 6.962701 | 9.806458 | 0.710012 |
key = str(key)
if key in self.__variable_locks:
return self.__variable_locks[key].locked()
return False | def is_locked(self, key) | Returns the status of the lock of a global variable
:param key: the unique key of the global variable
:return: | 4.596767 | 5.784407 | 0.794683 |
start_key = str(start_key)
output_list = []
if len(self.__global_variable_dictionary) == 0:
return output_list
for g_key in self.__global_variable_dictionary.keys():
# string comparison
if g_key and start_key in g_key:
output_l... | def get_all_keys_starting_with(self, start_key) | Returns all keys, which start with a certain pattern defined in :param start_key.
:param start_key: The start pattern to search all keys for.
:return: | 3.077601 | 3.622811 | 0.849506 |
dict_copy = {}
for key, value in self.__global_variable_dictionary.items():
if key in self.__variable_references and self.__variable_references[key]:
dict_copy[key] = value
else:
dict_copy[key] = copy.deepcopy(value)
return dict_c... | def global_variable_dictionary(self) | Property for the _global_variable_dictionary field | 2.751724 | 2.725008 | 1.009804 |
if value is not None and data_type is not type(None):
# if not isinstance(value, data_type):
if not type_inherits_of_type(data_type, type(value)):
raise TypeError(
"Value: '{0}' is not of data type: '{1}', value type: {2}".format(value, data_t... | def check_value_and_type(value, data_type) | Checks if a given value is of a specific type
:param value: the value to check
:param data_type: the type to be checked upon
:return: | 3.536984 | 3.828858 | 0.92377 |
# Distance between border of rectangle and point
# Equation from http://stackoverflow.com/a/18157551/3568069
dx = max(self.point.x - self.width / 2. - pos[0], 0, pos[0] - (self.point.x + self.width / 2.))
dy = max(self.point.y - self.height / 2. - pos[1], 0, pos[1] - (self.point... | def glue(self, pos) | Calculates the distance between the given position and the port
:param (float, float) pos: Distance to this position is calculated
:return: Distance to port
:rtype: float | 2.966478 | 3.070012 | 0.966276 |
h, r = divmod(time / 1000, 3600)
m, s = divmod(r, 60)
return "%02d:%02d:%02d" % (h, m, s) | def format_time(time) | Formats the given time into HH:MM:SS | 2.122725 | 2.101938 | 1.00989 |
if self.parent:
self.parent.remove_controller(self)
else:
self.destroy() | def __destroy(self) | Remove controller from parent controller and/or destroy it self. | 4.958224 | 2.556584 | 1.939394 |
super(PreferencesWindowController, self).register_view(view)
self.view['add_library_button'].connect('clicked', self._on_add_library)
self.view["remove_library_button"].connect('clicked', self._on_remove_library)
self.view['config_tree_view'].connect("button_press_event", self.... | def register_view(self, view) | Called when the View was registered | 1.767664 | 1.758684 | 1.005106 |
config_key = info['args'][1] if "key" not in info['kwargs'] else info['kwargs']['key']
# config_value = info['args'][-1] if "value" not in info['kwargs'] else info['kwargs']['value']
self._handle_config_update(config_m, config_key) | def on_config_value_changed(self, config_m, prop_name, info) | Callback when a config value has been changed
Only collects information, delegates handling further to _handle_config_update
: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 ... | 3.464991 | 3.404156 | 1.017871 |
self.check_for_preliminary_config()
method_name = info['method_name'] # __setitem__, __delitem__, clear, ...
if method_name in ['__setitem__', '__delitem__']:
config_key = info['args'][0]
self._handle_config_update(config_m, config_key)
# Probably the ... | def on_preliminary_config_changed(self, config_m, prop_name, info) | Callback when a preliminary config value has been changed
Mainly collects information, delegates handling further to _handle_config_update
:param ConfigModel config_m: The config model that has been changed
:param str prop_name: Should always be 'preliminary_config'
:param dict info: I... | 5.139226 | 4.912641 | 1.046123 |
if config_key == "LIBRARY_PATHS":
self.update_libraries_list_store()
if config_key == "SHORTCUTS":
self.update_shortcut_settings()
else:
self.update_config_value(config_m, config_key) | def _handle_config_update(self, config_m, config_key) | Handles changes in config values
The method ensure that the correct list stores are updated with the new values.
:param ConfigModel config_m: The config model that has been changed
:param config_key: The config key who's value has been changed
:return: | 4.800889 | 4.741705 | 1.012482 |
self.update_path_labels()
self.update_core_config_list_store()
self.update_gui_config_list_store()
self.update_libraries_list_store()
self.update_shortcut_settings()
self.check_for_preliminary_config() | def update_all(self) | Shorthand method to update all collection information | 6.060045 | 5.950545 | 1.018402 |
if any([self.model.preliminary_config, self.gui_config_model.preliminary_config]):
self.view['apply_button'].set_sensitive(True)
else:
self.view['apply_button'].set_sensitive(False) | def check_for_preliminary_config(self) | Activates the 'Apply' button if there are preliminary changes | 4.064503 | 3.045071 | 1.334781 |
self.view['core_label'].set_text("Core Config Path: " + str(self.core_config_model.config.config_file_path))
self.view['gui_label'].set_text("GUI Config Path: " + str(self.gui_config_model.config.config_file_path)) | def update_path_labels(self) | Update labels showing config paths | 3.441797 | 2.866642 | 1.200637 |
config_value = config_m.get_current_config_value(config_key)
if config_m is self.core_config_model:
list_store = self.core_list_store
elif config_m is self.gui_config_model:
list_store = self.gui_list_store
else:
return
self._update_li... | def update_config_value(self, config_m, config_key) | Updates the corresponding list store of a changed config value
:param ConfigModel config_m: The config model that has been changed
:param str config_key: The config key who's value has been changed | 2.789558 | 2.68596 | 1.03857 |
for row_num, row in enumerate(list_store):
if row[self.KEY_STORAGE_ID] == config_key:
row[self.VALUE_STORAGE_ID] = str(config_value)
row[self.TOGGLE_VALUE_STORAGE_ID] = config_value
return row_num | def _update_list_store_entry(self, list_store, config_key, config_value) | Helper method to update a list store
:param Gtk.ListStore list_store: List store to be updated
:param str config_key: Config key to search for
:param config_value: New config value
:returns: Row of list store that has been updated
:rtype: int | 3.270243 | 3.290931 | 0.993714 |
ignore_keys = [] if ignore_keys is None else ignore_keys
list_store.clear()
for config_key in sorted(config_m.config.keys):
if config_key in ignore_keys:
continue
config_value = config_m.get_current_config_value(config_key)
# (config_k... | def _update_list_store(config_m, list_store, ignore_keys=None) | Generic method to create list store for a given config model
:param ConfigModel config_m: Config model to read into list store
:param Gtk.ListStore list_store: List store to be filled
:param list ignore_keys: List of keys that should be ignored | 2.56191 | 2.754755 | 0.929996 |
self.library_list_store.clear()
libraries = self.core_config_model.get_current_config_value("LIBRARY_PATHS", use_preliminary=True, default={})
library_names = sorted(libraries.keys())
for library_name in library_names:
library_path = libraries[library_name]
... | def update_libraries_list_store(self) | Creates the list store for the libraries | 3.27192 | 3.132276 | 1.044582 |
self.shortcut_list_store.clear()
shortcuts = self.gui_config_model.get_current_config_value("SHORTCUTS", use_preliminary=True, default={})
actions = sorted(shortcuts.keys())
for action in actions:
keys = shortcuts[action]
self.shortcut_list_store.append((... | def update_shortcut_settings(self) | Creates the list store for the shortcuts | 5.061658 | 4.413725 | 1.1468 |
for row_num, iter_elem in enumerate(list_store):
if iter_elem[column] == value:
tree_view.set_cursor(row_num)
return row_num | def _select_row_by_column_value(tree_view, list_store, column, value) | Helper method to select a tree view row
:param Gtk.TreeView tree_view: Tree view who's row is to be selected
:param Gtk.ListStore list_store: List store of the tree view
:param int column: Column in which the value is searched
:param value: Value to search for
:returns: Row of l... | 2.962962 | 3.487005 | 0.849715 |
self.view['library_tree_view'].grab_focus()
if react_to_event(self.view, self.view['library_tree_view'], event):
temp_library_name = "<LIB_NAME_%s>" % self._lib_counter
self._lib_counter += 1
library_config = self.core_config_model.get_current_config_value("L... | def _on_add_library(self, *event) | Callback method handling the addition of a new library | 4.796769 | 4.662862 | 1.028718 |
self.view['library_tree_view'].grab_focus()
if react_to_event(self.view, self.view['library_tree_view'], event):
path = self.view["library_tree_view"].get_cursor()[0]
if path is not None:
library_name = self.library_list_store[int(path[0])][0]
... | def _on_remove_library(self, *event) | Callback method handling the removal of an existing library | 3.254746 | 3.167314 | 1.027605 |
config_key = config_list_store[int(path)][self.KEY_STORAGE_ID]
config_value = bool(config_list_store[int(path)][self.TOGGLE_VALUE_STORAGE_ID])
config_value ^= True
config_m.set_preliminary_config_value(config_key, config_value) | def _on_checkbox_toggled(self, renderer, path, config_m, config_list_store) | Callback method handling a config toggle event
:param Gtk.CellRenderer renderer: Cell renderer that has been toggled
:param path: Path within the list store
:param ConfigModel config_m: The config model related to the toggle option
:param Gtk.ListStore config_list_store: The list store ... | 4.341711 | 4.621735 | 0.939411 |
def handle_import(dialog_text, path_name):
chooser = Gtk.FileChooserDialog(dialog_text, None,
Gtk.FileChooserAction.SAVE,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
... | def _on_import_config(self, *args) | Callback method the the import button was clicked
Shows a dialog allowing to import an existing configuration file | 2.848809 | 2.80027 | 1.017334 |
response = self._config_chooser_dialog("Export configuration",
"Please select the configuration file(s) to be exported:")
if response == Gtk.ResponseType.REJECT:
return
def handle_export(dialog_text, path, config_m):
... | def _on_export_config(self, *args) | Callback method the the export button was clicked
Shows dialogs allowing to export the configurations into separate files | 3.20253 | 3.159597 | 1.013588 |
if self.core_config_model.preliminary_config or self.gui_config_model.preliminary_config:
self._on_apply_button_clicked()
self.__destroy() | def _on_ok_button_clicked(self, *args) | OK button clicked: Applies the configurations and closes the window | 8.127923 | 5.96606 | 1.36236 |
self.core_config_model.preliminary_config.clear()
self.gui_config_model.preliminary_config.clear()
self.__destroy() | def _on_cancel_button_clicked(self, *args) | Cancel button clicked: Dismiss preliminary config and close the window | 8.691566 | 4.929112 | 1.763312 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.