From 25f78d823aecc3c9969a527eb4b700961ac9e056 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Tue, 19 Feb 2008 14:40:57 +0000 Subject: [PATCH] get_operation and get_till_operation --- pisi/db/historydb.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pisi/db/historydb.py b/pisi/db/historydb.py index fc0038ef..bea956cc 100644 --- a/pisi/db/historydb.py +++ b/pisi/db/historydb.py @@ -46,6 +46,24 @@ class HistoryDB(lazydb.LazyDB): def update_history(self): self.history.update() + def get_operation(self, operation): + for log in self.__logs: + if log.startswith("%03d_" % operation): + hist = pisi.history.History(os.path.join(ctx.config.history_dir(), log)) + return hist.operation + return None + + def get_till_operation(self, operation): + if not filter(lambda x:x.startswith("%03d_" % operation), self.__logs): + return + + for log in self.__logs: + if log.startswith("%03d_" % operation): + return + + hist = pisi.history.History(os.path.join(ctx.config.history_dir(), log)) + yield hist.operation + def get_last(self, count=0): count = count or len(self.__logs) for log in self.__logs[:count]: