# This file is part of Recently Used Desklet # # Recently Used Desklet is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # Recently Used Desklet is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with Recently Used Desklet; if not, write to the Free # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA # 02111-1307 USA from xml.sax import make_parser from xml.sax.handler import feature_namespaces from xml.sax import saxutils from RecentParser import RecentParser # # Reader for .desktop files. # class RecentReader: def __init__(self, filename, theme): self.__parser = make_parser() # Tell the parser we are not interested in XML namespaces self.__parser.setFeature(feature_namespaces, 0) dh = RecentParser(theme) # Tell the parser to use our handler self.__parser.setContentHandler(dh) self.__parser.parse(filename) self.__recent_list = dh.get_recent_files() def get_recent_files(self): # sort these files by timestamp self.__recent_list.sort( lambda x,y: -(x.get_timestamp() > y.get_timestamp()) ) return self.__recent_list # DEPRECATED, cause it don't work def __cmp_timestamp(self, x, y): if ( x.get_timestamp() > y.get_timestamp() ): return -1 if ( x.get_timestamp() < y.get_timestamp() ): return 1 return 0