From 4db1a045a0606bead191a563abc54dfa8352efe0 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 29 Aug 2012 23:26:17 -0400 Subject: Rewrite commands to use bugdirs instead of a single bugdir. The bulk of the work is in regard to XML, with new BugDir.xml and .from_xml methods to support the new entity. I also split the guts import_xml's ._run method into sub-methods to make the import logic more obvious. --- libbe/command/base.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'libbe/command/base.py') diff --git a/libbe/command/base.py b/libbe/command/base.py index d814d7c..b9038a0 100644 --- a/libbe/command/base.py +++ b/libbe/command/base.py @@ -522,7 +522,7 @@ class StorageCallbacks (object): def setup_command(self, command): command._get_unconnected_storage = self.get_unconnected_storage command._get_storage = self.get_storage - command._get_bugdir = self.get_bugdir + command._get_bugdirs = self.get_bugdirs def get_unconnected_storage(self): """ @@ -555,15 +555,20 @@ class StorageCallbacks (object): def set_storage(self, storage): self._storage = storage - def get_bugdir(self): + def get_bugdirs(self): """Callback for use by commands that need it.""" - if not hasattr(self, '_bugdir'): - self._bugdir = libbe.bugdir.BugDir(self.get_storage(), - from_storage=True) - return self._bugdir - - def set_bugdir(self, bugdir): - self._bugdir = bugdir + if not hasattr(self, '_bugdirs'): + storage = self.get_storage() + self._bugdirs = dict( + (uuid, libbe.bugdir.BugDir( + storage=storage, + uuid=uuid, + from_storage=True)) + for uuid in storage.children()) + return self._bugdirs + + def set_bugdirs(self, bugdirs): + self._bugdirs = bugdirs def cleanup(self): if hasattr(self, '_storage'): -- cgit