(self, path=None)
return result
Save the sorted application list.
Save the sorted application list.
Save the sorted application list .
def save(self, path=None):
        """Save the sorted application list."""
        result = []
        for executable, names in iteritems(self.data):
            for ext in self.extensions:
                if executable.lower().endswith(ext):
                    for window_name, app_name in iteritems(names):
                        if window_name is None:
                            if app_name == executable[:-self.extensions[ext]['len']]:
                                result.append(unicode(executable))
                            else:
                                result.append(u'{}: {}'.format(executable, app_name))
                        else:
                            if window_name == app_name:
                                result.append(u'{}[{}]'.format(executable, window_name))
                            else:
                                result.append(u'{}[{}]: {}'.format(executable, window_name, app_name))
                    break
        result = '\r\n'.join(_DEFAULT_TEXT + [''] + sorted(result, key=unicode.lower))
        
        if path is None:
            path = self.path
        with TextFile(path, 'wb', encoding='utf-8') as f:
            f.write(result.encode('utf-8'))
        return result
def save ( self , path = None ) : result = [ ] for executable , names in iteritems ( self . data ) : for ext in self . extensions : if executable . lower ( ) . endswith ( ext ) : for window_name , app_name in iteritems ( names ) : if window_name is None : if app_name == executable [ : - self . extensions [ ext ] [ 'len' ] ] : result . append ( unicode ( executable ) ) else : result . append ( u'{}: {}' . format ( executable , app_name ) ) else : if window_name == app_name : result . append ( u'{}[{}]' . format ( executable , window_name ) ) else : result . append ( u'{}[{}]: {}' . format ( executable , window_name , app_name ) ) break result = '\r\n' . join ( _DEFAULT_TEXT + [ '' ] + sorted ( result , key = unicode . lower ) ) if path is None : path = self . path with TextFile ( path , 'wb' , encoding = 'utf-8' ) as f : f . write ( result . encode ( 'utf-8' ) ) return result