sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def handle(self, event):
"""
Handle the event by calling each tool until the event is handled
or grabbed.
If a tool is returning True on a button press event, the motion and
button release events are also passed to this
"""
# Allow to handle a subset of events whi... | Handle the event by calling each tool until the event is handled
or grabbed.
If a tool is returning True on a button press event, the motion and
button release events are also passed to this | entailment |
def movable_items(self):
"""Filter selection
Filter items of selection that cannot be moved (i.e. are not instances of `Item`) and return the rest.
"""
view = self.view
if self._move_name_v:
yield InMotion(self._item, view)
else:
selected_items =... | Filter selection
Filter items of selection that cannot be moved (i.e. are not instances of `Item`) and return the rest. | entailment |
def on_button_press(self, event):
"""Select items
When the mouse button is pressed, the selection is updated.
:param event: The button event
"""
if event.get_button()[1] not in self._buttons:
return False # Only handle events for registered buttons (left mouse clic... | Select items
When the mouse button is pressed, the selection is updated.
:param event: The button event | entailment |
def on_button_release(self, event):
"""Write back changes
If one or more items have been moved, the new position are stored in the corresponding meta data and a signal
notifying the change is emitted.
:param event: The button event
"""
affected_models = {}
for ... | Write back changes
If one or more items have been moved, the new position are stored in the corresponding meta data and a signal
notifying the change is emitted.
:param event: The button event | entailment |
def _filter_library_state(self, items):
"""Filters out child elements of library state when they cannot be hovered
Checks if hovered item is within a LibraryState
* if not, the list is returned unfiltered
* if so, STATE_SELECTION_INSIDE_LIBRARY_STATE_ENABLED is checked
* if ... | Filters out child elements of library state when they cannot be hovered
Checks if hovered item is within a LibraryState
* if not, the list is returned unfiltered
* if so, STATE_SELECTION_INSIDE_LIBRARY_STATE_ENABLED is checked
* if enabled, the library is selected (instead of the st... | entailment |
def _filter_hovered_items(self, items, event):
"""Filters out items that cannot be hovered
:param list items: Sorted list of items beneath the cursor
:param Gtk.Event event: Motion event
:return: filtered items
:rtype: list
"""
items = self._filter_library_state(... | Filters out items that cannot be hovered
:param list items: Sorted list of items beneath the cursor
:param Gtk.Event event: Motion event
:return: filtered items
:rtype: list | entailment |
def on_button_release(self, event):
"""Select or deselect rubber banded groups of items
The selection of elements is prior and never items are selected or deselected at the same time.
"""
self.queue_draw(self.view)
x0, y0, x1, y1 = self.x0, self.y0, self.x1, self.y1
re... | Select or deselect rubber banded groups of items
The selection of elements is prior and never items are selected or deselected at the same time. | entailment |
def on_button_press(self, event):
"""Handle button press events.
If the (mouse) button is pressed on top of a Handle (item.Handle), that handle is grabbed and can be
dragged around.
"""
if not event.get_button()[1] == 1: # left mouse button
return False
view... | Handle button press events.
If the (mouse) button is pressed on top of a Handle (item.Handle), that handle is grabbed and can be
dragged around. | entailment |
def _set_motion_handle(self, event):
"""Sets motion handle to currently grabbed handle
"""
item = self.grabbed_item
handle = self.grabbed_handle
pos = event.x, event.y
self.motion_handle = HandleInMotion(item, handle, self.view)
self.motion_handle.GLUE_DISTANCE = ... | Sets motion handle to currently grabbed handle | entailment |
def _create_temporary_connection(self):
"""Creates a placeholder connection view
:return: New placeholder connection
:rtype: rafcon.gui.mygaphas.items.connection.ConnectionPlaceholderView
"""
if self._is_transition:
self._connection_v = TransitionPlaceholderView(self... | Creates a placeholder connection view
:return: New placeholder connection
:rtype: rafcon.gui.mygaphas.items.connection.ConnectionPlaceholderView | entailment |
def _handle_temporary_connection(self, old_sink, new_sink, of_target=True):
"""Connect connection to new_sink
If new_sink is set, the connection origin or target will be set to new_sink. The connection to old_sink is
being removed.
:param gaphas.aspect.ConnectionSink old_sink: Old sink... | Connect connection to new_sink
If new_sink is set, the connection origin or target will be set to new_sink. The connection to old_sink is
being removed.
:param gaphas.aspect.ConnectionSink old_sink: Old sink (if existing)
:param gaphas.aspect.ConnectionSink new_sink: New sink (if exist... | entailment |
def _connect_temporarily(self, port_v, target=True):
"""Set a connection between the current connection and the given port
:param rafcon.gui.mygaphas.items.ports.PortView port_v: The port to be connected
:param bool target: Whether the connection origin or target should be connected
"""... | Set a connection between the current connection and the given port
:param rafcon.gui.mygaphas.items.ports.PortView port_v: The port to be connected
:param bool target: Whether the connection origin or target should be connected | entailment |
def _disconnect_temporarily(self, port_v, target=True):
"""Removes a connection between the current connection and the given port
:param rafcon.gui.mygaphas.items.ports.PortView port_v: The port that was connected
:param bool target: Whether the connection origin or target should be disconnecte... | Removes a connection between the current connection and the given port
:param rafcon.gui.mygaphas.items.ports.PortView port_v: The port that was connected
:param bool target: Whether the connection origin or target should be disconnected | entailment |
def on_button_press(self, event):
"""Handle button press events.
If the (mouse) button is pressed on top of a Handle (item.Handle), that handle is grabbed and can be
dragged around.
"""
if not event.get_button()[1] == 1: # left mouse button
return False
view... | Handle button press events.
If the (mouse) button is pressed on top of a Handle (item.Handle), that handle is grabbed and can be
dragged around. | entailment |
def on_button_press(self, event):
"""Handle button press events.
If the (mouse) button is pressed on top of a Handle (item.Handle), that handle is grabbed and can be
dragged around.
"""
if not event.get_button()[1] == 1: # left mouse button
return False
view... | Handle button press events.
If the (mouse) button is pressed on top of a Handle (item.Handle), that handle is grabbed and can be
dragged around. | entailment |
def register_view(self, view):
"""Called when the View was registered"""
super(ToolBarController, self).register_view(view)
self.view['button_new'].connect('clicked', self.on_button_new_clicked)
self.view['button_open'].connect('clicked', self.on_button_open_clicked)
self.view['b... | Called when the View was registered | entailment |
def initialize(self):
"""Initializes the library manager
It searches through all library paths given in the config file for libraries, and loads the states.
This cannot be done in the __init__ function as the library_manager can be compiled and executed by
singleton.py before the state... | Initializes the library manager
It searches through all library paths given in the config file for libraries, and loads the states.
This cannot be done in the __init__ function as the library_manager can be compiled and executed by
singleton.py before the state*.pys are loaded | entailment |
def _clean_path(path):
"""Create a fully fissile absolute system path with no symbolic links and environment variables"""
path = path.replace('"', '')
path = path.replace("'", '')
# Replace ~ with /home/user
path = os.path.expanduser(path)
# Replace environment variables
... | Create a fully fissile absolute system path with no symbolic links and environment variables | entailment |
def _load_nested_libraries(self, library_path, target_dict):
"""Recursively load libraries within path
Adds all libraries specified in a given path and stores them into the provided library dictionary. The library
entries in the dictionary consist only of the path to the library in the file sys... | Recursively load libraries within path
Adds all libraries specified in a given path and stores them into the provided library dictionary. The library
entries in the dictionary consist only of the path to the library in the file system.
:param library_path: the path to add all libraries from
... | entailment |
def get_os_path_to_library(self, library_path, library_name, allow_user_interaction=True):
"""Find library_os_path of library
This function retrieves the file system library_os_path of a library specified by a library_path and a
library_name. In case the library does not exist any more at its ... | Find library_os_path of library
This function retrieves the file system library_os_path of a library specified by a library_path and a
library_name. In case the library does not exist any more at its original location, the user has to specify
an alternative location.
:param str libra... | entailment |
def _get_library_os_path_from_library_dict_tree(self, library_path, library_name):
"""Hand verified library os path from libraries dictionary tree."""
if library_path is None or library_name is None:
return None
path_list = library_path.split(os.sep)
target_lib_dict = self.li... | Hand verified library os path from libraries dictionary tree. | entailment |
def _get_library_root_key_for_os_path(self, path):
"""Return library root key if path is within library root paths"""
path = os.path.realpath(path)
library_root_key = None
for library_root_key, library_root_path in self._library_root_paths.items():
rel_path = os.path.relpath(... | Return library root key if path is within library root paths | entailment |
def get_library_path_and_name_for_os_path(self, path):
"""Generate valid library_path and library_name
The method checks if the given os path is in the list of loaded library root paths and use respective
library root key/mounting point to concatenate the respective library_path and separate r... | Generate valid library_path and library_name
The method checks if the given os path is in the list of loaded library root paths and use respective
library root key/mounting point to concatenate the respective library_path and separate respective library_name.
:param str path: A library os pat... | entailment |
def get_library_instance(self, library_path, library_name):
"""Generate a Library instance from within libraries dictionary tree."""
if self.is_library_in_libraries(library_path, library_name):
from rafcon.core.states.library_state import LibraryState
return LibraryState(library_... | Generate a Library instance from within libraries dictionary tree. | entailment |
def get_library_state_copy_instance(self, lib_os_path):
""" A method to get a state copy of the library specified via the lib_os_path.
:param lib_os_path: the location of the library to get a copy for
:return:
"""
# originally libraries were called like this; DO NOT DELETE; int... | A method to get a state copy of the library specified via the lib_os_path.
:param lib_os_path: the location of the library to get a copy for
:return: | entailment |
def remove_library_from_file_system(self, library_path, library_name):
"""Remove library from hard disk."""
library_file_system_path = self.get_os_path_to_library(library_path, library_name)[0]
shutil.rmtree(library_file_system_path)
self.refresh_libraries() | Remove library from hard disk. | entailment |
def buses_of_vlvl(network, voltage_level):
""" Get bus-ids of given voltage level(s).
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
voltage_level: list
Returns
-------
list
List containing bus-ids.
"""
mask = network.buses.v_n... | Get bus-ids of given voltage level(s).
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
voltage_level: list
Returns
-------
list
List containing bus-ids. | entailment |
def buses_grid_linked(network, voltage_level):
""" Get bus-ids of a given voltage level connected to the grid.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
voltage_level: list
Returns
-------
list
List containing bus-ids.
"""
... | Get bus-ids of a given voltage level connected to the grid.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
voltage_level: list
Returns
-------
list
List containing bus-ids. | entailment |
def geolocation_buses(network, session):
"""
If geopandas is installed:
Use Geometries of buses x/y(lon/lat) and Polygons
of Countries from RenpassGisParameterRegion
in order to locate the buses
Else:
Use coordinats of buses to locate foreign buses, which is less accurate.
Param... | If geopandas is installed:
Use Geometries of buses x/y(lon/lat) and Polygons
of Countries from RenpassGisParameterRegion
in order to locate the buses
Else:
Use coordinats of buses to locate foreign buses, which is less accurate.
Parameters
----------
network_etrago: : class: `e... | entailment |
def buses_by_country(network):
"""
Find buses of foreign countries using coordinates
and return them as Pandas Series
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
Returns
-------
foreign_buses: Series containing buses by country
"""
... | Find buses of foreign countries using coordinates
and return them as Pandas Series
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
Returns
-------
foreign_buses: Series containing buses by country | entailment |
def clip_foreign(network):
"""
Delete all components and timelines located outside of Germany.
Add transborder flows divided by country of origin as
network.foreign_trade.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
Returns
-------
n... | Delete all components and timelines located outside of Germany.
Add transborder flows divided by country of origin as
network.foreign_trade.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
Returns
-------
network : :class:`pypsa.Network
... | entailment |
def foreign_links(network):
"""Change transmission technology of foreign lines from AC to DC (links).
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
Returns
-------
network : :class:`pypsa.Network
Overall container of PyPSA
"""
... | Change transmission technology of foreign lines from AC to DC (links).
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
Returns
-------
network : :class:`pypsa.Network
Overall container of PyPSA | entailment |
def set_q_foreign_loads(network, cos_phi=1):
"""Set reative power timeseries of loads in neighbouring countries
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
cos_phi: float
Choose ration of active and reactive power of foreign loads
Return... | Set reative power timeseries of loads in neighbouring countries
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
cos_phi: float
Choose ration of active and reactive power of foreign loads
Returns
-------
network : :class:`pypsa.Network
... | entailment |
def connected_grid_lines(network, busids):
""" Get grid lines connected to given buses.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
busids : list
List containing bus-ids.
Returns
-------
:class:`pandas.DataFrame
PyPSA lines.... | Get grid lines connected to given buses.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
busids : list
List containing bus-ids.
Returns
-------
:class:`pandas.DataFrame
PyPSA lines. | entailment |
def connected_transformer(network, busids):
""" Get transformer connected to given buses.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
busids : list
List containing bus-ids.
Returns
-------
:class:`pandas.DataFrame
PyPSA tran... | Get transformer connected to given buses.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
busids : list
List containing bus-ids.
Returns
-------
:class:`pandas.DataFrame
PyPSA transformer. | entailment |
def load_shedding(network, **kwargs):
""" Implement load shedding in existing network to identify
feasibility problems
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
marginal_cost : int
Marginal costs for load shedding
p_nom : int
... | Implement load shedding in existing network to identify
feasibility problems
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
marginal_cost : int
Marginal costs for load shedding
p_nom : int
Installed capacity of load shedding generato... | entailment |
def data_manipulation_sh(network):
""" Adds missing components to run calculations with SH scenarios.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
"""
from shapely.geometry import Point, LineString, MultiLineString
from geoalchemy2.shap... | Adds missing components to run calculations with SH scenarios.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA | entailment |
def results_to_csv(network, args, pf_solution=None):
""" Function the writes the calaculation results
in csv-files in the desired directory.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
args: dict
Contains calculation settings of appl.py
... | Function the writes the calaculation results
in csv-files in the desired directory.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
args: dict
Contains calculation settings of appl.py
pf_solution: pandas.Dataframe or None
If pf was calcu... | entailment |
def parallelisation(network, args, group_size, extra_functionality=None):
"""
Function that splits problem in selected number of
snapshot groups and runs optimization successive for each group.
Not useful for calculations with storage untis or extension.
Parameters
----------
... | Function that splits problem in selected number of
snapshot groups and runs optimization successive for each group.
Not useful for calculations with storage untis or extension.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
args: dict
... | entailment |
def set_slack(network):
""" Function that chosses the bus with the maximum installed power as slack
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
Returns
-------
network : :class:`pypsa.Network
Overall container of PyPSA
"""
... | Function that chosses the bus with the maximum installed power as slack
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
Returns
-------
network : :class:`pypsa.Network
Overall container of PyPSA | entailment |
def pf_post_lopf(network, args, extra_functionality, add_foreign_lopf):
""" Function that prepares and runs non-linar load flow using PyPSA pf.
If network has been extendable, a second lopf with reactances adapted to
new s_nom is needed.
If crossborder lines are DC-links, pf is only applied... | Function that prepares and runs non-linar load flow using PyPSA pf.
If network has been extendable, a second lopf with reactances adapted to
new s_nom is needed.
If crossborder lines are DC-links, pf is only applied on german network.
Crossborder flows are still considerd due to the active ... | entailment |
def distribute_q(network, allocation='p_nom'):
""" Function that distributes reactive power at bus to all installed
generators and storages.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
allocation: str
Choose key to distribute reactive p... | Function that distributes reactive power at bus to all installed
generators and storages.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
allocation: str
Choose key to distribute reactive power:
'p_nom' to dirstribute via p_nom
'p' t... | entailment |
def calc_line_losses(network):
""" Calculate losses per line with PF result data
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
s0 : series
apparent power of line
i0 : series
current of line
-------
"""
# Line losses
... | Calculate losses per line with PF result data
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
s0 : series
apparent power of line
i0 : series
current of line
------- | entailment |
def set_line_costs(network, args,
cost110=230, cost220=290, cost380=85, costDC=375):
""" Set capital costs for extendable lines in respect to PyPSA [€/MVA]
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
args: dict containing settings... | Set capital costs for extendable lines in respect to PyPSA [€/MVA]
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
args: dict containing settings from appl.py
cost110 : capital costs per km for 110kV lines and cables
default: 230€/MVA/km,... | entailment |
def set_trafo_costs(network, args, cost110_220=7500, cost110_380=17333,
cost220_380=14166):
""" Set capital costs for extendable transformers in respect
to PyPSA [€/MVA]
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
cost110_220... | Set capital costs for extendable transformers in respect
to PyPSA [€/MVA]
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
cost110_220 : capital costs for 110/220kV transformer
default: 7500€/MVA, source: costs for extra trafo in
... | entailment |
def add_missing_components(network):
# Munich
"""Add missing transformer at Heizkraftwerk Nord in Munich and missing
transformer in Stuttgart
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
Returns
-------
network : :class:`pypsa.Network... | Add missing transformer at Heizkraftwerk Nord in Munich and missing
transformer in Stuttgart
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
Returns
-------
network : :class:`pypsa.Network
Overall container of PyPSA | entailment |
def convert_capital_costs(network, start_snapshot, end_snapshot, p=0.05, T=40):
""" Convert capital_costs to fit to pypsa and caluculated time
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
p : interest rate, default 0.05
T : number of periods, defa... | Convert capital_costs to fit to pypsa and caluculated time
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
p : interest rate, default 0.05
T : number of periods, default 40 years (source: StromNEV Anlage 1)
------- | entailment |
def find_snapshots(network, carrier, maximum = True, minimum = True, n = 3):
"""
Function that returns snapshots with maximum and/or minimum feed-in of
selected carrier.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
carrier: str
Selec... | Function that returns snapshots with maximum and/or minimum feed-in of
selected carrier.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
carrier: str
Selected carrier of generators
maximum: bool
Choose if timestep of maximal feed-in is r... | entailment |
def ramp_limits(network):
""" Add ramping constraints to thermal power plants.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
Returns
-------
"""
carrier = ['coal', 'biomass', 'gas', 'oil', 'waste', 'lignite',
'urani... | Add ramping constraints to thermal power plants.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
Returns
------- | entailment |
def get_args_setting(args, jsonpath='scenario_setting.json'):
"""
Get and open json file with scenaio settings of eTraGo ``args``.
The settings incluedes all eTraGo specific settings of arguments and
parameters for a reproducible calculation.
Parameters
----------
json_file : str
D... | Get and open json file with scenaio settings of eTraGo ``args``.
The settings incluedes all eTraGo specific settings of arguments and
parameters for a reproducible calculation.
Parameters
----------
json_file : str
Default: ``scenario_setting.json``
Name of scenario setting json fi... | entailment |
def set_line_country_tags(network):
"""
Set country tag for AC- and DC-lines.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
"""
transborder_lines_0 = network.lines[network.lines['bus0'].isin(
network.buses.index[network.buses['coun... | Set country tag for AC- and DC-lines.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA | entailment |
def crossborder_capacity(network, method, capacity_factor):
"""
Adjust interconnector capacties.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
method : string
Method of correction. Options are 'ntc_acer' and 'thermal_acer'.
'ntc_acer' c... | Adjust interconnector capacties.
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
method : string
Method of correction. Options are 'ntc_acer' and 'thermal_acer'.
'ntc_acer' corrects all capacities according to values published by
the ACE... | entailment |
def set_branch_capacity(network, args):
"""
Set branch capacity factor of lines and transformers, different factors for
HV (110kV) and eHV (220kV, 380kV).
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
args: dict
Settings in appl.py
""... | Set branch capacity factor of lines and transformers, different factors for
HV (110kV) and eHV (220kV, 380kV).
Parameters
----------
network : :class:`pypsa.Network
Overall container of PyPSA
args: dict
Settings in appl.py | entailment |
def max_line_ext(network, snapshots, share=1.01):
"""
Sets maximal share of overall network extension
as extra functionality in LOPF
Parameters
----------
share: float
Maximal share of network extension in p.u.
"""
lines_snom = network.lines.s_nom.sum()
links_pnom = networ... | Sets maximal share of overall network extension
as extra functionality in LOPF
Parameters
----------
share: float
Maximal share of network extension in p.u. | entailment |
def min_renewable_share(network, snapshots, share=0.72):
"""
Sets minimal renewable share of generation as extra functionality in LOPF
Parameters
----------
share: float
Minimal share of renewable generation in p.u.
"""
renewables = ['wind_onshore', 'wind_offshore',
... | Sets minimal renewable share of generation as extra functionality in LOPF
Parameters
----------
share: float
Minimal share of renewable generation in p.u. | entailment |
def max_curtailment(network, snapshots, curtail_max=0.03):
"""
each RE can only be curtailed (over all snapshots)
with respect to curtail_max
Parameters
----------
curtail_max: float
maximal curtailment per power plant in p.u.
"""
renewables = ['wind_onshore', 'wind_offsho... | each RE can only be curtailed (over all snapshots)
with respect to curtail_max
Parameters
----------
curtail_max: float
maximal curtailment per power plant in p.u. | entailment |
def get_node(guild_id: int, ignore_ready_status: bool = False) -> Node:
"""
Gets a node based on a guild ID, useful for noding separation. If the
guild ID does not already have a node association, the least used
node is returned. Skips over nodes that are not yet ready.
Parameters
----------
... | Gets a node based on a guild ID, useful for noding separation. If the
guild ID does not already have a node association, the least used
node is returned. Skips over nodes that are not yet ready.
Parameters
----------
guild_id : int
ignore_ready_status : bool
Returns
-------
Node | entailment |
async def join_voice(guild_id: int, channel_id: int):
"""
Joins a voice channel by ID's.
Parameters
----------
guild_id : int
channel_id : int
"""
node = get_node(guild_id)
voice_ws = node.get_voice_ws(guild_id)
await voice_ws.voice_state(guild_id, channel_id) | Joins a voice channel by ID's.
Parameters
----------
guild_id : int
channel_id : int | entailment |
async def connect(self, timeout=None):
"""
Connects to the Lavalink player event websocket.
Parameters
----------
timeout : int
Time after which to timeout on attempting to connect to the Lavalink websocket,
``None`` is considered never, but the underlyin... | Connects to the Lavalink player event websocket.
Parameters
----------
timeout : int
Time after which to timeout on attempting to connect to the Lavalink websocket,
``None`` is considered never, but the underlying code may stop trying past a
certain point.
... | entailment |
async def listener(self):
"""
Listener task for receiving ops from Lavalink.
"""
while self._ws.open and self._is_shutdown is False:
try:
data = json.loads(await self._ws.recv())
except websockets.ConnectionClosed:
break
... | Listener task for receiving ops from Lavalink. | entailment |
async def join_voice_channel(self, guild_id, channel_id):
"""
Alternative way to join a voice channel if node is known.
"""
voice_ws = self.get_voice_ws(guild_id)
await voice_ws.voice_state(guild_id, channel_id) | Alternative way to join a voice channel if node is known. | entailment |
async def disconnect(self):
"""
Shuts down and disconnects the websocket.
"""
self._is_shutdown = True
self.ready.clear()
self.update_state(NodeState.DISCONNECTING)
await self.player_manager.disconnect()
if self._ws is not None and self._ws.open:
... | Shuts down and disconnects the websocket. | entailment |
def register_view(self, view):
"""Called when the View was registered
Can be used e.g. to connect signals. Here, the destroy signal is connected to close the application
:param rafcon.gui.views.state_editor.overview.StateOverviewView view: A state overview view instance
"""
# p... | Called when the View was registered
Can be used e.g. to connect signals. Here, the destroy signal is connected to close the application
:param rafcon.gui.views.state_editor.overview.StateOverviewView view: A state overview view instance | entailment |
def run(self):
""" This defines the sequence of actions that are taken when the barrier concurrency state is executed
:return:
"""
logger.debug("Starting execution of {0}{1}".format(self, " (backwards)" if self.backward_execution else ""))
self.setup_run()
# data to be ... | This defines the sequence of actions that are taken when the barrier concurrency state is executed
:return: | entailment |
def run_decider_state(self, decider_state, child_errors, final_outcomes_dict):
""" Runs the decider state of the barrier concurrency state. The decider state decides on which outcome the
barrier concurrency is left.
:param decider_state: the decider state of the barrier concurrency state
... | Runs the decider state of the barrier concurrency state. The decider state decides on which outcome the
barrier concurrency is left.
:param decider_state: the decider state of the barrier concurrency state
:param child_errors: error of the concurrent branches
:param final_outcomes_dict:... | entailment |
def _check_transition_validity(self, check_transition):
""" Transition of BarrierConcurrencyStates must least fulfill the condition of a ContainerState.
Start transitions are forbidden in the ConcurrencyState.
:param check_transition: the transition to check for validity
:return:
... | Transition of BarrierConcurrencyStates must least fulfill the condition of a ContainerState.
Start transitions are forbidden in the ConcurrencyState.
:param check_transition: the transition to check for validity
:return: | entailment |
def add_state(self, state, storage_load=False):
"""Overwrite the parent class add_state method
Add automatic transition generation for the decider_state.
:param state: The state to be added
:return:
"""
state_id = super(BarrierConcurrencyState, self).add_state(state)
... | Overwrite the parent class add_state method
Add automatic transition generation for the decider_state.
:param state: The state to be added
:return: | entailment |
def states(self, states):
""" Overwrite the setter of the container state base class as special handling for the decider state is needed.
:param states: the dictionary of new states
:raises exceptions.TypeError: if the states parameter is not of type dict
"""
# First safely remo... | Overwrite the setter of the container state base class as special handling for the decider state is needed.
:param states: the dictionary of new states
:raises exceptions.TypeError: if the states parameter is not of type dict | entailment |
def remove_state(self, state_id, recursive=True, force=False, destroy=True):
""" Overwrite the parent class remove state method by checking if the user tries to delete the decider state
:param state_id: the id of the state to remove
:param recursive: a flag to indicate a recursive disassembling... | Overwrite the parent class remove state method by checking if the user tries to delete the decider state
:param state_id: the id of the state to remove
:param recursive: a flag to indicate a recursive disassembling of all substates
:param force: a flag to indicate forcefully deletion of all sta... | entailment |
def get_outcome_for_state_name(self, name):
""" Returns the final outcome of the child state specified by name.
Note: This is utility function that is used by the programmer to make a decision based on the final outcome
of its child states. A state is not uniquely specified by the name, but as ... | Returns the final outcome of the child state specified by name.
Note: This is utility function that is used by the programmer to make a decision based on the final outcome
of its child states. A state is not uniquely specified by the name, but as the programmer normally does not want
to use sta... | entailment |
def get_outcome_for_state_id(self, state_id):
""" Returns the final outcome of the child state specified by the state_id.
:param state_id: The id of the state to get the final outcome for.
:return:
"""
return_value = None
for s_id, name_outcome_tuple in self.final_outcom... | Returns the final outcome of the child state specified by the state_id.
:param state_id: The id of the state to get the final outcome for.
:return: | entailment |
def get_errors_for_state_name(self, name):
""" Returns the error message of the child state specified by name.
Note: This is utility function that is used by the programmer to make a decision based on the final outcome
of its child states. A state is not uniquely specified by the name, but as t... | Returns the error message of the child state specified by name.
Note: This is utility function that is used by the programmer to make a decision based on the final outcome
of its child states. A state is not uniquely specified by the name, but as the programmer normally does not want
to use sta... | entailment |
def add_controller(self, key, controller):
"""Add child controller
The passed controller is registered as child of self. The register_actions method of the child controller is
called, allowing the child controller to register shortcut callbacks.
:param key: Name of the controller (uniq... | Add child controller
The passed controller is registered as child of self. The register_actions method of the child controller is
called, allowing the child controller to register shortcut callbacks.
:param key: Name of the controller (unique within self), to later access it again
:par... | entailment |
def remove_controller(self, controller):
"""Remove child controller and destroy it
Removes all references to the child controller and calls destroy() on the controller.
:param str | ExtendedController controller: Either the child controller object itself or its registered name
:return:... | Remove child controller and destroy it
Removes all references to the child controller and calls destroy() on the controller.
:param str | ExtendedController controller: Either the child controller object itself or its registered name
:return: Whether the controller was existing
:rtype:... | entailment |
def register_actions(self, shortcut_manager):
"""Register callback methods for triggered actions in all child controllers.
:param rafcon.gui.shortcut_manager.ShortcutManager shortcut_manager: Shortcut Manager Object holding mappings
between shortcuts and actions.
"""
assert ... | Register callback methods for triggered actions in all child controllers.
:param rafcon.gui.shortcut_manager.ShortcutManager shortcut_manager: Shortcut Manager Object holding mappings
between shortcuts and actions. | entailment |
def destroy(self):
"""Recursively destroy all Controllers
The method remove all controllers, which calls the destroy method of the child controllers. Then,
all registered models are relieved and and the widget hand by the initial view argument is destroyed.
"""
self.disconnect_a... | Recursively destroy all Controllers
The method remove all controllers, which calls the destroy method of the child controllers. Then,
all registered models are relieved and and the widget hand by the initial view argument is destroyed. | entailment |
def observe_model(self, model):
"""Make this model observable within the controller
The method also keeps track of all observed models, in order to be able to relieve them later on.
:param gtkmvc3.Model model: The model to be observed
"""
self.__registered_models.add(model)
... | Make this model observable within the controller
The method also keeps track of all observed models, in order to be able to relieve them later on.
:param gtkmvc3.Model model: The model to be observed | entailment |
def relieve_model(self, model):
"""Do no longer observe the model
The model is also removed from the internal set of tracked models.
:param gtkmvc3.Model model: The model to be relieved
"""
self.__registered_models.remove(model)
return super(ExtendedController, self).re... | Do no longer observe the model
The model is also removed from the internal set of tracked models.
:param gtkmvc3.Model model: The model to be relieved | entailment |
def relieve_all_models(self):
"""Relieve all registered models
The method uses the set of registered models to relieve them.
"""
map(self.relieve_model, list(self.__registered_models))
self.__registered_models.clear() | Relieve all registered models
The method uses the set of registered models to relieve them. | entailment |
def change_data_type(self, data_type, default_value=None):
"""This method changes both the data type and default value. If one of the parameters does not fit,
an exception is thrown and no property is changed. Using this method ensures a consistent data type
and default value and only notifies o... | This method changes both the data type and default value. If one of the parameters does not fit,
an exception is thrown and no property is changed. Using this method ensures a consistent data type
and default value and only notifies once.
:param data_type: The new data type
:param defau... | entailment |
def check_default_value(self, default_value, data_type=None):
"""Check whether the passed default value suits to the passed data type. If no data type is passed, the
data type of the data port is used. If the default value does not fit, an exception is thrown. If the default
value is of type str... | Check whether the passed default value suits to the passed data type. If no data type is passed, the
data type of the data port is used. If the default value does not fit, an exception is thrown. If the default
value is of type string, it is tried to convert that value to the data type.
:param ... | entailment |
def open_folder_cmd_line(query, default_path=None):
"""Queries the user for a path to open
:param str query: Query that asks the user for a specific folder path to be opened
:param str default_path: Path to use if the user doesn't specify a path
:return: Input path from the user or `default_path` ... | Queries the user for a path to open
:param str query: Query that asks the user for a specific folder path to be opened
:param str default_path: Path to use if the user doesn't specify a path
:return: Input path from the user or `default_path` if nothing is specified or None if path does not exist
... | entailment |
def create_folder_cmd_line(query, default_name=None, default_path=None):
"""Queries the user for a path to be created
:param str query: Query that asks the user for a specific folder path to be created
:param str default_name: Default name of the folder to be created
:param str default_path: Path in w... | Queries the user for a path to be created
:param str query: Query that asks the user for a specific folder path to be created
:param str default_name: Default name of the folder to be created
:param str default_path: Path in which the folder is created if the user doesn't specify a path
:return: Input... | entailment |
def save_folder_cmd_line(query, default_name=None, default_path=None):
"""Queries the user for a path or file to be saved into
The folder or file has not to be created already and will not be created by this function. The parent directory
of folder and file has to exist otherwise the function will return N... | Queries the user for a path or file to be saved into
The folder or file has not to be created already and will not be created by this function. The parent directory
of folder and file has to exist otherwise the function will return None.
:param str query: Query that asks the user for a specific folder/fil... | entailment |
def register_view(self, view):
"""Called when the View was registered
"""
super(StateTransitionsListController, self).register_view(view)
def cell_text(column, cell_renderer, model, iter, data):
t_id = model.get_value(iter, self.ID_STORAGE_ID)
in_external = 'exte... | Called when the View was registered | entailment |
def remove_core_element(self, model):
"""Remove respective core element of handed transition model
:param TransitionModel model: Transition model which core element should be removed
:return:
"""
assert model.transition.parent is self.model.state or model.transition.parent is se... | Remove respective core element of handed transition model
:param TransitionModel model: Transition model which core element should be removed
:return: | entailment |
def get_possible_combos_for_transition(trans, model, self_model, is_external=False):
""" The function provides combos for a transition and its respective
:param trans:
:param model:
:param self_model:
:param is_external:
:return:
"""
from_state_combo = Gt... | The function provides combos for a transition and its respective
:param trans:
:param model:
:param self_model:
:param is_external:
:return: | entailment |
def _update_internal_data_base(self):
""" Updates Internal combo knowledge for any actual transition by calling get_possible_combos_for_transition-
function for those.
"""
model = self.model
# print("clean data base")
### FOR COMBOS
# internal transitions
... | Updates Internal combo knowledge for any actual transition by calling get_possible_combos_for_transition-
function for those. | entailment |
def _update_tree_store(self):
""" Updates TreeStore of the Gtk.ListView according internal combo knowledge gained by
_update_internal_data_base function call.
"""
self.list_store.clear()
if self.view_dict['transitions_internal'] and isinstance(self.model, ContainerStateModel) an... | Updates TreeStore of the Gtk.ListView according internal combo knowledge gained by
_update_internal_data_base function call. | entailment |
def register_actions(self, shortcut_manager):
"""Register callback methods for triggered actions
:param rafcon.gui.shortcut_manager.ShortcutManager shortcut_manager:
"""
shortcut_manager.add_callback_for_action("delete", self.trans_list_ctrl.remove_action_callback)
shortcut_mana... | Register callback methods for triggered actions
:param rafcon.gui.shortcut_manager.ShortcutManager shortcut_manager: | entailment |
def move_dirty_lock_file(dirty_lock_file, sm_path):
""" Move the dirt_lock file to the sm_path and thereby is not found by auto recovery of backup anymore """
if dirty_lock_file is not None \
and not dirty_lock_file == os.path.join(sm_path, dirty_lock_file.split(os.sep)[-1]):
logger.debug("M... | Move the dirt_lock file to the sm_path and thereby is not found by auto recovery of backup anymore | entailment |
def write_backup_meta_data(self):
"""Write the auto backup meta data into the current tmp-storage path"""
auto_backup_meta_file = os.path.join(self._tmp_storage_path, FILE_NAME_AUTO_BACKUP)
storage.storage_utils.write_dict_to_json(self.meta, auto_backup_meta_file) | Write the auto backup meta data into the current tmp-storage path | entailment |
def update_last_backup_meta_data(self):
"""Update the auto backup meta data with internal recovery information"""
self.meta['last_backup']['time'] = get_time_string_for_float(self.last_backup_time)
self.meta['last_backup']['file_system_path'] = self._tmp_storage_path
self.meta['last_back... | Update the auto backup meta data with internal recovery information | entailment |
def update_last_sm_origin_meta_data(self):
"""Update the auto backup meta data with information of the state machine origin"""
# TODO finally maybe remove this when all backup features are integrated into one backup-structure
# data also used e.g. to backup tabs
self.meta['last_saved']['... | Update the auto backup meta data with information of the state machine origin | entailment |
def _check_for_dyn_timed_auto_backup(self):
""" The method implements the timed storage feature.
The method re-initiating a new timed thread if the state-machine not already stored to backup
(what could be caused by the force_temp_storage_interval) or force the storing of the state-machine if... | The method implements the timed storage feature.
The method re-initiating a new timed thread if the state-machine not already stored to backup
(what could be caused by the force_temp_storage_interval) or force the storing of the state-machine if there
is no new request for a timed backup. Ne... | entailment |
def check_for_auto_backup(self, force=False):
""" The method implements the checks for possible auto backup of the state-machine according duration till
the last change together with the private method _check_for_dyn_timed_auto_backup.
If the only_fix_interval is True this function is called on... | The method implements the checks for possible auto backup of the state-machine according duration till
the last change together with the private method _check_for_dyn_timed_auto_backup.
If the only_fix_interval is True this function is called ones in the beginning and is called by a timed-
thre... | entailment |
def on_drag_data_get(self, widget, context, data, info, time):
"""dragged state is inserted and its state_id sent to the receiver
:param widget:
:param context:
:param data: SelectionData: contains state_id
:param info:
:param time:
"""
import rafcon.gui.... | dragged state is inserted and its state_id sent to the receiver
:param widget:
:param context:
:param data: SelectionData: contains state_id
:param info:
:param time: | entailment |
def on_mouse_click(self, widget, event):
"""state insertion on mouse click
:param widget:
:param Gdk.Event event: mouse click event
"""
import rafcon.gui.helpers.state_machine as gui_helper_state_machine
if self.view.get_path_at_pos(int(event.x), int(event.y)) is not Non... | state insertion on mouse click
:param widget:
:param Gdk.Event event: mouse click event | entailment |
def on_mouse_motion(self, widget, event):
"""selection on mouse over
:param widget:
:param Gdk.Event event: mouse motion event
"""
path = self.view.get_path_at_pos(int(event.x), int(event.y))
if path is not None:
self.view.select_path(path)
else:
... | selection on mouse over
:param widget:
:param Gdk.Event event: mouse motion event | entailment |
def _get_state(self):
"""get state instance which was clicked on
:return: State that represents the icon which was clicked on
:rtype: rafcon.core.states.State
"""
selected = self.view.get_selected_items()
if not selected:
return
shorthand, state_clas... | get state instance which was clicked on
:return: State that represents the icon which was clicked on
:rtype: rafcon.core.states.State | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.