#NEWLINE# def scan_applications( self ) : #NEWLINE# #INDENT# paths = self . system_path ( ) #NEWLINE# applications = [ ] #NEWLINE# for app_path in self . application_paths ( ) : #NEWLINE# #INDENT# for filename in os . listdir ( app_path ) : #NEWLINE# #INDENT# pathname = os . path . join ( app_path , filename ) #NEWLINE# if os . path . isfile ( pathname ) : #NEWLINE# #INDENT# with codecs . open ( pathname , 'r' , encoding = system_encoding , errors = 'ignore' ) as f : #NEWLINE# #INDENT# name = None #NEWLINE# command = None #NEWLINE# terminal = None #NEWLINE# for line in f . readlines ( ) : #NEWLINE# #INDENT# if ( line [ 0 : 5 ] == 'Exec=' ) : #NEWLINE# #INDENT# command_tmp = line [ 5 : ( - 1 ) ] . split ( ) #NEWLINE# command = '' #NEWLINE# space = '' #NEWLINE# for piece in line : #NEWLINE# #INDENT# if ( piece . find ( '%' ) == ( - 1 ) ) : #NEWLINE# #INDENT# command += ( space + piece ) #NEWLINE# space = ' ' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( line [ 0 : 5 ] == 'Name=' ) : #NEWLINE# #INDENT# name = line [ 5 : ( - 1 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( line [ 0 : 9 ] == 'Terminal=' ) : #NEWLINE# #INDENT# if ( line [ 9 : ( - 1 ) ] . lower ( ) == 'true' ) : #NEWLINE# #INDENT# terminal = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# terminal = False #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( ( name is not None ) and ( command is not None ) ) : #NEWLINE# #INDENT# if ( terminal is None ) : #NEWLINE# #INDENT# terminal = False #NEWLINE# #UNINDENT# for path in paths : #NEWLINE# #INDENT# if ( command [ 0 : len ( path ) ] == path ) : #NEWLINE# #INDENT# if ( command [ ( len ( path ) + 1 ) : ] . find ( '/' ) == ( - 1 ) ) : #NEWLINE# #INDENT# command = command [ ( len ( path ) + 1 ) : ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# applications . append ( { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'command' : command , #NEWLINE# 'terminal' : terminal , #NEWLINE# 'descriptor' : filename . replace ( '.desktop' , '' ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return applications