idx
int64
0
63k
question
stringlengths
61
4.03k
target
stringlengths
6
1.23k
42,400
def libvlc_video_set_crop_geometry ( p_mi , psz_geometry ) : f = _Cfunctions . get ( 'libvlc_video_set_crop_geometry' , None ) or _Cfunction ( 'libvlc_video_set_crop_geometry' , ( ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , ctypes . c_char_p ) return f ( p_mi , psz_geometry )
Set new crop filter geometry .
42,401
def libvlc_video_set_teletext ( p_mi , i_page ) : f = _Cfunctions . get ( 'libvlc_video_set_teletext' , None ) or _Cfunction ( 'libvlc_video_set_teletext' , ( ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , ctypes . c_int ) return f ( p_mi , i_page )
Set new teletext page to retrieve .
42,402
def libvlc_video_get_track_description ( p_mi ) : f = _Cfunctions . get ( 'libvlc_video_get_track_description' , None ) or _Cfunction ( 'libvlc_video_get_track_description' , ( ( 1 , ) , ) , None , ctypes . POINTER ( TrackDescription ) , MediaPlayer ) return f ( p_mi )
Get the description of available video tracks .
42,403
def libvlc_video_set_deinterlace ( p_mi , psz_mode ) : f = _Cfunctions . get ( 'libvlc_video_set_deinterlace' , None ) or _Cfunction ( 'libvlc_video_set_deinterlace' , ( ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , ctypes . c_char_p ) return f ( p_mi , psz_mode )
Enable or disable deinterlace filter .
42,404
def libvlc_video_get_marquee_string ( p_mi , option ) : f = _Cfunctions . get ( 'libvlc_video_get_marquee_string' , None ) or _Cfunction ( 'libvlc_video_get_marquee_string' , ( ( 1 , ) , ( 1 , ) , ) , string_result , ctypes . c_void_p , MediaPlayer , ctypes . c_uint ) return f ( p_mi , option )
Get a string marquee option value .
42,405
def libvlc_video_set_marquee_string ( p_mi , option , psz_text ) : f = _Cfunctions . get ( 'libvlc_video_set_marquee_string' , None ) or _Cfunction ( 'libvlc_video_set_marquee_string' , ( ( 1 , ) , ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , ctypes . c_uint , ctypes . c_char_p ) return f ( p_mi , option , psz_text )
Set a marquee string option .
42,406
def libvlc_video_get_logo_int ( p_mi , option ) : f = _Cfunctions . get ( 'libvlc_video_get_logo_int' , None ) or _Cfunction ( 'libvlc_video_get_logo_int' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , MediaPlayer , ctypes . c_uint ) return f ( p_mi , option )
Get integer logo option .
42,407
def libvlc_video_set_logo_string ( p_mi , option , psz_value ) : f = _Cfunctions . get ( 'libvlc_video_set_logo_string' , None ) or _Cfunction ( 'libvlc_video_set_logo_string' , ( ( 1 , ) , ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , ctypes . c_uint , ctypes . c_char_p ) return f ( p_mi , option , psz_value )
Set logo option as string . Options that take a different type value are ignored .
42,408
def libvlc_video_get_adjust_float ( p_mi , option ) : f = _Cfunctions . get ( 'libvlc_video_get_adjust_float' , None ) or _Cfunction ( 'libvlc_video_get_adjust_float' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_float , MediaPlayer , ctypes . c_uint ) return f ( p_mi , option )
Get float adjust option .
42,409
def libvlc_video_set_adjust_float ( p_mi , option , value ) : f = _Cfunctions . get ( 'libvlc_video_set_adjust_float' , None ) or _Cfunction ( 'libvlc_video_set_adjust_float' , ( ( 1 , ) , ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , ctypes . c_uint , ctypes . c_float ) return f ( p_mi , option , value )
Set adjust option as float . Options that take a different type value are ignored .
42,410
def libvlc_audio_output_list_get ( p_instance ) : f = _Cfunctions . get ( 'libvlc_audio_output_list_get' , None ) or _Cfunction ( 'libvlc_audio_output_list_get' , ( ( 1 , ) , ) , None , ctypes . POINTER ( AudioOutput ) , Instance ) return f ( p_instance )
Gets the list of available audio output modules .
42,411
def libvlc_audio_output_list_release ( p_list ) : f = _Cfunctions . get ( 'libvlc_audio_output_list_release' , None ) or _Cfunction ( 'libvlc_audio_output_list_release' , ( ( 1 , ) , ) , None , None , ctypes . POINTER ( AudioOutput ) ) return f ( p_list )
Frees the list of available audio output modules .
42,412
def libvlc_audio_output_set ( p_mi , psz_name ) : f = _Cfunctions . get ( 'libvlc_audio_output_set' , None ) or _Cfunction ( 'libvlc_audio_output_set' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , MediaPlayer , ctypes . c_char_p ) return f ( p_mi , psz_name )
Selects an audio output module .
42,413
def libvlc_audio_output_device_list_release ( p_list ) : f = _Cfunctions . get ( 'libvlc_audio_output_device_list_release' , None ) or _Cfunction ( 'libvlc_audio_output_device_list_release' , ( ( 1 , ) , ) , None , None , ctypes . POINTER ( AudioOutputDevice ) ) return f ( p_list )
Frees a list of available audio output devices .
42,414
def libvlc_audio_set_mute ( p_mi , status ) : f = _Cfunctions . get ( 'libvlc_audio_set_mute' , None ) or _Cfunction ( 'libvlc_audio_set_mute' , ( ( 1 , ) , ( 1 , ) , ) , None , None , MediaPlayer , ctypes . c_int ) return f ( p_mi , status )
Set mute status .
42,415
def libvlc_audio_set_volume ( p_mi , i_volume ) : f = _Cfunctions . get ( 'libvlc_audio_set_volume' , None ) or _Cfunction ( 'libvlc_audio_set_volume' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , MediaPlayer , ctypes . c_int ) return f ( p_mi , i_volume )
Set current software audio volume .
42,416
def libvlc_audio_set_track ( p_mi , i_track ) : f = _Cfunctions . get ( 'libvlc_audio_set_track' , None ) or _Cfunction ( 'libvlc_audio_set_track' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , MediaPlayer , ctypes . c_int ) return f ( p_mi , i_track )
Set current audio track .
42,417
def libvlc_audio_set_channel ( p_mi , channel ) : f = _Cfunctions . get ( 'libvlc_audio_set_channel' , None ) or _Cfunction ( 'libvlc_audio_set_channel' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , MediaPlayer , ctypes . c_int ) return f ( p_mi , channel )
Set current audio channel .
42,418
def libvlc_audio_get_delay ( p_mi ) : f = _Cfunctions . get ( 'libvlc_audio_get_delay' , None ) or _Cfunction ( 'libvlc_audio_get_delay' , ( ( 1 , ) , ) , None , ctypes . c_int64 , MediaPlayer ) return f ( p_mi )
Get current audio delay .
42,419
def libvlc_audio_equalizer_get_preset_name ( u_index ) : f = _Cfunctions . get ( 'libvlc_audio_equalizer_get_preset_name' , None ) or _Cfunction ( 'libvlc_audio_equalizer_get_preset_name' , ( ( 1 , ) , ) , None , ctypes . c_char_p , ctypes . c_uint ) return f ( u_index )
Get the name of a particular equalizer preset . This name can be used for example to prepare a preset label or menu in a user interface .
42,420
def libvlc_audio_equalizer_get_band_frequency ( u_index ) : f = _Cfunctions . get ( 'libvlc_audio_equalizer_get_band_frequency' , None ) or _Cfunction ( 'libvlc_audio_equalizer_get_band_frequency' , ( ( 1 , ) , ) , None , ctypes . c_float , ctypes . c_uint ) return f ( u_index )
Get a particular equalizer band frequency . This value can be used for example to create a label for an equalizer band control in a user interface .
42,421
def libvlc_audio_equalizer_get_preamp ( p_equalizer ) : f = _Cfunctions . get ( 'libvlc_audio_equalizer_get_preamp' , None ) or _Cfunction ( 'libvlc_audio_equalizer_get_preamp' , ( ( 1 , ) , ) , None , ctypes . c_float , ctypes . c_void_p ) return f ( p_equalizer )
Get the current pre - amplification value from an equalizer .
42,422
def libvlc_audio_equalizer_get_amp_at_index ( p_equalizer , u_band ) : f = _Cfunctions . get ( 'libvlc_audio_equalizer_get_amp_at_index' , None ) or _Cfunction ( 'libvlc_audio_equalizer_get_amp_at_index' , ( ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_float , ctypes . c_void_p , ctypes . c_uint ) return f ( p_equalizer , u_band )
Get the amplification value for a particular equalizer frequency band .
42,423
def libvlc_vlm_set_loop ( p_instance , psz_name , b_loop ) : f = _Cfunctions . get ( 'libvlc_vlm_set_loop' , None ) or _Cfunction ( 'libvlc_vlm_set_loop' , ( ( 1 , ) , ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , Instance , ctypes . c_char_p , ctypes . c_int ) return f ( p_instance , psz_name , b_loop )
Set a media s loop status .
42,424
def libvlc_vlm_seek_media ( p_instance , psz_name , f_percentage ) : f = _Cfunctions . get ( 'libvlc_vlm_seek_media' , None ) or _Cfunction ( 'libvlc_vlm_seek_media' , ( ( 1 , ) , ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , Instance , ctypes . c_char_p , ctypes . c_float ) return f ( p_instance , psz_name , f_percentage )
Seek in the named broadcast .
42,425
def libvlc_vlm_show_media ( p_instance , psz_name ) : f = _Cfunctions . get ( 'libvlc_vlm_show_media' , None ) or _Cfunction ( 'libvlc_vlm_show_media' , ( ( 1 , ) , ( 1 , ) , ) , string_result , ctypes . c_void_p , Instance , ctypes . c_char_p ) return f ( p_instance , psz_name )
Return information about the named media as a JSON string representation . This function is mainly intended for debugging use if you want programmatic access to the state of a vlm_media_instance_t please use the corresponding libvlc_vlm_get_media_instance_xxx - functions . Currently there are no such functions available for vlm_media_t though .
42,426
def libvlc_vlm_get_media_instance_position ( p_instance , psz_name , i_instance ) : f = _Cfunctions . get ( 'libvlc_vlm_get_media_instance_position' , None ) or _Cfunction ( 'libvlc_vlm_get_media_instance_position' , ( ( 1 , ) , ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_float , Instance , ctypes . c_char_p , ctypes . c_int ) return f ( p_instance , psz_name , i_instance )
Get vlm_media instance position by name or instance id .
42,427
def libvlc_vlm_get_media_instance_time ( p_instance , psz_name , i_instance ) : f = _Cfunctions . get ( 'libvlc_vlm_get_media_instance_time' , None ) or _Cfunction ( 'libvlc_vlm_get_media_instance_time' , ( ( 1 , ) , ( 1 , ) , ( 1 , ) , ) , None , ctypes . c_int , Instance , ctypes . c_char_p , ctypes . c_int ) return f ( p_instance , psz_name , i_instance )
Get vlm_media instance time by name or instance id .
42,428
def libvlc_vlm_get_event_manager ( p_instance ) : f = _Cfunctions . get ( 'libvlc_vlm_get_event_manager' , None ) or _Cfunction ( 'libvlc_vlm_get_event_manager' , ( ( 1 , ) , ) , class_result ( EventManager ) , ctypes . c_void_p , Instance ) return f ( p_instance )
Get libvlc_event_manager from a vlm media . The p_event_manager is immutable so you don t have to hold the lock .
42,429
def debug_callback ( event , * args , ** kwds ) : l = [ 'event %s' % ( event . type , ) ] if args : l . extend ( map ( str , args ) ) if kwds : l . extend ( sorted ( '%s=%s' % t for t in kwds . items ( ) ) ) print ( 'Debug callback (%s)' % ', ' . join ( l ) )
Example callback useful for debugging .
42,430
def event_attach ( self , eventtype , callback , * args , ** kwds ) : if not isinstance ( eventtype , EventType ) : raise VLCException ( "%s required: %r" % ( 'EventType' , eventtype ) ) if not hasattr ( callback , '__call__' ) : raise VLCException ( "%s required: %r" % ( 'callable' , callback ) ) if not any ( getargspec ( callback ) [ : 2 ] ) : raise VLCException ( "%s required: %r" % ( 'argument' , callback ) ) if self . _callback_handler is None : _called_from_ctypes = ctypes . CFUNCTYPE ( None , ctypes . POINTER ( Event ) , ctypes . c_void_p ) @ _called_from_ctypes def _callback_handler ( event , k ) : try : call , args , kwds = self . _callbacks [ k ] call ( event . contents , * args , ** kwds ) except KeyError : pass self . _callback_handler = _callback_handler self . _callbacks = { } k = eventtype . value r = libvlc_event_attach ( self , k , self . _callback_handler , k ) if not r : self . _callbacks [ k ] = ( callback , args , kwds ) return r
Register an event notification .
42,431
def media_player_new ( self , uri = None ) : p = libvlc_media_player_new ( self ) if uri : p . set_media ( self . media_new ( uri ) ) p . _instance = self return p
Create a new MediaPlayer instance .
42,432
def media_new ( self , mrl , * options ) : if ':' in mrl and mrl . index ( ':' ) > 1 : m = libvlc_media_new_location ( self , str_to_bytes ( mrl ) ) else : m = libvlc_media_new_path ( self , str_to_bytes ( os . path . normpath ( mrl ) ) ) for o in options : libvlc_media_add_option ( m , str_to_bytes ( o ) ) m . _instance = self return m
Create a new Media instance .
42,433
def media_list_new ( self , mrls = None ) : l = libvlc_media_list_new ( self ) if mrls : for m in mrls : l . add_media ( m ) l . _instance = self return l
Create a new MediaList instance .
42,434
def audio_output_enumerate_devices ( self ) : r = [ ] head = libvlc_audio_output_list_get ( self ) if head : i = head while i : i = i . contents d = [ { 'id' : libvlc_audio_output_device_id ( self , i . name , d ) , 'longname' : libvlc_audio_output_device_longname ( self , i . name , d ) } for d in range ( libvlc_audio_output_device_count ( self , i . name ) ) ] r . append ( { 'name' : i . name , 'description' : i . description , 'devices' : d } ) i = i . next libvlc_audio_output_list_release ( head ) return r
Enumerate the defined audio output devices .
42,435
def vlm_add_input ( self , psz_name , psz_input ) : return libvlc_vlm_add_input ( self , str_to_bytes ( psz_name ) , str_to_bytes ( psz_input ) )
Add a media s input MRL . This will add the specified one .
42,436
def vlm_change_media ( self , psz_name , psz_input , psz_output , i_options , ppsz_options , b_enabled , b_loop ) : return libvlc_vlm_change_media ( self , str_to_bytes ( psz_name ) , str_to_bytes ( psz_input ) , str_to_bytes ( psz_output ) , i_options , ppsz_options , b_enabled , b_loop )
Edit the parameters of a media . This will delete all existing inputs and add the specified one .
42,437
def set_mrl ( self , mrl , * options ) : m = self . get_instance ( ) . media_new ( mrl , * options ) self . set_media ( m ) return m
Set the MRL to play .
42,438
def do ( self ) : 'Do or redo the action' self . _runner = self . _generator ( * self . args , ** self . kwargs ) rets = next ( self . _runner ) if isinstance ( rets , tuple ) : self . _text = rets [ 0 ] return rets [ 1 : ] elif rets is None : self . _text = '' return None else : self . _text = rets return None
Do or redo the action
42,439
def redo ( self ) : if self . canredo ( ) : undoable = self . _redos . pop ( ) with self . _pausereceiver ( ) : try : undoable . do ( ) except : self . clear ( ) raise else : self . _undos . append ( undoable ) self . docallback ( )
Redo the last undone action . This is only possible if no other actions have occurred since the last undo call .
42,440
def clear ( self ) : self . _undos . clear ( ) self . _redos . clear ( ) self . _savepoint = None self . _receiver = self . _undos
Clear the undo list .
42,441
def is_bbox_not_intersecting ( self , other ) : self_x_min , self_x_max , self_y_min , self_y_max = self . get_bbox ( ) other_x_min , other_x_max , other_y_min , other_y_max = other . get_bbox ( ) return self_x_min > other_x_max or other_x_min > self_x_max or self_y_min > other_y_max or other_y_min > self_y_max
Returns False iif bounding boxed of self and other intersect
42,442
def is_edge_not_excluding_vertices ( self , other ) : c_a = cos ( self . angle ) s_a = sin ( self . angle ) other_x_min , other_x_max , other_y_min , other_y_max = other . get_bbox ( ) self_x_diff = 0.5 * self . width self_y_diff = 0.5 * self . height if c_a > 0 : if s_a > 0 : return c_a * other_x_max + s_a * other_y_max < - self_x_diff or c_a * other_x_min + s_a * other_y_min > self_x_diff or c_a * other_y_max - s_a * other_x_min < - self_y_diff or c_a * other_y_min - s_a * other_x_max > self_y_diff else : return c_a * other_x_max + s_a * other_y_min < - self_x_diff or c_a * other_x_min + s_a * other_y_max > self_x_diff or c_a * other_y_max - s_a * other_x_max < - self_y_diff or c_a * other_y_min - s_a * other_x_min > self_y_diff else : if s_a > 0 : return c_a * other_x_min + s_a * other_y_max < - self_x_diff or c_a * other_x_max + s_a * other_y_min > self_x_diff or c_a * other_y_min - s_a * other_x_min < - self_y_diff or c_a * other_y_max - s_a * other_x_max > self_y_diff else : return c_a * other_x_min + s_a * other_y_min < - self_x_diff or c_a * other_x_max + s_a * other_y_max > self_x_diff or c_a * other_y_min - s_a * other_x_max < - self_y_diff or c_a * other_y_max - s_a * other_x_min > self_y_diff
Returns False iif any edge excludes all vertices of other .
42,443
def collides ( self , other ) : angle = self . angle width = self . width height = self . height if angle == 0 : return other . collides ( Rect ( - 0.5 * width , - 0.5 * height , width , height ) ) if self . is_bbox_not_intersecting ( other ) : return False return not self . is_edge_not_excluding_vertices ( other )
Returns collision with axis aligned rect
42,444
def get_vec_lr ( self ) : return self . width * self . cos_a ( ) , - self . width * self . sin_a ( )
Returns vector from left to right
42,445
def get_vec_tb ( self ) : return self . height * self . sin_a ( ) , self . height * self . cos_a ( )
Returns vector from top to bottom
42,446
def get_center ( self ) : lr_x , lr_y = self . get_vec_lr ( ) tb_x , tb_y = self . get_vec_tb ( ) center_x = self . x + ( lr_x + tb_x ) / 2.0 center_y = self . y + ( lr_y + tb_y ) / 2.0 return center_x , center_y
Returns rectangle center
42,447
def get_edges ( self ) : lr_x , lr_y = self . get_vec_lr ( ) tb_x , tb_y = self . get_vec_tb ( ) top_left = self . x , self . y top_right = self . x + lr_x , self . y + lr_y bottom_left = self . x + tb_x , self . y + tb_y bottom_right = self . x + lr_x + tb_x , self . y + lr_y + tb_y return top_left , top_right , bottom_left , bottom_right
Returns 2 - tuples for each edge
42,448
def collides_axisaligned_rect ( self , other ) : self_shifted = RotoOriginRect ( self . width , self . height , - self . angle ) s_a = self . sin_a ( ) c_a = self . cos_a ( ) center_x = self . x + self . width / 2.0 * c_a - self . height / 2.0 * s_a center_y = self . y - self . height / 2.0 * c_a - self . width / 2.0 * s_a other_shifted = Rect ( other . x - center_x , other . y - center_y , other . width , other . height ) return self_shifted . collides ( other_shifted )
Returns collision with axis aligned other rect
42,449
def get_paths ( self , theme , icon_size ) : _size_str = "x" . join ( map ( str , icon_size ) ) theme_path = get_program_path ( ) + "share" + os . sep + "icons" + os . sep icon_path = theme_path + theme + os . sep + _size_str + os . sep action_path = icon_path + "actions" + os . sep toggle_path = icon_path + "toggles" + os . sep return theme_path , icon_path , action_path , toggle_path
Returns tuple of theme icon action and toggle paths
42,450
def CreateBitmap ( self , artid , client , size ) : if artid in self . extra_icons : return wx . Bitmap ( self . extra_icons [ artid ] , wx . BITMAP_TYPE_ANY ) else : return wx . ArtProvider . GetBitmap ( artid , client , size )
Adds custom images to Artprovider
42,451
def set_initial_state ( self , kwargs ) : self . main_window = kwargs . pop ( "main_window" ) try : statustext = kwargs . pop ( "statustext" ) except KeyError : statustext = "" try : self . total_lines = kwargs . pop ( "total_lines" ) self . statustext = statustext + _ ( "{nele} of {totalele} elements processed." ) except KeyError : self . total_lines = None self . statustext = statustext + _ ( "{nele} elements processed." ) try : self . freq = kwargs . pop ( "freq" ) except KeyError : self . freq = 1000 self . aborted = False self . line = 0 self . main_window . Bind ( wx . EVT_KEY_DOWN , self . on_key )
Sets class state from kwargs attributes pops extra kwargs
42,452
def progress_status ( self ) : if self . line % self . freq == 0 : text = self . statustext . format ( nele = self . line , totalele = self . total_lines ) if self . main_window . grid . actions . pasting : try : post_command_event ( self . main_window , self . main_window . StatusBarMsg , text = text ) except TypeError : pass else : self . main_window . GetStatusBar ( ) . SetStatusText ( text ) if is_gtk ( ) : try : wx . Yield ( ) except : pass self . line += 1
Displays progress in statusbar
42,453
def on_key ( self , event ) : if self . main_window . grid . actions . pasting and event . GetKeyCode ( ) == wx . WXK_ESCAPE : self . aborted = True event . Skip ( )
Sets aborted state if escape is pressed
42,454
def _get_tables ( self , ods ) : childnodes = ods . spreadsheet . childNodes qname_childnodes = [ ( s . qname [ 1 ] , s ) for s in childnodes ] return [ node for name , node in qname_childnodes if name == u"table" ]
Returns list of table nodes from ods object
42,455
def _get_rows ( self , table ) : childnodes = table . childNodes qname_childnodes = [ ( s . qname [ 1 ] , s ) for s in childnodes ] return [ node for name , node in qname_childnodes if name == u'table-row' ]
Returns rows from table
42,456
def _get_cells ( self , row ) : childnodes = row . childNodes qname_childnodes = [ ( s . qname [ 1 ] , s ) for s in childnodes ] return [ node for name , node in qname_childnodes if name == u'table-cell' ]
Returns rows from row
42,457
def _ods2code ( self ) : ods = ODSReader ( self . ods_file , clonespannedcolumns = True ) tables = ods . sheets for tab_id , table in enumerate ( tables ) : for row_id in xrange ( len ( table ) ) : for col_id in xrange ( len ( table [ row_id ] ) ) : key = row_id , col_id , tab_id text = unicode ( table [ row_id ] [ col_id ] ) self . code_array [ key ] = text
Updates code in code_array
42,458
def pyspread ( S = None ) : app = MainApplication ( S = S , redirect = False ) app . MainLoop ( )
Holds application main loop
42,459
def readSheet ( self , sheet ) : name = sheet . getAttribute ( "name" ) rows = sheet . getElementsByType ( TableRow ) arrRows = [ ] for row in rows : row_comment = "" arrCells = GrowingList ( ) cells = row . getElementsByType ( TableCell ) count = 0 for cell in cells : repeat = cell . getAttribute ( "numbercolumnsrepeated" ) if ( not repeat ) : repeat = 1 spanned = int ( cell . getAttribute ( 'numbercolumnsspanned' ) or 0 ) if self . clonespannedcolumns is not None and spanned > 1 : repeat = spanned ps = cell . getElementsByType ( P ) textContent = "" for p in ps : for n in p . childNodes : if ( n . nodeType == 1 and n . tagName == "text:span" ) : for c in n . childNodes : if ( c . nodeType == 3 ) : textContent = u'{}{}' . format ( textContent , n . data ) if ( n . nodeType == 3 ) : textContent = u'{}{}' . format ( textContent , n . data ) if ( textContent ) : if ( textContent [ 0 ] != "#" ) : for rr in xrange ( int ( repeat ) ) : arrCells [ count ] = textContent count += 1 else : row_comment = row_comment + textContent + " " else : for rr in xrange ( int ( repeat ) ) : count += 1 if ( len ( arrCells ) ) : arrRows . append ( arrCells ) self . sheets . append ( arrRows ) self . sheet_names . append ( name )
Reads a sheet in the sheet dictionary
42,460
def sniff ( filepath ) : with open ( filepath , "rb" ) as csvfile : sample = csvfile . read ( config [ "sniff_size" ] ) sniffer = csv . Sniffer ( ) dialect = sniffer . sniff ( sample ) ( ) has_header = sniffer . has_header ( sample ) return dialect , has_header
Sniffs CSV dialect and header info from csvfilepath
42,461
def get_first_line ( filepath , dialect ) : with open ( filepath , "rb" ) as csvfile : csvreader = csv . reader ( csvfile , dialect = dialect ) for first_line in csvreader : break return first_line
Returns List of first line items of file filepath
42,462
def digested_line ( line , digest_types ) : digested_line = [ ] for i , ele in enumerate ( line ) : try : digest_key = digest_types [ i ] except IndexError : digest_key = digest_types [ 0 ] digest = Digest ( acceptable_types = [ digest_key ] ) try : digested_line . append ( repr ( digest ( ele ) ) ) except Exception : digested_line . append ( "" ) return digested_line
Returns list of digested values in line
42,463
def csv_digest_gen ( filepath , dialect , has_header , digest_types ) : with open ( filepath , "rb" ) as csvfile : csvreader = csv . reader ( csvfile , dialect = dialect ) if has_header : for line in csvreader : break for line in csvreader : yield digested_line ( line , digest_types )
Generator of digested values from csv file in filepath
42,464
def cell_key_val_gen ( iterable , shape , topleft = ( 0 , 0 ) ) : top , left = topleft for __row , line in enumerate ( iterable ) : row = top + __row if row >= shape [ 0 ] : break for __col , value in enumerate ( line ) : col = left + __col if col >= shape [ 1 ] : break yield row , col , value
Generator of row col value tuple from iterable of iterables
42,465
def encode_gen ( line , encoding = "utf-8" ) : for ele in line : if isinstance ( ele , types . UnicodeType ) : yield ele . encode ( encoding ) else : yield ele
Encodes all Unicode strings in line to encoding
42,466
def _get_csv_cells_gen ( self , line ) : digest_types = self . digest_types for j , value in enumerate ( line ) : if self . first_line : digest_key = None digest = lambda x : x . decode ( self . encoding ) else : try : digest_key = digest_types [ j ] except IndexError : digest_key = digest_types [ 0 ] digest = Digest ( acceptable_types = [ digest_key ] , encoding = self . encoding ) try : digest_res = digest ( value ) if digest_res == "\b" : digest_res = None elif digest_key is not types . CodeType : digest_res = repr ( digest_res ) except Exception : digest_res = "" yield digest_res
Generator of values in a csv line
42,467
def write ( self , iterable ) : io_error_text = _ ( "Error writing to file {filepath}." ) io_error_text = io_error_text . format ( filepath = self . path ) try : with open ( self . path , "wb" ) as csvfile : csv_writer = csv . writer ( csvfile , self . dialect ) for line in iterable : csv_writer . writerow ( list ( encode_gen ( line , encoding = self . encoding ) ) ) except IOError : txt = _ ( "Error opening file {filepath}." ) . format ( filepath = self . path ) try : post_command_event ( self . main_window , self . StatusBarMsg , text = txt ) except TypeError : pass return False
Writes values from iterable into CSV file
42,468
def _shape2xls ( self , worksheets ) : __ , __ , tabs = self . code_array . shape if tabs > self . xls_max_tabs : tabs = self . xls_max_tabs for tab in xrange ( tabs ) : worksheet = self . workbook . add_sheet ( str ( tab ) ) worksheets . append ( worksheet )
Writes shape to xls file
42,469
def _code2xls ( self , worksheets ) : code_array = self . code_array xls_max_shape = self . xls_max_rows , self . xls_max_cols , self . xls_max_tabs for key in code_array : if all ( kele < mele for kele , mele in zip ( key , xls_max_shape ) ) : row , col , tab = key code_str = code_array ( key ) if code_str is not None : style = self . _get_xfstyle ( worksheets , key ) worksheets [ tab ] . write ( row , col , label = code_str , style = style ) max_shape = [ min ( xls_max_shape [ 0 ] , code_array . shape [ 0 ] ) , min ( xls_max_shape [ 1 ] , code_array . shape [ 1 ] ) ] if max_shape [ 0 ] * max_shape [ 1 ] > 1024000 : max_shape [ 0 ] = 4000 cell_attributes = code_array . dict_grid . cell_attributes bboxes = [ ] for s , __tab , __ in cell_attributes : if s : bboxes . append ( ( s . get_grid_bbox ( code_array . shape ) , __tab ) ) cells = [ ] for ( ( bb_top , bb_left ) , ( bb_bottom , bb_right ) ) , __tab in bboxes : __bb_bottom = min ( bb_bottom , max_shape [ 0 ] ) __bb_right = min ( bb_right , max_shape [ 1 ] ) for __row , __col in product ( xrange ( bb_top , __bb_bottom + 1 ) , xrange ( bb_left , __bb_right + 1 ) ) : cells . append ( ( __row , __col , __tab ) ) cell_set = set ( cells ) for key in cell_set : if key not in code_array and all ( ele >= 0 for ele in key ) : row , col , tab = key style = self . _get_xfstyle ( worksheets , key ) worksheets [ tab ] . write ( row , col , label = "" , style = style )
Writes code to xls file
42,470
def _xls2code ( self , worksheet , tab ) : def xlrddate2datetime ( xlrd_date ) : try : xldate_tuple = xlrd . xldate_as_tuple ( xlrd_date , self . workbook . datemode ) return datetime ( xldate_tuple ) except ( ValueError , TypeError ) : return '' type2mapper = { 0 : lambda x : None , 1 : lambda x : str ( x ) , 2 : lambda x : str ( x ) , 3 : xlrddate2datetime , 4 : lambda x : str ( bool ( x ) ) , 5 : lambda x : str ( x ) , 6 : lambda x : None , } rows , cols = worksheet . nrows , worksheet . ncols for row , col in product ( xrange ( rows ) , xrange ( cols ) ) : cell_type = worksheet . cell_type ( row , col ) cell_value = worksheet . cell_value ( row , col ) key = row , col , tab mapper = type2mapper [ cell_type ] self . code_array [ key ] = mapper ( cell_value )
Updates code in xls code_array
42,471
def _get_font ( self , pys_style ) : if "textfont" not in pys_style : return font = xlwt . Font ( ) font . name = pys_style [ "textfont" ] if "pointsize" in pys_style : font . height = pys_style [ "pointsize" ] * 20.0 if "fontweight" in pys_style : font . bold = ( pys_style [ "fontweight" ] == wx . BOLD ) if "fontstyle" in pys_style : font . italic = ( pys_style [ "fontstyle" ] == wx . ITALIC ) if "textcolor" in pys_style : textcolor = wx . Colour ( ) textcolor . SetRGB ( pys_style [ "textcolor" ] ) font . colour_index = self . color2idx ( * textcolor . Get ( ) ) if "underline" in pys_style : font . underline_type = pys_style [ "underline" ] if "strikethrough" in pys_style : font . struck_out = pys_style [ "strikethrough" ] return font
Returns xlwt . Font for pyspread style
42,472
def _get_alignment ( self , pys_style ) : alignment_styles = [ "justification" , "vertical_align" , "angle" ] if not any ( astyle in pys_style for astyle in alignment_styles ) : return def angle2xfrotation ( angle ) : if 0 <= angle <= 90 : return angle elif - 90 <= angle < 0 : return 90 - angle return 0 justification2xfalign = { "left" : 1 , "center" : 2 , "right" : 3 , } vertical_align2xfalign = { "top" : 0 , "middle" : 1 , "bottom" : 2 , } alignment = xlwt . Alignment ( ) try : alignment . horz = justification2xfalign [ pys_style [ "justification" ] ] except KeyError : pass try : alignment . vert = vertical_align2xfalign [ pys_style [ "vertical_align" ] ] except KeyError : pass try : alignment . rota = angle2xfrotation ( pys_style [ "angle" ] ) except KeyError : pass return alignment
Returns xlwt . Alignment for pyspread style
42,473
def _get_pattern ( self , pys_style ) : if "bgcolor" not in pys_style : return pattern = xlwt . Pattern ( ) pattern . pattern = xlwt . Pattern . SOLID_PATTERN bgcolor = wx . Colour ( ) bgcolor . SetRGB ( pys_style [ "bgcolor" ] ) pattern . pattern_fore_colour = self . color2idx ( * bgcolor . Get ( ) ) return pattern
Returns xlwt . pattern for pyspread style
42,474
def _get_borders ( self , pys_style , pys_style_above , pys_style_left ) : border_keys = [ "borderwidth_right" , "borderwidth_bottom" , "bordercolor_right" , "bordercolor_bottom" , ] if not any ( border_key in pys_style for border_key in border_keys ) : return def width2border_line_style ( width ) : if width == 0 : return xlwt . Borders . NO_LINE if 0 < width < 2 : return xlwt . Borders . THIN if 2 <= width < 6 : return xlwt . Borders . MEDIUM if width >= 6 : return xlwt . Borders . THICK raise ValueError ( "Width {} unknown" . format ( width ) ) DEFAULT_LINE_STYLE = xlwt . Borders . THIN DEFAULT_COLOR_IDX = 0x16 borders = xlwt . Borders ( ) try : bottom_pys_style = pys_style [ "borderwidth_bottom" ] bottom_line_style = width2border_line_style ( bottom_pys_style ) except KeyError : bottom_line_style = DEFAULT_LINE_STYLE finally : borders . bottom = bottom_line_style try : right_pys_style = pys_style [ "borderwidth_right" ] right_line_style = width2border_line_style ( right_pys_style ) except KeyError : right_line_style = DEFAULT_LINE_STYLE finally : borders . right = right_line_style try : top_pys_style = pys_style_above [ "borderwidth_bottom" ] top_line_style = width2border_line_style ( top_pys_style ) except KeyError : top_line_style = DEFAULT_LINE_STYLE finally : borders . top = top_line_style try : left_pys_style = pys_style_left [ "borderwidth_right" ] left_line_style = width2border_line_style ( left_pys_style ) except KeyError : left_line_style = DEFAULT_LINE_STYLE finally : borders . left = left_line_style def _get_color_idx ( color ) : if color == get_color ( config [ "grid_color" ] ) : return DEFAULT_COLOR_IDX else : return self . color2idx ( * color . Get ( ) ) try : bottom_color_pys_style = pys_style [ "bordercolor_bottom" ] bcolor = wx . Colour ( ) bcolor . SetRGB ( bottom_color_pys_style ) bottom_color_idx = _get_color_idx ( bcolor ) except KeyError : bottom_color_idx = DEFAULT_COLOR_IDX finally : borders . bottom_colour = bottom_color_idx try : right_color_pys_style = pys_style [ "bordercolor_right" ] rcolor = wx . Colour ( ) rcolor . SetRGB ( right_color_pys_style ) right_colour_idx = _get_color_idx ( rcolor ) except KeyError : right_colour_idx = DEFAULT_COLOR_IDX finally : borders . right_colour = right_colour_idx try : top_color_pys_style = pys_style_above [ "bordercolor_bottom" ] tcolor = wx . Colour ( ) tcolor . SetRGB ( top_color_pys_style ) top_color_idx = _get_color_idx ( tcolor ) except KeyError : top_color_idx = DEFAULT_COLOR_IDX finally : borders . top_colour = top_color_idx try : left_color_pys_style = pys_style_left [ "bordercolor_right" ] lcolor = wx . Colour ( ) lcolor . SetRGB ( left_color_pys_style ) left_colour_idx = _get_color_idx ( lcolor ) except KeyError : left_colour_idx = DEFAULT_COLOR_IDX finally : borders . left_colour = left_colour_idx return borders
Returns xlwt . Borders for pyspread style
42,475
def _get_xfstyle ( self , worksheets , key ) : row , col , tab = key dict_grid = self . code_array . dict_grid dict_grid . cell_attributes . _update_table_cache ( ) pys_style = dict_grid . cell_attributes [ key ] pys_style_above = dict_grid . cell_attributes [ row - 1 , col , tab ] pys_style_left = dict_grid . cell_attributes [ row , col - 1 , tab ] xfstyle = xlwt . XFStyle ( ) font = self . _get_font ( pys_style ) if font is not None : xfstyle . font = font alignment = self . _get_alignment ( pys_style ) if alignment is not None : xfstyle . alignment = alignment pattern = self . _get_pattern ( pys_style ) if pattern is not None : xfstyle . pattern = pattern borders = self . _get_borders ( pys_style , pys_style_above , pys_style_left ) if borders is not None : xfstyle . borders = borders return xfstyle
Gets XFStyle for cell key
42,476
def _cell_attribute_append ( self , selection , tab , attributes ) : cell_attributes = self . code_array . cell_attributes thick_bottom_cells = [ ] thick_right_cells = [ ] if "borderwidth_bottom" in attributes : bwidth = attributes [ "borderwidth_bottom" ] for row , col in selection . cells : __bwidth = cell_attributes [ row , col , tab ] [ "borderwidth_bottom" ] if __bwidth > bwidth : thick_bottom_cells . append ( ( row , col ) ) if "borderwidth_right" in attributes : rwidth = attributes [ "borderwidth_right" ] for row , col in selection . cells : __rwidth = cell_attributes [ row , col , tab ] [ "borderwidth_right" ] if __rwidth > rwidth : thick_right_cells . append ( ( row , col ) ) for thick_cell in thick_bottom_cells + thick_right_cells : try : selection . cells . remove ( thick_cell ) except ValueError : pass cell_attributes . append ( ( selection , tab , attributes ) ) if thick_bottom_cells : bsel = copy ( selection ) bsel . cells = thick_bottom_cells battrs = copy ( attributes ) battrs . pop ( "borderwidth_bottom" ) cell_attributes . append ( ( bsel , tab , battrs ) ) if thick_right_cells : rsel = copy ( selection ) rsel . cells = thick_right_cells rattrs = copy ( attributes ) rattrs . pop ( "borderwidth_right" ) cell_attributes . append ( ( rsel , tab , rattrs ) )
Appends to cell_attributes with checks
42,477
def _row_heights2xls ( self , worksheets ) : xls_max_rows , xls_max_tabs = self . xls_max_rows , self . xls_max_tabs dict_grid = self . code_array . dict_grid for row , tab in dict_grid . row_heights : if row < xls_max_rows and tab < xls_max_tabs : height_pixels = dict_grid . row_heights [ ( row , tab ) ] height_inches = height_pixels / float ( get_dpi ( ) [ 1 ] ) height_points = height_inches * 72.0 worksheets [ tab ] . row ( row ) . height_mismatch = True worksheets [ tab ] . row ( row ) . height = int ( height_points * 20.0 )
Writes row_heights to xls file
42,478
def pys_width2xls_width ( self , pys_width ) : width_0 = get_default_text_extent ( "0" ) [ 0 ] width_0_char = pys_width * 1.2 / width_0 return int ( width_0_char * 256.0 )
Returns xls width from given pyspread width
42,479
def _col_widths2xls ( self , worksheets ) : xls_max_cols , xls_max_tabs = self . xls_max_cols , self . xls_max_tabs dict_grid = self . code_array . dict_grid for col , tab in dict_grid . col_widths : if col < xls_max_cols and tab < xls_max_tabs : pys_width = dict_grid . col_widths [ ( col , tab ) ] xls_width = self . pys_width2xls_width ( pys_width ) worksheets [ tab ] . col ( col ) . width = xls_width
Writes col_widths to xls file
42,480
def from_code_array ( self ) : worksheets = [ ] self . _shape2xls ( worksheets ) self . _code2xls ( worksheets ) self . _row_heights2xls ( worksheets ) self . _col_widths2xls ( worksheets ) return self . workbook
Returns xls workbook object with everything from code_array
42,481
def to_code_array ( self ) : self . _xls2shape ( ) worksheets = self . workbook . sheet_names ( ) for tab , worksheet_name in enumerate ( worksheets ) : worksheet = self . workbook . sheet_by_name ( worksheet_name ) self . _xls2code ( worksheet , tab ) self . _xls2attributes ( worksheet , tab ) self . _xls2row_heights ( worksheet , tab ) self . _xls2col_widths ( worksheet , tab )
Replaces everything in code_array from xls_file
42,482
def _split_tidy ( self , string , maxsplit = None ) : if maxsplit is None : return string . rstrip ( "\n" ) . split ( "\t" ) else : return string . rstrip ( "\n" ) . split ( "\t" , maxsplit )
Rstrips string for \ n and splits string for \ t
42,483
def _pys_assert_version ( self , line ) : if float ( line . strip ( ) ) > 1.0 : msg = _ ( "File version {version} unsupported (>1.0)." ) . format ( version = line . strip ( ) ) raise ValueError ( msg )
Asserts pys file version
42,484
def _shape2pys ( self ) : shape_line = u"\t" . join ( map ( unicode , self . code_array . shape ) ) + u"\n" self . pys_file . write ( shape_line )
Writes shape to pys file
42,485
def _code2pys ( self ) : for key in self . code_array : key_str = u"\t" . join ( repr ( ele ) for ele in key ) code_str = self . code_array ( key ) if code_str is not None : out_str = key_str + u"\t" + code_str + u"\n" self . pys_file . write ( out_str . encode ( "utf-8" ) )
Writes code to pys file
42,486
def _pys2code ( self , line ) : row , col , tab , code = self . _split_tidy ( line , maxsplit = 3 ) key = self . _get_key ( row , col , tab ) self . code_array . dict_grid [ key ] = unicode ( code , encoding = 'utf-8' )
Updates code in pys code_array
42,487
def _attributes2pys ( self ) : purged_cell_attributes = [ ] purged_cell_attributes_keys = [ ] for selection , tab , attr_dict in self . code_array . cell_attributes : if purged_cell_attributes_keys and ( selection , tab ) == purged_cell_attributes_keys [ - 1 ] : purged_cell_attributes [ - 1 ] [ 2 ] . update ( attr_dict ) else : purged_cell_attributes_keys . append ( ( selection , tab ) ) purged_cell_attributes . append ( [ selection , tab , attr_dict ] ) for selection , tab , attr_dict in purged_cell_attributes : sel_list = [ selection . block_tl , selection . block_br , selection . rows , selection . cols , selection . cells ] tab_list = [ tab ] attr_dict_list = [ ] for key in attr_dict : attr_dict_list . append ( key ) attr_dict_list . append ( attr_dict [ key ] ) if config [ "font_save_enabled" ] and key == 'textfont' : self . fonts_used . append ( attr_dict [ key ] ) line_list = map ( repr , sel_list + tab_list + attr_dict_list ) self . pys_file . write ( u"\t" . join ( line_list ) + u"\n" )
Writes attributes to pys file
42,488
def _row_heights2pys ( self ) : for row , tab in self . code_array . dict_grid . row_heights : if row < self . code_array . shape [ 0 ] and tab < self . code_array . shape [ 2 ] : height = self . code_array . dict_grid . row_heights [ ( row , tab ) ] height_strings = map ( repr , [ row , tab , height ] ) self . pys_file . write ( u"\t" . join ( height_strings ) + u"\n" )
Writes row_heights to pys file
42,489
def _col_widths2pys ( self ) : for col , tab in self . code_array . dict_grid . col_widths : if col < self . code_array . shape [ 1 ] and tab < self . code_array . shape [ 2 ] : width = self . code_array . dict_grid . col_widths [ ( col , tab ) ] width_strings = map ( repr , [ col , tab , width ] ) self . pys_file . write ( u"\t" . join ( width_strings ) + u"\n" )
Writes col_widths to pys file
42,490
def _macros2pys ( self ) : macros = self . code_array . dict_grid . macros pys_macros = macros . encode ( "utf-8" ) self . pys_file . write ( pys_macros )
Writes macros to pys file
42,491
def _pys2macros ( self , line ) : if self . code_array . dict_grid . macros and self . code_array . dict_grid . macros [ - 1 ] != "\n" : self . code_array . dict_grid . macros += "\n" self . code_array . dict_grid . macros += line . decode ( "utf-8" )
Updates macros in code_array
42,492
def _fonts2pys ( self ) : system_fonts = font_manager . findSystemFonts ( ) font_name2font_file = { } for sys_font in system_fonts : font_name = font_manager . FontProperties ( fname = sys_font ) . get_name ( ) if font_name in self . fonts_used : font_name2font_file [ font_name ] = sys_font for font_name in font_name2font_file : with open ( font_name2font_file [ font_name ] ) as fontfile : font_data = fontfile . read ( ) ascii_font_data = base64 . b64encode ( font_data ) font_line_list = [ font_name , ascii_font_data ] self . pys_file . write ( u"\t" . join ( font_line_list ) + u"\n" )
Writes fonts to pys file
42,493
def _pys2fonts ( self , line ) : font_name , ascii_font_data = self . _split_tidy ( line ) font_data = base64 . b64decode ( ascii_font_data ) system_fonts = font_manager . findSystemFonts ( ) system_font_names = [ ] for sys_font in system_fonts : system_font_names . append ( font_manager . FontProperties ( fname = sys_font ) . get_name ( ) ) if font_name not in system_font_names : self . code_array . custom_fonts [ font_name ] = font_data with open ( self . temp_fontdir + os . sep + font_name , "wb" ) as font_file : font_file . write ( font_data ) with tempfile . NamedTemporaryFile ( ) as fontsconf_tmpfile : fontsconf_tmpfile_name = fontsconf_tmpfile . name fontsconf_tmpfile . write ( self . temp_fontdir ) os . environ [ "FONTCONFIG_FILE" ] = fontsconf_tmpfile_name
Updates custom font list
42,494
def from_code_array ( self ) : for key in self . _section2writer : self . pys_file . write ( key ) self . _section2writer [ key ] ( ) try : if self . pys_file . aborted : break except AttributeError : pass if config [ "font_save_enabled" ] : self . fonts_used = [ ]
Replaces everything in pys_file from code_array
42,495
def to_code_array ( self ) : state = None first_line = True self . pys_file . seek ( 0 ) for line in self . pys_file : if first_line : if line == "[Pyspread save file version]\n" : first_line = False else : raise ValueError ( _ ( "File format unsupported." ) ) if line in self . _section2reader : state = line elif state is not None : self . _section2reader [ state ] ( line )
Replaces everything in code_array from pys_file
42,496
def _style ( self ) : self . fold_symbols = 2 self . faces = { 'times' : 'Times' , 'mono' : 'Courier' , 'helv' : wx . SystemSettings . GetFont ( wx . SYS_DEFAULT_GUI_FONT ) . GetFaceName ( ) , 'other' : 'new century schoolbook' , 'size' : 10 , 'size2' : 8 , } white = "white" gray = "#404040" self . fold_symbol_style = [ ( stc . STC_MARKNUM_FOLDEROPEN , stc . STC_MARK_CIRCLEMINUS , white , gray ) , ( stc . STC_MARKNUM_FOLDER , stc . STC_MARK_CIRCLEPLUS , white , gray ) , ( stc . STC_MARKNUM_FOLDERSUB , stc . STC_MARK_VLINE , white , gray ) , ( stc . STC_MARKNUM_FOLDERTAIL , stc . STC_MARK_LCORNERCURVE , white , gray ) , ( stc . STC_MARKNUM_FOLDEREND , stc . STC_MARK_CIRCLEPLUSCONNECTED , white , gray ) , ( stc . STC_MARKNUM_FOLDEROPENMID , stc . STC_MARK_CIRCLEMINUSCONNECTED , white , gray ) , ( stc . STC_MARKNUM_FOLDERMIDTAIL , stc . STC_MARK_TCORNERCURVE , white , gray ) , ] self . text_styles = [ ( stc . STC_STYLE_DEFAULT , "face:%(helv)s,size:%(size)d" % self . faces ) , ( stc . STC_STYLE_LINENUMBER , "back:#C0C0C0,face:%(helv)s,size:%(size2)d" % self . faces ) , ( stc . STC_STYLE_CONTROLCHAR , "face:%(other)s" % self . faces ) , ( stc . STC_STYLE_BRACELIGHT , "fore:#FFFFFF,back:#0000FF,bold" ) , ( stc . STC_STYLE_BRACEBAD , "fore:#000000,back:#FF0000,bold" ) , ( stc . STC_P_DEFAULT , "fore:#000000,face:%(helv)s,size:%(size)d" % self . faces ) , ( stc . STC_P_COMMENTLINE , "fore:#007F00,face:%(other)s,size:%(size)d" % self . faces ) , ( stc . STC_P_NUMBER , "fore:#007F7F,size:%(size)d" % self . faces ) , ( stc . STC_P_STRING , "fore:#7F007F,face:%(helv)s,size:%(size)d" % self . faces ) , ( stc . STC_P_CHARACTER , "fore:#7F007F,face:%(helv)s,size:%(size)d" % self . faces ) , ( stc . STC_P_WORD , "fore:#00007F,bold,size:%(size)d" % self . faces ) , ( stc . STC_P_TRIPLE , "fore:#7F0000,size:%(size)d" % self . faces ) , ( stc . STC_P_TRIPLEDOUBLE , "fore:#7F0000,size:%(size)d" % self . faces ) , ( stc . STC_P_CLASSNAME , "fore:#0000FF,bold,underline,size:%(size)d" % self . faces ) , ( stc . STC_P_DEFNAME , "fore:#007F7F,bold,size:%(size)d" % self . faces ) , ( stc . STC_P_OPERATOR , "bold,size:%(size)d" % self . faces ) , ( stc . STC_P_IDENTIFIER , "fore:#000000,face:%(helv)s,size:%(size)d" % self . faces ) , ( stc . STC_P_COMMENTBLOCK , "fore:#7F7F7F,size:%(size)d" % self . faces ) , ( stc . STC_P_STRINGEOL , "fore:#000000,face:%(mono)s,back:#E0C0E0,eol,size:%(size)d" % self . faces ) , ]
Set editor style
42,497
def OnUpdateUI ( self , evt ) : brace_at_caret = - 1 brace_opposite = - 1 char_before = None caret_pos = self . GetCurrentPos ( ) if caret_pos > 0 : char_before = self . GetCharAt ( caret_pos - 1 ) style_before = self . GetStyleAt ( caret_pos - 1 ) if char_before and chr ( char_before ) in "[]{}()" and style_before == stc . STC_P_OPERATOR : brace_at_caret = caret_pos - 1 if brace_at_caret < 0 : char_after = self . GetCharAt ( caret_pos ) style_after = self . GetStyleAt ( caret_pos ) if char_after and chr ( char_after ) in "[]{}()" and style_after == stc . STC_P_OPERATOR : brace_at_caret = caret_pos if brace_at_caret >= 0 : brace_opposite = self . BraceMatch ( brace_at_caret ) if brace_at_caret != - 1 and brace_opposite == - 1 : self . BraceBadLight ( brace_at_caret ) else : self . BraceHighlight ( brace_at_caret , brace_opposite )
Syntax highlighting while editing
42,498
def OnMarginClick ( self , evt ) : if evt . GetMargin ( ) == 2 : if evt . GetShift ( ) and evt . GetControl ( ) : self . fold_all ( ) else : line_clicked = self . LineFromPosition ( evt . GetPosition ( ) ) if self . GetFoldLevel ( line_clicked ) & stc . STC_FOLDLEVELHEADERFLAG : if evt . GetShift ( ) : self . SetFoldExpanded ( line_clicked , True ) self . expand ( line_clicked , True , True , 1 ) elif evt . GetControl ( ) : if self . GetFoldExpanded ( line_clicked ) : self . SetFoldExpanded ( line_clicked , False ) self . expand ( line_clicked , False , True , 0 ) else : self . SetFoldExpanded ( line_clicked , True ) self . expand ( line_clicked , True , True , 100 ) else : self . ToggleFold ( line_clicked )
When clicked old and unfold as needed
42,499
def expand ( self , line , do_expand , force = False , vislevels = 0 , level = - 1 ) : lastchild = self . GetLastChild ( line , level ) line += 1 while line <= lastchild : if force : if vislevels > 0 : self . ShowLines ( line , line ) else : self . HideLines ( line , line ) elif do_expand : self . ShowLines ( line , line ) if level == - 1 : level = self . GetFoldLevel ( line ) if level & stc . STC_FOLDLEVELHEADERFLAG : if force : self . SetFoldExpanded ( line , vislevels - 1 ) line = self . expand ( line , do_expand , force , vislevels - 1 ) else : expandsub = do_expand and self . GetFoldExpanded ( line ) line = self . expand ( line , expandsub , force , vislevels - 1 ) else : line += 1 return line
Multi - purpose expand method from original STC class