From 2a55cae9d7767e2a3259e27e6b1ac6603e27b025 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Mon, 16 Jun 2008 08:34:58 +0000 Subject: [PATCH] get operation config info --- pisi/db/historydb.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/pisi/db/historydb.py b/pisi/db/historydb.py index dd04c513..a47434ee 100644 --- a/pisi/db/historydb.py +++ b/pisi/db/historydb.py @@ -25,7 +25,7 @@ class HistoryDB(lazydb.LazyDB): def init(self): self.__logs = self.__generate_history() - + def __generate_history(self): logs = filter(lambda x:x.endswith(".xml"), os.listdir(ctx.config.history_dir())) logs.sort() @@ -69,6 +69,30 @@ class HistoryDB(lazydb.LazyDB): return hist.operation return None + def get_package_config_files(self, operation, package): + package_path = os.path.join(ctx.config.history_dir(), "%03d/%s" % (operation, package)) + if not os.path.exists(package_path): + return None + + configs = [] + for root, dirs, files in os.walk(package_path): + for f in files: + configs.append(("%s/%s" % (root, f))) + + return configs + + def get_config_files(self, operation): + config_path = os.path.join(ctx.config.history_dir(), "%03d" % operation) + if not os.path.exists(config_path): + return None + + allconfigs = {} + packages = os.listdir(config_path) + for package in packages: + allconfigs[package] = self.get_package_config_files(operation, package) + + return allconfigs + def get_till_operation(self, operation): if not filter(lambda x:x.startswith("%03d_" % operation), self.__logs): return