import apt import cPickle import pdb cache = apt.Cache() progress = apt.progress.OpTextProgress() to_add = [] datadir = "/usr/share/app-install" desktopdir = "/usr/share/app-install" cachedir = "/var/cache/app-install" treeview_categories = gtk.TreeView() treeview_packages = gtk.TreeView() menu = CoreApplicationMenu(datadir) menu.pickle = cPickle.load(open("/var/cache/app-install/menu.p")) available = [] available_extras = [] installed = [] installed_extras = [] print menu.pickle.keys() for app in menu.pickle[menu.pickle.keys()[0]]: if cache.has_key(app.pkgname) and cache[app.pkgname].is_installed: if app.execCmd: installed.append(app) else: installed_extras.append(app) else:
if __name__ == "__main__": parser = OptionParser() parser.add_option("-s", "--srcdir", dest="srcdir", default="/usr/share/app-install/desktop/", help="directory for the menu-data") parser.add_option("-d", "--destdir", dest="destdir", default="output", help="dir for the output") (options, args) = parser.parse_args() # get a cache cache = apt.Cache() # read menu menu = CoreApplicationMenu(options.srcdir) root = xdg.Menu.parse(os.path.join(options.srcdir, "applications.menu")) menu._populateFromEntry(root) # output per section index_file = open(os.path.join(options.destdir,"sections.txt"),"w") sections = menu.pickle.keys() sections.sort() for section in sections: name = unescape(section.name) index_file.write("%s\n" % name) section_file = open(os.path.join(options.destdir,name+".txt"),"w") for app in menu.pickle[section]: if not cache.has_key(app.pkgname): print "ERROR: can't find '%s' in apt cache" % app.pkgname continue