idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
42,300 | def delete_cell ( self , key ) : try : self . code_array . pop ( key ) except KeyError : pass self . grid . code_array . result_cache . clear ( ) | Deletes key cell |
42,301 | def append_reference_code ( self , key , ref_key , ref_type = "absolute" ) : if ref_type == "absolute" : code = self . _get_absolute_reference ( ref_key ) elif ref_type == "relative" : code = self . _get_relative_reference ( key , ref_key ) else : raise ValueError ( _ ( 'ref_type has to be "absolute" or "relative".' ) ) old_code = self . grid . code_array ( key ) if old_code is None : old_code = u"" if "S" in old_code and old_code [ - 1 ] == "]" : old_code_left , __ = old_code . rsplit ( "S" , 1 ) new_code = old_code_left + code else : new_code = old_code + code post_command_event ( self . grid . main_window , self . EntryLineMsg , text = new_code ) return new_code | Appends reference code to cell code . |
42,302 | def _set_cell_attr ( self , selection , table , attr ) : post_command_event ( self . main_window , self . ContentChangedMsg ) if selection is not None : self . code_array . cell_attributes . append ( ( selection , table , attr ) ) | Sets cell attr for key cell and mark grid content as changed |
42,303 | def set_attr ( self , attr , value , selection = None ) : if selection is None : selection = self . grid . selection if not selection : selection . cells . append ( self . grid . actions . cursor [ : 2 ] ) attrs = { attr : value } table = self . grid . current_table self . _set_cell_attr ( selection , table , attrs ) | Sets attr of current selection to value |
42,304 | def set_border_attr ( self , attr , value , borders ) : selection = self . grid . selection if not selection : selection . cells . append ( self . grid . actions . cursor [ : 2 ] ) if "inner" in borders : if "top" in borders : adj_selection = selection + ( - 1 , 0 ) self . set_attr ( attr + "_bottom" , value , adj_selection ) if "bottom" in borders : self . set_attr ( attr + "_bottom" , value ) if "left" in borders : adj_selection = selection + ( 0 , - 1 ) self . set_attr ( attr + "_right" , value , adj_selection ) if "right" in borders : self . set_attr ( attr + "_right" , value ) else : bbox_tl , bbox_lr = selection . get_bbox ( ) if "top" in borders : adj_selection = Selection ( [ bbox_tl ] , [ ( bbox_tl [ 0 ] , bbox_lr [ 1 ] ) ] , [ ] , [ ] , [ ] ) + ( - 1 , 0 ) self . set_attr ( attr + "_bottom" , value , adj_selection ) if "bottom" in borders : adj_selection = Selection ( [ ( bbox_lr [ 0 ] , bbox_tl [ 1 ] ) ] , [ bbox_lr ] , [ ] , [ ] , [ ] ) self . set_attr ( attr + "_bottom" , value , adj_selection ) if "left" in borders : adj_selection = Selection ( [ bbox_tl ] , [ ( bbox_lr [ 0 ] , bbox_tl [ 1 ] ) ] , [ ] , [ ] , [ ] ) + ( 0 , - 1 ) self . set_attr ( attr + "_right" , value , adj_selection ) if "right" in borders : adj_selection = Selection ( [ ( bbox_tl [ 0 ] , bbox_lr [ 1 ] ) ] , [ bbox_lr ] , [ ] , [ ] , [ ] ) self . set_attr ( attr + "_right" , value , adj_selection ) | Sets border attribute by adjusting selection to borders |
42,305 | def toggle_attr ( self , attr ) : selection = self . grid . selection if selection : value = self . get_new_selection_attr_state ( selection , attr ) else : value = self . get_new_cell_attr_state ( self . grid . actions . cursor , attr ) self . set_attr ( attr , value ) | Toggles an attribute attr for current selection |
42,306 | def change_frozen_attr ( self ) : if self . grid . selection : statustext = _ ( "Freezing selections is not supported." ) post_command_event ( self . main_window , self . StatusBarMsg , text = statustext ) cursor = self . grid . actions . cursor frozen = self . grid . code_array . cell_attributes [ cursor ] [ "frozen" ] if frozen : self . grid . code_array . frozen_cache . pop ( repr ( cursor ) ) else : res_obj = self . grid . code_array [ cursor ] self . grid . code_array . frozen_cache [ repr ( cursor ) ] = res_obj selection = Selection ( [ ] , [ ] , [ ] , [ ] , [ cursor [ : 2 ] ] ) self . set_attr ( "frozen" , not frozen , selection = selection ) | Changes frozen state of cell if there is no selection |
42,307 | def unmerge ( self , unmerge_area , tab ) : top , left , bottom , right = unmerge_area selection = Selection ( [ ( top , left ) ] , [ ( bottom , right ) ] , [ ] , [ ] , [ ] ) attr = { "merge_area" : None , "locked" : False } self . _set_cell_attr ( selection , tab , attr ) | Unmerges all cells in unmerge_area |
42,308 | def merge ( self , merge_area , tab ) : top , left , bottom , right = merge_area cursor = self . grid . actions . cursor top_left_code = self . code_array ( ( top , left , cursor [ 2 ] ) ) selection = Selection ( [ ( top , left ) ] , [ ( bottom , right ) ] , [ ] , [ ] , [ ] ) error_msg = _ ( "Overlapping merge area at {} prevents merge." ) for row in xrange ( top , bottom + 1 ) : for col in xrange ( left , right + 1 ) : key = row , col , tab if self . code_array . cell_attributes [ key ] [ "merge_area" ] : post_command_event ( self . main_window , self . StatusBarMsg , text = error_msg . format ( str ( key ) ) ) return self . delete_selection ( selection ) self . set_code ( ( top , left , cursor [ 2 ] ) , top_left_code ) attr = { "merge_area" : merge_area , "locked" : True } self . _set_cell_attr ( selection , tab , attr ) tl_selection = Selection ( [ ] , [ ] , [ ] , [ ] , [ ( top , left ) ] ) attr = { "locked" : False } self . _set_cell_attr ( tl_selection , tab , attr ) | Merges top left cell with all cells until bottom_right |
42,309 | def merge_selected_cells ( self , selection ) : tab = self . grid . current_table bbox = selection . get_bbox ( ) if bbox is None : row , col , tab = self . grid . actions . cursor ( bb_top , bb_left ) , ( bb_bottom , bb_right ) = ( row , col ) , ( row , col ) else : ( bb_top , bb_left ) , ( bb_bottom , bb_right ) = bbox merge_area = bb_top , bb_left , bb_bottom , bb_right cell_attributes = self . grid . code_array . cell_attributes tl_merge_area = cell_attributes [ ( bb_top , bb_left , tab ) ] [ "merge_area" ] if tl_merge_area is not None and tl_merge_area [ : 2 ] == merge_area [ : 2 ] : self . unmerge ( tl_merge_area , tab ) else : self . merge ( merge_area , tab ) | Merges or unmerges cells that are in the selection bounding box |
42,310 | def get_new_cell_attr_state ( self , key , attr_key ) : cell_attributes = self . grid . code_array . cell_attributes attr_values = self . attr_toggle_values [ attr_key ] attr_map = dict ( zip ( attr_values , attr_values [ 1 : ] + attr_values [ : 1 ] ) ) return attr_map [ cell_attributes [ key ] [ attr_key ] ] | Returns new attr cell state for toggles |
42,311 | def get_new_selection_attr_state ( self , selection , attr_key ) : cell_attributes = self . grid . code_array . cell_attributes attr_values = self . attr_toggle_values [ attr_key ] attr_map = dict ( zip ( attr_values , attr_values [ 1 : ] + attr_values [ : 1 ] ) ) selection_attrs = ( attr for attr in cell_attributes if attr [ 0 ] == selection ) attrs = { } for selection_attr in selection_attrs : attrs . update ( selection_attr [ 2 ] ) if attr_key in attrs : return attr_map [ attrs [ attr_key ] ] else : return self . attr_toggle_values [ attr_key ] [ 1 ] | Toggles new attr selection state and returns it |
42,312 | def refresh_frozen_cell ( self , key ) : code = self . grid . code_array ( key ) result = self . grid . code_array . _eval_cell ( key , code ) self . grid . code_array . frozen_cache [ repr ( key ) ] = result | Refreshes a frozen cell |
42,313 | def refresh_selected_frozen_cells ( self , selection = None ) : if selection is None : selection = self . grid . selection if not selection : selection . cells . append ( self . grid . actions . cursor [ : 2 ] ) cell_attributes = self . grid . code_array . cell_attributes refreshed_keys = [ ] for attr_selection , tab , attr_dict in cell_attributes : if tab == self . grid . actions . cursor [ 2 ] and "frozen" in attr_dict and attr_dict [ "frozen" ] : skey = attr_selection . cells [ 0 ] if skey in selection : key = tuple ( list ( skey ) + [ tab ] ) if key not in refreshed_keys and cell_attributes [ key ] [ "frozen" ] : self . refresh_frozen_cell ( key ) refreshed_keys . append ( key ) cell_attributes . _attr_cache . clear ( ) cell_attributes . _table_cache . clear ( ) | Refreshes content of frozen cells that are currently selected |
42,314 | def _import_csv ( self , path ) : if not path : return try : dialect , has_header , digest_types , encoding = self . main_window . interfaces . get_csv_import_info ( path ) except IOError : msg = _ ( "Error opening file {filepath}." ) . format ( filepath = path ) post_command_event ( self . main_window , self . StatusBarMsg , text = msg ) return except TypeError : return return CsvInterface ( self . main_window , path , dialect , digest_types , has_header , encoding ) | CSV import workflow |
42,315 | def import_file ( self , filepath , filterindex ) : post_command_event ( self . main_window , self . ContentChangedMsg ) if filterindex == 0 : return self . _import_csv ( filepath ) elif filterindex == 1 : return self . _import_txt ( filepath ) else : msg = _ ( "Unknown import choice {choice}." ) msg = msg . format ( choice = filterindex ) short_msg = _ ( 'Error reading CSV file' ) self . main_window . interfaces . display_warning ( msg , short_msg ) | Imports external file |
42,316 | def _export_csv ( self , filepath , data , preview_data ) : csv_info = self . main_window . interfaces . get_csv_export_info ( preview_data ) if csv_info is None : return try : dialect , digest_types , has_header = csv_info except TypeError : return csv_interface = CsvInterface ( self . main_window , filepath , dialect , digest_types , has_header ) try : csv_interface . write ( data ) except IOError , err : msg = _ ( "The file {filepath} could not be fully written\n \n" "Error message:\n{msg}" ) msg = msg . format ( filepath = filepath , msg = err ) short_msg = _ ( 'Error writing CSV file' ) self . main_window . interfaces . display_warning ( msg , short_msg ) | CSV export of code_array results |
42,317 | def _export_figure ( self , filepath , data , format ) : formats = [ "svg" , "eps" , "ps" , "pdf" , "png" ] assert format in formats data = fig2x ( data , format ) try : outfile = open ( filepath , "wb" ) outfile . write ( data ) except IOError , err : msg = _ ( "The file {filepath} could not be fully written\n \n" "Error message:\n{msg}" ) msg = msg . format ( filepath = filepath , msg = err ) short_msg = _ ( 'Error writing SVG file' ) self . main_window . interfaces . display_warning ( msg , short_msg ) finally : outfile . close ( ) | Export of single cell that contains a matplotlib figure |
42,318 | def export_file ( self , filepath , __filter , data , preview_data = None ) : if __filter . startswith ( "cell_" ) : self . _export_figure ( filepath , data , __filter [ 5 : ] ) elif __filter == "csv" : self . _export_csv ( filepath , data , preview_data = preview_data ) elif __filter in [ "pdf" , "svg" ] : self . export_cairo ( filepath , __filter ) | Export data for other applications |
42,319 | def get_print_rect ( self , grid_rect ) : grid = self . grid rect_x = grid_rect . x - grid . GetScrollPos ( wx . HORIZONTAL ) * grid . GetScrollLineX ( ) rect_y = grid_rect . y - grid . GetScrollPos ( wx . VERTICAL ) * grid . GetScrollLineY ( ) return wx . Rect ( rect_x , rect_y , grid_rect . width , grid_rect . height ) | Returns wx . Rect that is correctly positioned on the print canvas |
42,320 | def export_cairo ( self , filepath , filetype ) : if cairo is None : return export_info = self . main_window . interfaces . get_cairo_export_info ( filetype ) if export_info is None : return top_row = max ( 0 , export_info [ "top_row" ] ) bottom_row = min ( self . grid . code_array . shape [ 0 ] - 1 , export_info [ "bottom_row" ] ) left_col = max ( 0 , export_info [ "left_col" ] ) right_col = min ( self . grid . code_array . shape [ 1 ] - 1 , export_info [ "right_col" ] ) first_tab = max ( 0 , export_info [ "first_tab" ] ) last_tab = min ( self . grid . code_array . shape [ 2 ] - 1 , export_info [ "last_tab" ] ) width = export_info [ "paper_width" ] height = export_info [ "paper_height" ] orientation = export_info [ "orientation" ] if orientation == "landscape" : width , height = height , width if filetype == "pdf" : surface = cairo . PDFSurface ( filepath , width , height ) elif filetype == "svg" : surface = cairo . SVGSurface ( filepath , width , height ) else : msg = "Export filetype {filtype} not supported." . format ( filetype = filetype ) raise ValueError ( msg ) context = cairo . Context ( surface ) grid_cairo_renderer = GridCairoRenderer ( context , self . code_array , ( top_row , bottom_row + 1 ) , ( left_col , right_col + 1 ) , ( first_tab , last_tab + 1 ) , width , height , orientation , view_frozen = self . grid . _view_frozen , ) grid_cairo_renderer . draw ( ) surface . finish ( ) | Exports grid to the PDF file filepath |
42,321 | def print_preview ( self , print_area , print_data ) : if cairo is None : return print_info = self . main_window . interfaces . get_cairo_export_info ( "Print" ) if print_info is None : return printout_preview = Printout ( self . grid , print_data , print_info ) printout_printing = Printout ( self . grid , print_data , print_info ) preview = wx . PrintPreview ( printout_preview , printout_printing , print_data ) if not preview . Ok ( ) : return pfrm = wx . PreviewFrame ( preview , self . main_window , _ ( "Print preview" ) ) pfrm . Initialize ( ) pfrm . SetPosition ( self . main_window . GetPosition ( ) ) pfrm . SetSize ( self . main_window . GetSize ( ) ) pfrm . Show ( True ) | Launch print preview |
42,322 | def printout ( self , print_area , print_data ) : print_info = self . main_window . interfaces . get_cairo_export_info ( "Print" ) if print_info is None : return pdd = wx . PrintDialogData ( print_data ) printer = wx . Printer ( pdd ) printout = Printout ( self . grid , print_data , print_info ) if printer . Print ( self . main_window , printout , True ) : self . print_data = wx . PrintData ( printer . GetPrintDialogData ( ) . GetPrintData ( ) ) printout . Destroy ( ) | Print out print area |
42,323 | def copy ( self , selection , getter = None , delete = False ) : if getter is None : getter = self . _get_code tab = self . grid . current_table selection_bbox = selection . get_bbox ( ) if not selection_bbox : bb_top , bb_left = self . grid . actions . cursor [ : 2 ] bb_bottom , bb_right = bb_top , bb_left else : replace_none = self . main_window . grid . actions . _replace_bbox_none ( bb_top , bb_left ) , ( bb_bottom , bb_right ) = replace_none ( selection . get_bbox ( ) ) data = [ ] for __row in xrange ( bb_top , bb_bottom + 1 ) : data . append ( [ ] ) for __col in xrange ( bb_left , bb_right + 1 ) : if ( __row , __col ) in selection or not selection_bbox : content = getter ( ( __row , __col , tab ) ) if delete : try : self . grid . code_array . pop ( ( __row , __col , tab ) ) except KeyError : pass if content is None : data [ - 1 ] . append ( u"" ) else : data [ - 1 ] . append ( content ) else : data [ - 1 ] . append ( u"" ) return "\n" . join ( "\t" . join ( line ) for line in data ) | Returns code from selection in a tab separated string |
42,324 | def img2code ( self , key , img ) : code_template = "wx.ImageFromData({width}, {height}, " + "bz2.decompress(base64.b64decode('{data}'))).ConvertToBitmap()" code_alpha_template = "wx.ImageFromDataWithAlpha({width}, {height}, " + "bz2.decompress(base64.b64decode('{data}')), " + "bz2.decompress(base64.b64decode('{alpha}'))).ConvertToBitmap()" data = base64 . b64encode ( bz2 . compress ( img . GetData ( ) , 9 ) ) if img . HasAlpha ( ) : alpha = base64 . b64encode ( bz2 . compress ( img . GetAlphaData ( ) , 9 ) ) code_str = code_alpha_template . format ( width = img . GetWidth ( ) , height = img . GetHeight ( ) , data = data , alpha = alpha ) else : code_str = code_template . format ( width = img . GetWidth ( ) , height = img . GetHeight ( ) , data = data ) return code_str | Pastes wx . Image into single cell |
42,325 | def _get_paste_data_gen ( self , key , data ) : if type ( data ) is wx . _gdi . Bitmap : code_str = self . bmp2code ( key , data ) return [ [ code_str ] ] else : return ( line . split ( "\t" ) for line in data . split ( "\n" ) ) | Generator for paste data |
42,326 | def paste ( self , key , data ) : data_gen = self . _get_paste_data_gen ( key , data ) self . grid . actions . paste ( key [ : 2 ] , data_gen , freq = 1000 ) self . main_window . grid . ForceRefresh ( ) | Pastes data into grid |
42,327 | def _get_pasteas_data ( self , dim , obj ) : if dim == 0 : return [ [ repr ( obj ) ] ] elif dim == 1 : return [ [ repr ( o ) ] for o in obj ] elif dim == 2 : return [ map ( repr , o ) for o in obj ] | Returns list of lists of obj than has dimensionality dim |
42,328 | def paste_as ( self , key , data ) : def error_msg ( err ) : msg = _ ( "Error evaluating data: " ) + str ( err ) post_command_event ( self . main_window , self . StatusBarMsg , text = msg ) interfaces = self . main_window . interfaces key = self . main_window . grid . actions . cursor try : obj = ast . literal_eval ( data ) except ( SyntaxError , AttributeError ) : try : obj = [ map ( ast . literal_eval , line . split ( "\t" ) ) for line in data . split ( "\n" ) ] except Exception , err : try : obj = [ line . split ( '\t' ) for line in data . split ( '\n' ) ] except Exception , err : error_msg ( err ) return except ValueError , err : error_msg ( err ) return parameters = interfaces . get_pasteas_parameters_from_user ( obj ) if parameters is None : return paste_data = self . _get_pasteas_data ( parameters [ "dim" ] , obj ) if parameters [ "transpose" ] : paste_data = zip ( * paste_data ) self . main_window . grid . actions . paste ( key , paste_data , freq = 1000 ) | Paste and transform data |
42,329 | def execute_macros ( self ) : post_command_event ( self . main_window , self . ContentChangedMsg ) ( result , err ) = self . grid . code_array . execute_macros ( ) post_command_event ( self . main_window , self . MacroErrorMsg , msg = result , err = err ) | Executes macros and marks grid as changed |
42,330 | def open_macros ( self , filepath ) : try : wx . BeginBusyCursor ( ) self . main_window . grid . Disable ( ) with open ( filepath ) as macro_infile : self . main_window . grid . actions . enter_safe_mode ( ) post_command_event ( self . main_window , self . SafeModeEntryMsg ) post_command_event ( self . main_window , self . ContentChangedMsg ) macrocode = macro_infile . read ( ) self . grid . code_array . macros += "\n" + macrocode . strip ( "\n" ) self . grid . main_window . macro_panel . codetext_ctrl . SetText ( self . grid . code_array . macros ) except IOError : msg = _ ( "Error opening file {filepath}." ) . format ( filepath = filepath ) post_command_event ( self . main_window , self . StatusBarMsg , text = msg ) return False finally : self . main_window . grid . Enable ( ) wx . EndBusyCursor ( ) try : post_command_event ( self . main_window , self . ContentChangedMsg ) except TypeError : pass | Loads macros from file and marks grid as changed |
42,331 | def save_macros ( self , filepath , macros ) : io_error_text = _ ( "Error writing to file {filepath}." ) io_error_text = io_error_text . format ( filepath = filepath ) tmpfile = filepath + "~" try : wx . BeginBusyCursor ( ) self . main_window . grid . Disable ( ) with open ( tmpfile , "w" ) as macro_outfile : macro_outfile . write ( macros ) try : os . rename ( tmpfile , filepath ) except OSError : pass except IOError : try : post_command_event ( self . main_window , self . StatusBarMsg , text = io_error_text ) except TypeError : pass return False finally : self . main_window . grid . Enable ( ) wx . EndBusyCursor ( ) | Saves macros to file |
42,332 | def launch_help ( self , helpname , filename ) : position = config [ "help_window_position" ] size = config [ "help_window_size" ] self . help_window = wx . Frame ( self . main_window , - 1 , helpname , position , size ) self . help_htmlwindow = wx . html . HtmlWindow ( self . help_window , - 1 , ( 0 , 0 ) , size ) self . help_window . Bind ( wx . EVT_MOVE , self . OnHelpMove ) self . help_window . Bind ( wx . EVT_SIZE , self . OnHelpSize ) self . help_htmlwindow . Bind ( wx . EVT_RIGHT_DOWN , self . OnHelpBack ) self . help_htmlwindow . Bind ( wx . html . EVT_HTML_LINK_CLICKED , lambda e : self . open_external_links ( e ) ) self . help_htmlwindow . Bind ( wx . EVT_MOUSEWHEEL , lambda e : self . zoom_html ( e ) ) current_path = os . getcwd ( ) os . chdir ( get_help_path ( ) ) try : if os . path . isfile ( filename ) : self . help_htmlwindow . LoadFile ( filename ) else : self . help_htmlwindow . LoadPage ( filename ) except IOError : self . help_htmlwindow . LoadPage ( filename ) self . help_window . Show ( ) os . chdir ( current_path ) | Generic help launcher |
42,333 | def OnHelpMove ( self , event ) : position = event . GetPosition ( ) config [ "help_window_position" ] = repr ( ( position . x , position . y ) ) event . Skip ( ) | Help window move event handler stores position in config |
42,334 | def OnHelpSize ( self , event ) : size = event . GetSize ( ) config [ "help_window_size" ] = repr ( ( size . width , size . height ) ) event . Skip ( ) | Help window size event handler stores size in config |
42,335 | def vlcpanel_factory ( filepath , volume = None ) : vlc_panel_cls = VLCPanel VLCPanel . filepath = filepath if volume is not None : VLCPanel . volume = volume return vlc_panel_cls | Returns a VLCPanel class |
42,336 | def SetClientRect ( self , rect ) : panel_posx = rect [ 0 ] + self . grid . GetRowLabelSize ( ) panel_posy = rect [ 1 ] + self . grid . GetColLabelSize ( ) panel_scrolled_pos = self . grid . CalcScrolledPosition ( panel_posx , panel_posy ) self . SetPosition ( panel_scrolled_pos ) wx . Panel . SetClientRect ( self , wx . Rect ( 0 , 0 , rect [ 2 ] , rect [ 3 ] ) ) row_label_size = self . grid . GetRowLabelSize ( ) col_label_size = self . grid . GetColLabelSize ( ) if panel_scrolled_pos [ 0 ] < row_label_size or panel_scrolled_pos [ 1 ] < col_label_size : self . Hide ( ) else : self . Show ( ) | Positions and resizes video panel |
42,337 | def OnTogglePlay ( self , event ) : if self . player . get_state ( ) == vlc . State . Playing : self . player . pause ( ) else : self . player . play ( ) event . Skip ( ) | Toggles the video status between play and hold |
42,338 | def OnShiftVideo ( self , event ) : length = self . player . get_length ( ) time = self . player . get_time ( ) if event . GetWheelRotation ( ) < 0 : target_time = max ( 0 , time - length / 100.0 ) elif event . GetWheelRotation ( ) > 0 : target_time = min ( length , time + length / 100.0 ) self . player . set_time ( int ( target_time ) ) | Shifts through the video |
42,339 | def OnAdjustVolume ( self , event ) : self . volume = self . player . audio_get_volume ( ) if event . GetWheelRotation ( ) < 0 : self . volume = max ( 0 , self . volume - 10 ) elif event . GetWheelRotation ( ) > 0 : self . volume = min ( 200 , self . volume + 10 ) self . player . audio_set_volume ( self . volume ) | Changes video volume |
42,340 | def load ( self ) : old_config = not self . cfg_file . Exists ( "config_version" ) self . data . __dict__ . update ( self . defaults . __dict__ ) for key in self . defaults . __dict__ : if self . cfg_file . Exists ( key ) : setattr ( self . data , key , self . cfg_file . Read ( key ) ) if old_config or self . version != self . data . config_version : for key in self . reset_on_version_change : setattr ( self . data , key , getattr ( DefaultConfig ( ) , key ) ) self . data . config_version = self . version if hasattr ( self . data , "gpg_key_uid" ) : oldkey = "gpg_key_uid" delattr ( self . data , oldkey ) newkey = "gpg_key_fingerprint" setattr ( self . data , newkey , getattr ( DefaultConfig ( ) , newkey ) ) | Loads configuration file |
42,341 | def save ( self ) : for key in self . defaults . __dict__ : data = getattr ( self . data , key ) self . cfg_file . Write ( key , data ) | Saves configuration file |
42,342 | def string_result ( result , func , arguments ) : if result : s = bytes_to_str ( ctypes . string_at ( result ) ) libvlc_free ( result ) return s return None | Errcheck function . Returns a string and frees the original pointer . |
42,343 | def class_result ( classname ) : def wrap_errcheck ( result , func , arguments ) : if result is None : return None return classname ( result ) return wrap_errcheck | Errcheck function . Returns a function that creates the specified class . |
42,344 | def libvlc_vprinterr ( fmt , ap ) : f = _Cfunctions . get ( 'libvlc_vprinterr' , None ) or _Cfunction ( 'libvlc_vprinterr' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_char_p , ctypes . c_char_p , ctypes . c_void_p ) return f ( fmt , ap ) | Sets the LibVLC error status and message for the current thread . Any previous error is overridden . |
42,345 | def libvlc_add_intf ( p_instance , name ) : f = _Cfunctions . get ( 'libvlc_add_intf' , None ) or _Cfunction ( 'libvlc_add_intf' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , Instance , ctypes . c_char_p ) return f ( p_instance , name ) | Try to start a user interface for the libvlc instance . |
42,346 | def libvlc_event_attach ( p_event_manager , i_event_type , f_callback , user_data ) : f = _Cfunctions . get ( 'libvlc_event_attach' , None ) or _Cfunction ( 'libvlc_event_attach' , ( ( 1 , ) , ( 1 , ) , ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , EventManager , ctypes . c_uint , Callback , ctypes . c_void_p ) return f ( p_event_manager , i_event_type , f_callback , user_data ) | Register for an event notification . |
42,347 | def libvlc_event_type_name ( event_type ) : f = _Cfunctions . get ( 'libvlc_event_type_name' , None ) or _Cfunction ( 'libvlc_event_type_name' , ( ( 1 , ) , ) , None , ctypes . c_char_p , ctypes . c_uint ) return f ( event_type ) | Get an event s type name . |
42,348 | def libvlc_log_set_file ( p_instance , stream ) : f = _Cfunctions . get ( 'libvlc_log_set_file' , None ) or _Cfunction ( 'libvlc_log_set_file' , ( ( 1 , ) , ( 1 , ) , ) , None , None , Instance , FILE_ptr ) return f ( p_instance , stream ) | Sets up logging to a file . |
42,349 | def libvlc_module_description_list_release ( p_list ) : f = _Cfunctions . get ( 'libvlc_module_description_list_release' , None ) or _Cfunction ( 'libvlc_module_description_list_release' , ( ( 1 , ) , ) , None , None , ctypes . POINTER ( ModuleDescription ) ) return f ( p_list ) | Release a list of module descriptions . |
42,350 | def libvlc_audio_filter_list_get ( p_instance ) : f = _Cfunctions . get ( 'libvlc_audio_filter_list_get' , None ) or _Cfunction ( 'libvlc_audio_filter_list_get' , ( ( 1 , ) , ) , None , ctypes . POINTER ( ModuleDescription ) , Instance ) return f ( p_instance ) | Returns a list of audio filters that are available . |
42,351 | def libvlc_media_new_location ( p_instance , psz_mrl ) : f = _Cfunctions . get ( 'libvlc_media_new_location' , None ) or _Cfunction ( 'libvlc_media_new_location' , ( ( 1 , ) , ( 1 , ) , ) , class_result ( Media ) , ctypes . c_void_p , Instance , ctypes . c_char_p ) return f ( p_instance , psz_mrl ) | Create a media with a certain given media resource location for instance a valid URL . |
42,352 | def libvlc_media_duplicate ( p_md ) : f = _Cfunctions . get ( 'libvlc_media_duplicate' , None ) or _Cfunction ( 'libvlc_media_duplicate' , ( ( 1 , ) , ) , class_result ( Media ) , ctypes . c_void_p , Media ) return f ( p_md ) | Duplicate a media descriptor object . |
42,353 | def libvlc_media_save_meta ( p_md ) : f = _Cfunctions . get ( 'libvlc_media_save_meta' , None ) or _Cfunction ( 'libvlc_media_save_meta' , ( ( 1 , ) , ) , None , ctypes . c_int , Media ) return f ( p_md ) | Save the meta previously set . |
42,354 | def libvlc_media_get_stats ( p_md , p_stats ) : f = _Cfunctions . get ( 'libvlc_media_get_stats' , None ) or _Cfunction ( 'libvlc_media_get_stats' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , Media , ctypes . POINTER ( MediaStats ) ) return f ( p_md , p_stats ) | Get the current statistics about the media . |
42,355 | def libvlc_media_get_codec_description ( i_type , i_codec ) : f = _Cfunctions . get ( 'libvlc_media_get_codec_description' , None ) or _Cfunction ( 'libvlc_media_get_codec_description' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_char_p , TrackType , ctypes . c_uint32 ) return f ( i_type , i_codec ) | Get codec description from media elementary stream . |
42,356 | def libvlc_media_tracks_release ( p_tracks , i_count ) : f = _Cfunctions . get ( 'libvlc_media_tracks_release' , None ) or _Cfunction ( 'libvlc_media_tracks_release' , ( ( 1 , ) , ( 1 , ) , ) , None , None , ctypes . POINTER ( MediaTrack ) , ctypes . c_uint ) return f ( p_tracks , i_count ) | Release media descriptor s elementary streams description array . |
42,357 | def libvlc_media_get_type ( p_md ) : f = _Cfunctions . get ( 'libvlc_media_get_type' , None ) or _Cfunction ( 'libvlc_media_get_type' , ( ( 1 , ) , ) , None , MediaType , Media ) return f ( p_md ) | Get the media type of the media descriptor object . |
42,358 | def libvlc_media_discoverer_localized_name ( p_mdis ) : f = _Cfunctions . get ( 'libvlc_media_discoverer_localized_name' , None ) or _Cfunction ( 'libvlc_media_discoverer_localized_name' , ( ( 1 , ) , ) , string_result , ctypes . c_void_p , MediaDiscoverer ) return f ( p_mdis ) | Get media service discover object its localized name . |
42,359 | def libvlc_media_discoverer_media_list ( p_mdis ) : f = _Cfunctions . get ( 'libvlc_media_discoverer_media_list' , None ) or _Cfunction ( 'libvlc_media_discoverer_media_list' , ( ( 1 , ) , ) , class_result ( MediaList ) , ctypes . c_void_p , MediaDiscoverer ) return f ( p_mdis ) | Get media service discover media list . |
42,360 | def libvlc_media_discoverer_event_manager ( p_mdis ) : f = _Cfunctions . get ( 'libvlc_media_discoverer_event_manager' , None ) or _Cfunction ( 'libvlc_media_discoverer_event_manager' , ( ( 1 , ) , ) , class_result ( EventManager ) , ctypes . c_void_p , MediaDiscoverer ) return f ( p_mdis ) | Get event manager from media service discover object . |
42,361 | def libvlc_media_discoverer_is_running ( p_mdis ) : f = _Cfunctions . get ( 'libvlc_media_discoverer_is_running' , None ) or _Cfunction ( 'libvlc_media_discoverer_is_running' , ( ( 1 , ) , ) , None , ctypes . c_int , MediaDiscoverer ) return f ( p_mdis ) | Query if media service discover object is running . |
42,362 | def libvlc_media_library_new ( p_instance ) : f = _Cfunctions . get ( 'libvlc_media_library_new' , None ) or _Cfunction ( 'libvlc_media_library_new' , ( ( 1 , ) , ) , class_result ( MediaLibrary ) , ctypes . c_void_p , Instance ) return f ( p_instance ) | Create an new Media Library object . |
42,363 | def libvlc_media_library_load ( p_mlib ) : f = _Cfunctions . get ( 'libvlc_media_library_load' , None ) or _Cfunction ( 'libvlc_media_library_load' , ( ( 1 , ) , ) , None , ctypes . c_int , MediaLibrary ) return f ( p_mlib ) | Load media library . |
42,364 | def libvlc_media_library_media_list ( p_mlib ) : f = _Cfunctions . get ( 'libvlc_media_library_media_list' , None ) or _Cfunction ( 'libvlc_media_library_media_list' , ( ( 1 , ) , ) , class_result ( MediaList ) , ctypes . c_void_p , MediaLibrary ) return f ( p_mlib ) | Get media library subitems . |
42,365 | def libvlc_media_list_new ( p_instance ) : f = _Cfunctions . get ( 'libvlc_media_list_new' , None ) or _Cfunction ( 'libvlc_media_list_new' , ( ( 1 , ) , ) , class_result ( MediaList ) , ctypes . c_void_p , Instance ) return f ( p_instance ) | Create an empty media list . |
42,366 | def libvlc_media_list_event_manager ( p_ml ) : f = _Cfunctions . get ( 'libvlc_media_list_event_manager' , None ) or _Cfunction ( 'libvlc_media_list_event_manager' , ( ( 1 , ) , ) , class_result ( EventManager ) , ctypes . c_void_p , MediaList ) return f ( p_ml ) | Get libvlc_event_manager from this media list instance . The p_event_manager is immutable so you don t have to hold the lock . |
42,367 | def libvlc_media_list_player_new ( p_instance ) : f = _Cfunctions . get ( 'libvlc_media_list_player_new' , None ) or _Cfunction ( 'libvlc_media_list_player_new' , ( ( 1 , ) , ) , class_result ( MediaListPlayer ) , ctypes . c_void_p , Instance ) return f ( p_instance ) | Create new media_list_player . |
42,368 | def libvlc_media_list_player_event_manager ( p_mlp ) : f = _Cfunctions . get ( 'libvlc_media_list_player_event_manager' , None ) or _Cfunction ( 'libvlc_media_list_player_event_manager' , ( ( 1 , ) , ) , class_result ( EventManager ) , ctypes . c_void_p , MediaListPlayer ) return f ( p_mlp ) | Return the event manager of this media_list_player . |
42,369 | def libvlc_media_list_player_set_media_player ( p_mlp , p_mi ) : f = _Cfunctions . get ( 'libvlc_media_list_player_set_media_player' , None ) or _Cfunction ( 'libvlc_media_list_player_set_media_player' , ( ( 1 , ) , ( 1 , ) , ) , None , None , MediaListPlayer , MediaPlayer ) return f ( p_mlp , p_mi ) | Replace media player in media_list_player with this instance . |
42,370 | def libvlc_media_list_player_set_media_list ( p_mlp , p_mlist ) : f = _Cfunctions . get ( 'libvlc_media_list_player_set_media_list' , None ) or _Cfunction ( 'libvlc_media_list_player_set_media_list' , ( ( 1 , ) , ( 1 , ) , ) , None , None , MediaListPlayer , MediaList ) return f ( p_mlp , p_mlist ) | Set the media list associated with the player . |
42,371 | def libvlc_media_list_player_is_playing ( p_mlp ) : f = _Cfunctions . get ( 'libvlc_media_list_player_is_playing' , None ) or _Cfunction ( 'libvlc_media_list_player_is_playing' , ( ( 1 , ) , ) , None , ctypes . c_int , MediaListPlayer ) return f ( p_mlp ) | Is media list playing? |
42,372 | def libvlc_media_list_player_get_state ( p_mlp ) : f = _Cfunctions . get ( 'libvlc_media_list_player_get_state' , None ) or _Cfunction ( 'libvlc_media_list_player_get_state' , ( ( 1 , ) , ) , None , State , MediaListPlayer ) return f ( p_mlp ) | Get current libvlc_state of media list player . |
42,373 | def libvlc_media_list_player_play_item_at_index ( p_mlp , i_index ) : f = _Cfunctions . get ( 'libvlc_media_list_player_play_item_at_index' , None ) or _Cfunction ( 'libvlc_media_list_player_play_item_at_index' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , MediaListPlayer , ctypes . c_int ) return f ( p_mlp , i_index ) | Play media list item at position index . |
42,374 | def libvlc_media_list_player_play_item ( p_mlp , p_md ) : f = _Cfunctions . get ( 'libvlc_media_list_player_play_item' , None ) or _Cfunction ( 'libvlc_media_list_player_play_item' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , MediaListPlayer , Media ) return f ( p_mlp , p_md ) | Play the given media item . |
42,375 | def libvlc_media_list_player_set_playback_mode ( p_mlp , e_mode ) : f = _Cfunctions . get ( 'libvlc_media_list_player_set_playback_mode' , None ) or _Cfunction ( 'libvlc_media_list_player_set_playback_mode' , ( ( 1 , ) , ( 1 , ) , ) , None , None , MediaListPlayer , PlaybackMode ) return f ( p_mlp , e_mode ) | Sets the playback mode for the playlist . |
42,376 | def libvlc_media_player_new ( p_libvlc_instance ) : f = _Cfunctions . get ( 'libvlc_media_player_new' , None ) or _Cfunction ( 'libvlc_media_player_new' , ( ( 1 , ) , ) , class_result ( MediaPlayer ) , ctypes . c_void_p , Instance ) return f ( p_libvlc_instance ) | Create an empty Media Player object . |
42,377 | def libvlc_media_player_new_from_media ( p_md ) : f = _Cfunctions . get ( 'libvlc_media_player_new_from_media' , None ) or _Cfunction ( 'libvlc_media_player_new_from_media' , ( ( 1 , ) , ) , class_result ( MediaPlayer ) , ctypes . c_void_p , Media ) return f ( p_md ) | Create a Media Player object from a Media . |
42,378 | def libvlc_media_player_set_media ( p_mi , p_md ) : f = _Cfunctions . get ( 'libvlc_media_player_set_media' , None ) or _Cfunction ( 'libvlc_media_player_set_media' , ( ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , Media ) return f ( p_mi , p_md ) | Set the media that will be used by the media_player . If any previous md will be released . |
42,379 | def libvlc_media_player_get_media ( p_mi ) : f = _Cfunctions . get ( 'libvlc_media_player_get_media' , None ) or _Cfunction ( 'libvlc_media_player_get_media' , ( ( 1 , ) , ) , class_result ( Media ) , ctypes . c_void_p , MediaPlayer ) return f ( p_mi ) | Get the media used by the media_player . |
42,380 | def libvlc_media_player_event_manager ( p_mi ) : f = _Cfunctions . get ( 'libvlc_media_player_event_manager' , None ) or _Cfunction ( 'libvlc_media_player_event_manager' , ( ( 1 , ) , ) , class_result ( EventManager ) , ctypes . c_void_p , MediaPlayer ) return f ( p_mi ) | Get the Event Manager from which the media player send event . |
42,381 | def libvlc_media_player_set_agl ( p_mi , drawable ) : f = _Cfunctions . get ( 'libvlc_media_player_set_agl' , None ) or _Cfunction ( 'libvlc_media_player_set_agl' , ( ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , ctypes . c_uint32 ) return f ( p_mi , drawable ) | Set the agl handler where the media player should render its video output . |
42,382 | def libvlc_media_player_set_position ( p_mi , f_pos ) : f = _Cfunctions . get ( 'libvlc_media_player_set_position' , None ) or _Cfunction ( 'libvlc_media_player_set_position' , ( ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , ctypes . c_float ) return f ( p_mi , f_pos ) | Set movie position as percentage between 0 . 0 and 1 . 0 . This has no effect if playback is not enabled . This might not work depending on the underlying input format and protocol . |
42,383 | def libvlc_media_player_get_chapter_count_for_title ( p_mi , i_title ) : f = _Cfunctions . get ( 'libvlc_media_player_get_chapter_count_for_title' , None ) or _Cfunction ( 'libvlc_media_player_get_chapter_count_for_title' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , MediaPlayer , ctypes . c_int ) return f ( p_mi , i_title ) | Get title chapter count . |
42,384 | def libvlc_media_player_set_rate ( p_mi , rate ) : f = _Cfunctions . get ( 'libvlc_media_player_set_rate' , None ) or _Cfunction ( 'libvlc_media_player_set_rate' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , MediaPlayer , ctypes . c_float ) return f ( p_mi , rate ) | Set movie play rate . |
42,385 | def libvlc_media_player_get_state ( p_mi ) : f = _Cfunctions . get ( 'libvlc_media_player_get_state' , None ) or _Cfunction ( 'libvlc_media_player_get_state' , ( ( 1 , ) , ) , None , State , MediaPlayer ) return f ( p_mi ) | Get current movie state . |
42,386 | def libvlc_media_player_get_fps ( p_mi ) : f = _Cfunctions . get ( 'libvlc_media_player_get_fps' , None ) or _Cfunction ( 'libvlc_media_player_get_fps' , ( ( 1 , ) , ) , None , ctypes . c_float , MediaPlayer ) return f ( p_mi ) | Get movie fps rate . |
42,387 | def libvlc_media_player_has_vout ( p_mi ) : f = _Cfunctions . get ( 'libvlc_media_player_has_vout' , None ) or _Cfunction ( 'libvlc_media_player_has_vout' , ( ( 1 , ) , ) , None , ctypes . c_uint , MediaPlayer ) return f ( p_mi ) | How many video outputs does this media player have? |
42,388 | def libvlc_media_player_navigate ( p_mi , navigate ) : f = _Cfunctions . get ( 'libvlc_media_player_navigate' , None ) or _Cfunction ( 'libvlc_media_player_navigate' , ( ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , ctypes . c_uint ) return f ( p_mi , navigate ) | Navigate through DVD Menu . |
42,389 | def libvlc_media_player_set_video_title_display ( p_mi , position , timeout ) : f = _Cfunctions . get ( 'libvlc_media_player_set_video_title_display' , None ) or _Cfunction ( 'libvlc_media_player_set_video_title_display' , ( ( 1 , ) , ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , Position , ctypes . c_int ) return f ( p_mi , position , timeout ) | Set if and how the video title will be shown when media is played . |
42,390 | def libvlc_set_fullscreen ( p_mi , b_fullscreen ) : f = _Cfunctions . get ( 'libvlc_set_fullscreen' , None ) or _Cfunction ( 'libvlc_set_fullscreen' , ( ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , ctypes . c_int ) return f ( p_mi , b_fullscreen ) | Enable or disable fullscreen . |
42,391 | def libvlc_video_set_key_input ( p_mi , on ) : f = _Cfunctions . get ( 'libvlc_video_set_key_input' , None ) or _Cfunction ( 'libvlc_video_set_key_input' , ( ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , ctypes . c_uint ) return f ( p_mi , on ) | Enable or disable key press events handling according to the LibVLC hotkeys configuration . By default and for historical reasons keyboard events are handled by the LibVLC video widget . |
42,392 | def libvlc_video_get_size ( p_mi , num ) : f = _Cfunctions . get ( 'libvlc_video_get_size' , None ) or _Cfunction ( 'libvlc_video_get_size' , ( ( 1 , ) , ( 1 , ) , ( 2 , ) , ( 2 , ) , ) , None , ctypes . c_int , MediaPlayer , ctypes . c_uint , ctypes . POINTER ( ctypes . c_uint ) , ctypes . POINTER ( ctypes . c_uint ) ) return f ( p_mi , num ) | Get the pixel dimensions of a video . |
42,393 | def libvlc_video_get_aspect_ratio ( p_mi ) : f = _Cfunctions . get ( 'libvlc_video_get_aspect_ratio' , None ) or _Cfunction ( 'libvlc_video_get_aspect_ratio' , ( ( 1 , ) , ) , string_result , ctypes . c_void_p , MediaPlayer ) return f ( p_mi ) | Get current video aspect ratio . |
42,394 | def libvlc_video_set_aspect_ratio ( p_mi , psz_aspect ) : f = _Cfunctions . get ( 'libvlc_video_set_aspect_ratio' , None ) or _Cfunction ( 'libvlc_video_set_aspect_ratio' , ( ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , ctypes . c_char_p ) return f ( p_mi , psz_aspect ) | Set new video aspect ratio . |
42,395 | def libvlc_video_get_spu ( p_mi ) : f = _Cfunctions . get ( 'libvlc_video_get_spu' , None ) or _Cfunction ( 'libvlc_video_get_spu' , ( ( 1 , ) , ) , None , ctypes . c_int , MediaPlayer ) return f ( p_mi ) | Get current video subtitle . |
42,396 | def libvlc_video_set_spu ( p_mi , i_spu ) : f = _Cfunctions . get ( 'libvlc_video_set_spu' , None ) or _Cfunction ( 'libvlc_video_set_spu' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , MediaPlayer , ctypes . c_int ) return f ( p_mi , i_spu ) | Set new video subtitle . |
42,397 | def libvlc_video_set_subtitle_file ( p_mi , psz_subtitle ) : f = _Cfunctions . get ( 'libvlc_video_set_subtitle_file' , None ) or _Cfunction ( 'libvlc_video_set_subtitle_file' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , MediaPlayer , ctypes . c_char_p ) return f ( p_mi , psz_subtitle ) | Set new video subtitle file . |
42,398 | def libvlc_video_set_spu_delay ( p_mi , i_delay ) : f = _Cfunctions . get ( 'libvlc_video_set_spu_delay' , None ) or _Cfunction ( 'libvlc_video_set_spu_delay' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , MediaPlayer , ctypes . c_int64 ) return f ( p_mi , i_delay ) | Set the subtitle delay . This affects the timing of when the subtitle will be displayed . Positive values result in subtitles being displayed later while negative values will result in subtitles being displayed earlier . The subtitle delay will be reset to zero each time the media changes . |
42,399 | def libvlc_video_get_chapter_description ( p_mi , i_title ) : f = _Cfunctions . get ( 'libvlc_video_get_chapter_description' , None ) or _Cfunction ( 'libvlc_video_get_chapter_description' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . POINTER ( TrackDescription ) , MediaPlayer , ctypes . c_int ) return f ( p_mi , i_title ) | Get the description of available chapters for specific title . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.