idx
int64
0
63k
question
stringlengths
53
5.28k
target
stringlengths
5
805
40,200
def get_line_number_next_to_cursor_with_string_within ( self , s ) : line_number , _ = self . get_cursor_position ( ) text_buffer = self . text_view . get_buffer ( ) line_iter = text_buffer . get_iter_at_line ( line_number ) before_line_number = None while line_iter . backward_line ( ) : if s in self . get_text_of_line...
Find the closest occurrence of a string with respect to the cursor position in the text view
40,201
def set_variable ( self , key , value , per_reference = False , access_key = None , data_type = None ) : key = str ( key ) if self . variable_exist ( key ) : if data_type is None : data_type = self . __global_variable_type_dictionary [ key ] else : if data_type is None : data_type = type ( None ) assert isinstance ( da...
Sets a global variable
40,202
def get_variable ( self , key , per_reference = None , access_key = None , default = None ) : 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 = self . lock_variable ( key...
Fetches the value of a global variable
40,203
def variable_can_be_referenced ( self , key ) : key = str ( key ) return key in self . __variable_references and self . __variable_references [ key ]
Checks whether the value of the variable can be returned by reference
40,204
def delete_variable ( self , key ) : 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_variable_dictionary [ key ] sel...
Deletes a global variable
40,205
def lock_variable ( self , key , block = False ) : key = str ( key ) try : if key in self . __variable_locks : lock_successful = self . __variable_locks [ key ] . acquire ( False ) if lock_successful or block : if ( not lock_successful ) and block : duration = 0. loop_time = 0.1 while not self . __variable_locks [ key ...
Locks a global variable
40,206
def unlock_variable ( self , key , access_key , force = False ) : 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 ( "Global variable {} is not lock...
Unlocks a global variable
40,207
def set_locked_variable ( self , key , access_key , value ) : return self . set_variable ( key , value , per_reference = False , access_key = access_key )
Set an already locked global variable
40,208
def get_locked_variable ( self , key , access_key ) : return self . get_variable ( key , per_reference = False , access_key = access_key )
Returns the value of an global variable that is already locked
40,209
def is_locked ( self , key ) : key = str ( key ) if key in self . __variable_locks : return self . __variable_locks [ key ] . locked ( ) return False
Returns the status of the lock of a global variable
40,210
def global_variable_dictionary ( self ) : 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_copy
Property for the _global_variable_dictionary field
40,211
def check_value_and_type ( value , data_type ) : if value is not None and data_type is not type ( None ) : 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_type , type ( value ) ) )
Checks if a given value is of a specific type
40,212
def glue ( self , pos ) : 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 . y + self . height / 2. ) ) dist = sqrt ( dx * dx + dy * dy ) return self . po...
Calculates the distance between the given position and the port
40,213
def on_preliminary_config_changed ( self , config_m , prop_name , info ) : self . check_for_preliminary_config ( ) method_name = info [ 'method_name' ] if method_name in [ '__setitem__' , '__delitem__' ] : config_key = info [ 'args' ] [ 0 ] self . _handle_config_update ( config_m , config_key ) elif config_m is self . ...
Callback when a preliminary config value has been changed
40,214
def _handle_config_update ( self , config_m , config_key ) : 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 )
Handles changes in config values
40,215
def update_all ( self ) : 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 ( )
Shorthand method to update all collection information
40,216
def check_for_preliminary_config ( self ) : 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 )
Activates the Apply button if there are preliminary changes
40,217
def update_path_labels ( self ) : 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 ) )
Update labels showing config paths
40,218
def update_config_value ( self , config_m , config_key ) : 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_list_store...
Updates the corresponding list store of a changed config value
40,219
def _update_list_store_entry ( self , list_store , config_key , config_value ) : 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
Helper method to update a list store
40,220
def _update_list_store ( config_m , list_store , ignore_keys = None ) : 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 ) if is...
Generic method to create list store for a given config model
40,221
def update_libraries_list_store ( self ) : 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 [ lib...
Creates the list store for the libraries
40,222
def update_shortcut_settings ( self ) : 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 ...
Creates the list store for the shortcuts
40,223
def _select_row_by_column_value ( tree_view , list_store , column , value ) : for row_num , iter_elem in enumerate ( list_store ) : if iter_elem [ column ] == value : tree_view . set_cursor ( row_num ) return row_num
Helper method to select a tree view row
40,224
def _on_add_library ( self , * event ) : 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_confi...
Callback method handling the addition of a new library
40,225
def _on_remove_library ( self , * event ) : 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...
Callback method handling the removal of an existing library
40,226
def _on_checkbox_toggled ( self , renderer , path , config_m , config_list_store ) : 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 ( conf...
Callback method handling a config toggle event
40,227
def _on_import_config ( self , * args ) : def handle_import ( dialog_text , path_name ) : chooser = Gtk . FileChooserDialog ( dialog_text , None , Gtk . FileChooserAction . SAVE , ( Gtk . STOCK_CANCEL , Gtk . ResponseType . CANCEL , Gtk . STOCK_OPEN , Gtk . ResponseType . ACCEPT ) ) chooser . set_current_folder ( path_...
Callback method the the import button was clicked
40,228
def _on_export_config ( self , * args ) : 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 ) : chooser = Gtk . FileChooserDialog ( dialog_t...
Callback method the the export button was clicked
40,229
def _on_library_name_changed ( self , renderer , path , new_library_name ) : old_library_name = self . library_list_store [ int ( path ) ] [ self . KEY_STORAGE_ID ] if old_library_name == new_library_name : return library_path = self . library_list_store [ int ( path ) ] [ self . VALUE_STORAGE_ID ] library_config = sel...
Callback handling a change of a library name
40,230
def _on_library_path_changed ( self , renderer , path , new_library_path ) : library_name = self . library_list_store [ int ( path ) ] [ self . KEY_STORAGE_ID ] library_config = self . core_config_model . get_current_config_value ( "LIBRARY_PATHS" , use_preliminary = True , default = { } ) library_config [ library_name...
Callback handling a change of a library path
40,231
def _on_shortcut_changed ( self , renderer , path , new_shortcuts ) : action = self . shortcut_list_store [ int ( path ) ] [ self . KEY_STORAGE_ID ] old_shortcuts = self . gui_config_model . get_current_config_value ( "SHORTCUTS" , use_preliminary = True ) [ action ] from ast import literal_eval try : new_shortcuts = l...
Callback handling a change of a shortcut
40,232
def _on_config_value_changed ( self , renderer , path , new_value , config_m , list_store ) : config_key = list_store [ int ( path ) ] [ self . KEY_STORAGE_ID ] old_value = config_m . get_current_config_value ( config_key , use_preliminary = True ) if old_value == new_value : return if isinstance ( old_value , bool ) :...
Callback handling a change of a config value
40,233
def _config_chooser_dialog ( self , title_text , description ) : dialog = Gtk . Dialog ( title_text , self . view [ "preferences_window" ] , flags = 0 , buttons = ( Gtk . STOCK_CANCEL , Gtk . ResponseType . REJECT , Gtk . STOCK_OK , Gtk . ResponseType . ACCEPT ) ) label = Gtk . Label ( label = description ) label . set...
Dialog to select which config shall be exported
40,234
def remove_core_element ( self , model ) : assert model . data_flow . parent is self . model . state or model . data_flow . parent is self . model . parent . state gui_helper_state_machine . delete_core_element_of_model ( model )
Remove respective core element of handed data flow model
40,235
def start ( self ) : self . _root_state . input_data = self . _root_state . get_default_input_values_for_state ( self . _root_state ) self . _root_state . output_data = self . _root_state . create_output_dictionary_for_state ( self . _root_state ) new_execution_history = self . _add_new_execution_history ( ) new_execut...
Starts the execution of the root state .
40,236
def join ( self ) : self . _root_state . join ( ) if len ( self . _execution_histories ) > 0 : if self . _execution_histories [ - 1 ] . execution_history_storage is not None : set_read_and_writable_for_all = global_config . get_config_value ( "EXECUTION_LOG_SET_READ_AND_WRITABLE_FOR_ALL" , False ) self . _execution_his...
Wait for root state to finish execution
40,237
def _draw_container_state_port ( self , context , direction , color , transparency ) : c = context width , height = self . port_size c . set_line_width ( self . port_side_size / constants . BORDER_WIDTH_OUTLINE_WIDTH_FACTOR * self . _port_image_cache . multiplicator ) cur_point = c . get_current_point ( ) c . save ( ) ...
Draw the port of a container state
40,238
def _draw_single_connector ( context , width , height ) : c = context arrow_height = height / 2.0 c . rel_move_to ( - width / 2. , height / 2. ) c . rel_line_to ( width , 0 ) c . rel_line_to ( 0 , - ( height - arrow_height ) ) c . rel_line_to ( - width / 2. , - arrow_height ) c . rel_line_to ( - width / 2. , arrow_heig...
Draw the connector for execution states
40,239
def _draw_inner_connector ( context , width , height ) : c = context gap = height / 6. connector_height = ( height - gap ) / 2. c . rel_move_to ( - width / 2. , height / 2. ) c . rel_line_to ( width , 0 ) c . rel_line_to ( 0 , - connector_height ) c . rel_line_to ( - width , 0 ) c . close_path ( )
Draw the connector for container states
40,240
def _draw_outer_connector ( context , width , height ) : c = context arrow_height = height / 2.5 gap = height / 6. connector_height = ( height - gap ) / 2. c . rel_move_to ( - width / 2. , - gap / 2. ) c . rel_line_to ( width , 0 ) c . rel_line_to ( 0 , - ( connector_height - arrow_height ) ) c . rel_line_to ( - width ...
Draw the outer connector for container states
40,241
def _rotate_context ( context , direction ) : if direction is Direction . UP : pass elif direction is Direction . RIGHT : context . rotate ( deg2rad ( 90 ) ) elif direction is Direction . DOWN : context . rotate ( deg2rad ( 180 ) ) elif direction is Direction . LEFT : context . rotate ( deg2rad ( - 90 ) )
Moves the current position to position and rotates the context according to direction
40,242
def draw_name ( self , context , transparency , only_calculate_size = False ) : c = context cairo_context = c if isinstance ( c , CairoBoundingBoxContext ) : cairo_context = c . _cairo side_length = self . port_side_size layout = PangoCairo . create_layout ( cairo_context ) font_name = constants . INTERFACE_FONT font_s...
Draws the name of the port
40,243
def _draw_rectangle_path ( self , context , width , height , only_get_extents = False ) : c = context c . save ( ) if self . side is SnappedSide . LEFT or self . side is SnappedSide . RIGHT : c . rotate ( deg2rad ( 90 ) ) c . rel_move_to ( - width / 2. , - height / 2. ) c . rel_line_to ( width , 0 ) c . rel_line_to ( 0...
Draws the rectangle path for the port
40,244
def _get_port_center_position ( self , width ) : x , y = self . pos . x . value , self . pos . y . value if self . side is SnappedSide . TOP or self . side is SnappedSide . BOTTOM : if x - width / 2. < 0 : x = width / 2 elif x + width / 2. > self . parent . width : x = self . parent . width - width / 2. else : if y - w...
Calculates the center position of the port rectangle
40,245
def get_current_state_m ( self ) : page_id = self . view . notebook . get_current_page ( ) if page_id == - 1 : return None page = self . view . notebook . get_nth_page ( page_id ) state_identifier = self . get_state_identifier_for_page ( page ) return self . tabs [ state_identifier ] [ 'state_m' ]
Returns the state model of the currently open tab
40,246
def state_machine_manager_notification ( self , model , property , info ) : if self . current_state_machine_m is not None : selection = self . current_state_machine_m . selection if len ( selection . states ) > 0 : self . activate_state_tab ( selection . get_selected_state ( ) )
Triggered whenever a new state machine is created or an existing state machine is selected .
40,247
def clean_up_tabs ( self ) : tabs_to_close = [ ] for state_identifier , tab_dict in list ( self . tabs . items ( ) ) : if tab_dict [ 'sm_id' ] not in self . model . state_machine_manager . state_machines : tabs_to_close . append ( state_identifier ) for state_identifier , tab_dict in list ( self . closed_tabs . items (...
Method remove state - tabs for those no state machine exists anymore .
40,248
def state_machines_set_notification ( self , model , prop_name , info ) : if info [ 'method_name' ] == '__setitem__' : state_machine_m = info . args [ 1 ] self . observe_model ( state_machine_m )
Observe all open state machines and their root states
40,249
def state_machines_del_notification ( self , model , prop_name , info ) : if info [ 'method_name' ] == '__delitem__' : state_machine_m = info [ "result" ] try : self . relieve_model ( state_machine_m ) except KeyError : pass self . clean_up_tabs ( )
Relive models of closed state machine
40,250
def add_state_editor ( self , state_m ) : state_identifier = self . get_state_identifier ( state_m ) if state_identifier in self . closed_tabs : state_editor_ctrl = self . closed_tabs [ state_identifier ] [ 'controller' ] state_editor_view = state_editor_ctrl . view handler_id = self . closed_tabs [ state_identifier ] ...
Triggered whenever a state is selected .
40,251
def script_text_changed ( self , text_buffer , state_m ) : state_identifier = self . get_state_identifier ( state_m ) if state_identifier in self . tabs : tab_list = self . tabs elif state_identifier in self . closed_tabs : tab_list = self . closed_tabs else : logger . warning ( 'It was tried to check a source script o...
Update gui elements according text buffer changes
40,252
def destroy_page ( self , tab_dict ) : if tab_dict [ 'source_code_changed_handler_id' ] is not None : handler_id = tab_dict [ 'source_code_changed_handler_id' ] if tab_dict [ 'controller' ] . view . source_view . get_buffer ( ) . handler_is_connected ( handler_id ) : tab_dict [ 'controller' ] . view . source_view . get...
Destroys desired page
40,253
def close_page ( self , state_identifier , delete = True ) : if delete and state_identifier in self . closed_tabs : self . destroy_page ( self . closed_tabs [ state_identifier ] ) del self . closed_tabs [ state_identifier ] if state_identifier in self . tabs : page_to_close = self . tabs [ state_identifier ] [ 'page' ]...
Closes the desired page
40,254
def find_page_of_state_m ( self , state_m ) : for state_identifier , page_info in list ( self . tabs . items ( ) ) : if page_info [ 'state_m' ] is state_m : return page_info [ 'page' ] , state_identifier return None , None
Return the identifier and page of a given state model
40,255
def on_tab_close_clicked ( self , event , state_m ) : [ page , state_identifier ] = self . find_page_of_state_m ( state_m ) if page : self . close_page ( state_identifier , delete = False )
Triggered when the states - editor close button is clicked
40,256
def on_toggle_sticky_clicked ( self , event , state_m ) : [ page , state_identifier ] = self . find_page_of_state_m ( state_m ) if not page : return self . tabs [ state_identifier ] [ 'is_sticky' ] = not self . tabs [ state_identifier ] [ 'is_sticky' ] page . sticky_button . set_active ( self . tabs [ state_identifier ...
Callback for the toggle - sticky - check - button emitted by custom TabLabel widget .
40,257
def close_all_pages ( self ) : states_to_be_closed = [ ] for state_identifier in self . tabs : states_to_be_closed . append ( state_identifier ) for state_identifier in states_to_be_closed : self . close_page ( state_identifier , delete = False )
Closes all tabs of the states editor
40,258
def close_pages_for_specific_sm_id ( self , sm_id ) : states_to_be_closed = [ ] for state_identifier in self . tabs : state_m = self . tabs [ state_identifier ] [ "state_m" ] if state_m . state . get_state_machine ( ) . state_machine_id == sm_id : states_to_be_closed . append ( state_identifier ) for state_identifier i...
Closes all tabs of the states editor for a specific sm_id
40,259
def on_switch_page ( self , notebook , page_pointer , page_num , user_param1 = None ) : page = notebook . get_nth_page ( page_num ) for tab_info in list ( self . tabs . values ( ) ) : if tab_info [ 'page' ] is page : state_m = tab_info [ 'state_m' ] sm_id = state_m . state . get_state_machine ( ) . state_machine_id sel...
Update state selection when the active tab was changed
40,260
def activate_state_tab ( self , state_m ) : current_state_m = self . get_current_state_m ( ) if current_state_m is not state_m : state_identifier = self . get_state_identifier ( state_m ) if state_identifier not in self . tabs : page_id = self . add_state_editor ( state_m ) self . view . notebook . set_current_page ( p...
Opens the tab for the specified state model
40,261
def keep_only_sticked_and_selected_tabs ( self ) : if not global_gui_config . get_config_value ( 'KEEP_ONLY_STICKY_STATES_OPEN' , True ) : return page_id = self . view . notebook . get_current_page ( ) if page_id == - 1 : return page = self . view . notebook . get_nth_page ( page_id ) current_state_identifier = self . ...
Close all tabs except the currently active one and all sticked ones
40,262
def selection_notification ( self , model , property , info ) : if model is not self . current_state_machine_m or len ( self . current_state_machine_m . ongoing_complex_actions ) > 0 : return state_machine_m = model assert isinstance ( state_machine_m . selection , Selection ) if len ( state_machine_m . selection . sta...
If a single state is selected open the corresponding tab
40,263
def notify_state_name_change ( self , model , prop_name , info ) : if is_execution_status_update_notification_from_state_machine_model ( prop_name , info ) : return overview = NotificationOverview ( info , False , self . __class__ . __name__ ) changed_model = overview [ 'model' ] [ - 1 ] method_name = overview [ 'metho...
Checks whether the name of a state was changed and change the tab label accordingly
40,264
def update_tab_label ( self , state_m ) : state_identifier = self . get_state_identifier ( state_m ) if state_identifier not in self . tabs and state_identifier not in self . closed_tabs : return tab_info = self . tabs [ state_identifier ] if state_identifier in self . tabs else self . closed_tabs [ state_identifier ] ...
Update all tab labels
40,265
def get_state_identifier_for_page ( self , page ) : for identifier , page_info in list ( self . tabs . items ( ) ) : if page_info [ "page" ] is page : return identifier
Return the state identifier for a given page
40,266
def rename_selected_state ( self , key_value , modifier_mask ) : selection = self . current_state_machine_m . selection if len ( selection . states ) == 1 and len ( selection ) == 1 : selected_state = selection . get_selected_state ( ) self . activate_state_tab ( selected_state ) _ , state_identifier = self . find_page...
Callback method for shortcut action rename
40,267
def generate_semantic_data_key ( used_semantic_keys ) : semantic_data_id_counter = - 1 while True : semantic_data_id_counter += 1 if "semantic data key " + str ( semantic_data_id_counter ) not in used_semantic_keys : break return "semantic data key " + str ( semantic_data_id_counter )
Create a new and unique semantic data key
40,268
def state_id_generator ( size = STATE_ID_LENGTH , chars = string . ascii_uppercase , used_state_ids = None ) : new_state_id = '' . join ( random . choice ( chars ) for x in range ( size ) ) while used_state_ids is not None and new_state_id in used_state_ids : new_state_id = '' . join ( random . choice ( chars ) for x i...
Create a new and unique state id
40,269
def global_variable_id_generator ( size = 10 , chars = string . ascii_uppercase ) : new_global_variable_id = '' . join ( random . choice ( chars ) for x in range ( size ) ) while new_global_variable_id in used_global_variable_ids : new_global_variable_id = '' . join ( random . choice ( chars ) for x in range ( size ) )...
Create a new and unique global variable id
40,270
def set ( self ) : glColor4f ( self . r , self . g , self . b , self . a )
Set the color as current OpenGL color
40,271
def pixel_to_size_ratio ( self ) : left , right , _ , _ = self . get_view_coordinates ( ) width = right - left display_width = self . get_allocation ( ) . width return display_width / float ( width )
Calculates the ratio between pixel and OpenGL distances
40,272
def expose_init ( self , * args ) : gldrawable = self . get_gl_drawable ( ) glcontext = self . get_gl_context ( ) if not gldrawable or not gldrawable . gl_begin ( glcontext ) : return False glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) glInitNames ( ) glPushName ( 0 ) self . name_counter = 1 return False
Process the drawing routine
40,273
def expose_finish ( self , * args ) : gldrawable = self . get_gl_drawable ( ) if not gldrawable : return if gldrawable . is_double_buffered ( ) : gldrawable . swap_buffers ( ) else : glFlush ( ) gldrawable . gl_end ( )
Finish drawing process
40,274
def _write_string ( self , string , pos_x , pos_y , height , color , bold = False , align_right = False , depth = 0. ) : stroke_width = height / 8. if bold : stroke_width = height / 5. color . set ( ) self . _set_closest_stroke_width ( stroke_width ) glMatrixMode ( GL_MODELVIEW ) glPushMatrix ( ) pos_y -= height if not...
Write a string
40,275
def prepare_selection ( self , pos_x , pos_y , width , height ) : glSelectBuffer ( self . name_counter * 6 ) viewport = glGetInteger ( GL_VIEWPORT ) glMatrixMode ( GL_PROJECTION ) glPushMatrix ( ) glRenderMode ( GL_SELECT ) glLoadIdentity ( ) if width < 1 : width = 1 if height < 1 : height = 1 pos_x += width / 2. pos_y...
Prepares the selection rendering
40,276
def find_selection ( ) : hits = glRenderMode ( GL_RENDER ) glMatrixMode ( GL_PROJECTION ) glPopMatrix ( ) glMatrixMode ( GL_MODELVIEW ) return hits
Finds the selected ids
40,277
def _set_closest_stroke_width ( self , width ) : width *= self . pixel_to_size_ratio ( ) / 6. stroke_width_range = glGetFloatv ( GL_LINE_WIDTH_RANGE ) stroke_width_granularity = glGetFloatv ( GL_LINE_WIDTH_GRANULARITY ) if width < stroke_width_range [ 0 ] : glLineWidth ( stroke_width_range [ 0 ] ) return if width > str...
Sets the line width to the closest supported one
40,278
def _draw_circle ( self , pos_x , pos_y , radius , depth , stroke_width = 1. , fill_color = None , border_color = None , from_angle = 0. , to_angle = 2 * pi ) : visible = False if not self . point_outside_view ( ( pos_x , pos_y ) ) : visible = True if not visible : for i in range ( 0 , 8 ) : angle = 2 * pi / 8. * i x =...
Draws a circle
40,279
def _apply_orthogonal_view ( self ) : left , right , bottom , top = self . get_view_coordinates ( ) glOrtho ( left , right , bottom , top , - 10 , 0 )
Orthogonal view with respect to current aspect ratio
40,280
def update_data_frames ( network , cluster_weights , dates , hours ) : network . snapshot_weightings = network . snapshot_weightings . loc [ dates ] network . snapshots = network . snapshot_weightings . index snapshot_weightings = [ ] for i in cluster_weights . values ( ) : x = 0 while x < hours : snapshot_weightings ....
Updates the snapshots snapshots weights and the dataframes based on the original data in the network and the medoids created by clustering these original data .
40,281
def daily_bounds ( network , snapshots ) : sus = network . storage_units network . model . period_starts = network . snapshot_weightings . index [ 0 : : 24 ] network . model . storages = sus . index def day_rule ( m , s , p ) : return ( m . state_of_charge [ s , p ] == m . state_of_charge [ s , p + pd . Timedelta ( hou...
This will bound the storage level to 0 . 5 max_level every 24th hour .
40,282
def on_add ( self , widget , data = None ) : if isinstance ( self . model , ContainerStateModel ) : try : scoped_var_ids = gui_helper_state_machine . add_scoped_variable_to_selected_states ( selected_states = [ self . model ] ) if scoped_var_ids : self . select_entry ( scoped_var_ids [ self . model . state ] ) except V...
Create a new scoped variable with default values
40,283
def remove_core_element ( self , model ) : assert model . scoped_variable . parent is self . model . state gui_helper_state_machine . delete_core_element_of_model ( model )
Remove respective core element of handed scoped variable model
40,284
def apply_new_scoped_variable_name ( self , path , new_name ) : data_port_id = self . list_store [ path ] [ self . ID_STORAGE_ID ] try : if self . model . state . scoped_variables [ data_port_id ] . name != new_name : self . model . state . scoped_variables [ data_port_id ] . name = new_name except TypeError as e : log...
Applies the new name of the scoped variable defined by path
40,285
def apply_new_scoped_variable_type ( self , path , new_variable_type_str ) : data_port_id = self . list_store [ path ] [ self . ID_STORAGE_ID ] try : if self . model . state . scoped_variables [ data_port_id ] . data_type . __name__ != new_variable_type_str : self . model . state . scoped_variables [ data_port_id ] . c...
Applies the new data type of the scoped variable defined by path
40,286
def apply_new_scoped_variable_default_value ( self , path , new_default_value_str ) : data_port_id = self . get_list_store_row_from_cursor_selection ( ) [ self . ID_STORAGE_ID ] try : if str ( self . model . state . scoped_variables [ data_port_id ] . default_value ) != new_default_value_str : self . model . state . sc...
Applies the new default value of the scoped variable defined by path
40,287
def reload_scoped_variables_list_store ( self ) : if isinstance ( self . model , ContainerStateModel ) : tmp = self . get_new_list_store ( ) for sv_model in self . model . scoped_variables : data_type = sv_model . scoped_variable . data_type data_type_name = data_type . __name__ data_type_module = data_type . __module_...
Reloads the scoped variable list store from the data port models
40,288
def store_session ( ) : from rafcon . gui . singleton import state_machine_manager_model , global_runtime_config from rafcon . gui . models . auto_backup import AutoBackupModel from rafcon . gui . models import AbstractStateModel from rafcon . gui . singleton import main_window_controller for sm_m in state_machine_mana...
Stores reference backup information for all open tabs into runtime config
40,289
def add_logging_level ( level_name , level_num , method_name = None ) : if not method_name : method_name = level_name . lower ( ) if hasattr ( logging , level_name ) : raise AttributeError ( '{} already defined in logging module' . format ( level_name ) ) if hasattr ( logging , method_name ) : raise AttributeError ( '{...
Add new logging level
40,290
def get_logger ( name ) : if name in existing_loggers : return existing_loggers [ name ] namespace = name if name . startswith ( rafcon_root + "." ) else rafcon_root + "." + name logger = logging . getLogger ( namespace ) logger . propagate = True existing_loggers [ name ] = logger return logger
Returns a logger for the given name
40,291
def open_state_machine ( path = None , recent_opened_notification = False ) : start_time = time . time ( ) if path is None : if interface . open_folder_func is None : logger . error ( "No function defined for opening a folder" ) return load_path = interface . open_folder_func ( "Please choose the folder of the state ma...
Open a state machine from respective file system path
40,292
def save_state_machine ( delete_old_state_machine = False , recent_opened_notification = False , as_copy = False , copy_path = None ) : state_machine_manager_model = rafcon . gui . singleton . state_machine_manager_model states_editor_ctrl = rafcon . gui . singleton . main_window_controller . get_controller ( 'states_e...
Save selected state machine
40,293
def save_state_machine_as ( path = None , recent_opened_notification = False , as_copy = False ) : state_machine_manager_model = rafcon . gui . singleton . state_machine_manager_model selected_state_machine_model = state_machine_manager_model . get_selected_state_machine_model ( ) if selected_state_machine_model is Non...
Store selected state machine to path
40,294
def is_state_machine_stopped_to_proceed ( selected_sm_id = None , root_window = None ) : if not state_machine_execution_engine . finished_or_stopped ( ) : if selected_sm_id is None or selected_sm_id == state_machine_manager . active_state_machine_id : message_string = "A state machine is still running. This state machi...
Check if state machine is stopped and in case request user by dialog how to proceed
40,295
def refresh_selected_state_machine ( ) : selected_sm_id = rafcon . gui . singleton . state_machine_manager_model . selected_state_machine_id selected_sm = state_machine_manager . state_machines [ selected_sm_id ] state_machines_editor_ctrl = rafcon . gui . singleton . main_window_controller . get_controller ( 'state_ma...
Reloads the selected state machine .
40,296
def delete_core_element_of_model ( model , raise_exceptions = False , recursive = True , destroy = True , force = False ) : if isinstance ( model , AbstractStateModel ) and model . state . is_root_state : logger . warning ( "Deletion is not allowed. {0} is root state of state machine." . format ( model . core_element )...
Deletes respective core element of handed model of its state machine
40,297
def delete_core_elements_of_models ( models , raise_exceptions = True , recursive = True , destroy = True , force = False ) : if not hasattr ( models , '__iter__' ) : models = [ models ] return sum ( delete_core_element_of_model ( model , raise_exceptions , recursive = recursive , destroy = destroy , force = force ) fo...
Deletes all respective core elements for the given models
40,298
def is_selection_inside_of_library_state ( state_machine_m = None , selected_elements = None ) : if state_machine_m is None : state_machine_m = rafcon . gui . singleton . state_machine_manager_model . get_selected_state_machine_model ( ) if state_machine_m is None and selected_elements is None : return False selection_...
Check if handed or selected elements are inside of library state
40,299
def insert_state_into_selected_state ( state , as_template = False ) : smm_m = rafcon . gui . singleton . state_machine_manager_model if not isinstance ( state , State ) : logger . warning ( "A state is needed to be insert not {0}" . format ( state ) ) return False if not smm_m . selected_state_machine_id : logger . wa...
Adds a State to the selected state