#!/usr/bin/python -tt import yum import sys import time def enc(s): # this sucks. what we get back from the rpmdb # are strings, but they may actually have unicode so we # can't encode them if type(s) == unicode: return s.encode("UTF-8") return s my = yum.YumBase() now = time.time() year_ago = now - 31536000 old = open('old-repo.txt', 'w') new = open('new-repo.txt', 'w') item = 1 newestpkgs = my.pkgSack.returnNewestByNameArch() total=len(newestpkgs) for pkg in newestpkgs: print '%s/%s' % (item, total) item += 1 for (when, who, what) in pkg.changelog: msg = "* %s %s\n%s\n" % (time.ctime(int(when)), enc(who), enc(what)) if int(when) > int(year_ago): new.write(msg) else: old.write(msg) old.close() new.close() old = open('old-db.txt', 'w') new = open('new-db.txt', 'w') item = 1 newestpkgs = my.rpmdb.returnPackages() total = len(newestpkgs) for pkg in newestpkgs: print '%s/%s' % (item, total) item += 1 for (when, who, what) in pkg.changelog: msg = "* %s %s\n%s\n" % (time.ctime(int(when)), enc(who), enc(what)) if int(when) > int(year_ago): new.write(msg) else: old.write(msg) old.close() new.close()