=== modified file 'launchpadbugs/bugbase.py' --- launchpadbugs/bugbase.py 2008-01-09 22:31:45 +0000 +++ launchpadbugs/bugbase.py 2008-02-27 20:22:52 +0000 @@ -330,4 +330,15 @@ def get_date_updated(self): raise NotImplementedError, 'this method must be implemented by a concrete subclass' date_updated = LateBindingProperty(get_date_updated, doc="returns date when bugreport was updated") + + + ######################################################################### + # attached branches + ######################################################################### + + + def get_branches(self): + raise NotImplementedError, 'this method must be implemented by a concrete subclass' + branches = LateBindingProperty(get_branches, doc="returns list of attached bzr branches") + === modified file 'launchpadbugs/html_bug.py' --- launchpadbugs/html_bug.py 2008-02-11 18:55:14 +0000 +++ launchpadbugs/html_bug.py 2008-02-27 20:43:33 +0000 @@ -1150,6 +1150,63 @@ def commit(self, force_changes=False, ignore_lp_errors=True): raise NotImplementedError, 'this method is not implemented ATM' + +class BzrBranch(object): + def __init__(self, title, url, status): + self.__title = title + self.__url = url + self.__status = status + + def __repr__(self): + return "BzrBranch(%s, %s, %s)" %(self.title, self.url, self.status) + + __str__ = __repr__ + + @property + def title(self): + return self.__title + + @property + def url(self): + return self.__url + + @property + def status(self): + return self.__status + + + +class Branches(set): + def __init__(self, connection, xml, url): + self.parsed = False + set.__init__(self) + self.__url = url + self.__xml = xml + self.__connection = connection + + def parse(self): + if self.parsed: + return True + for i in self.__xml: + m = i.xpathEval("a[1]") + assert m + title = m[0].prop("title") + url = m[0].prop("href") + m = i.xpathEval("span") + assert m + status = m[0].content + self.add(BzrBranch(title, url, status)) + self.parsed = True + + @property + def changed(self): + """get a list of changed attributes + currently read-only + """ + return set() + + def commit(self, force_changes=False, ignore_lp_errors=True): + raise NotImplementedError, 'this method is not implemented ATM' class Bug(BugBase): @@ -1182,6 +1239,7 @@ self.__subscribers = Subscribers(connection=self.__connection, xml=self.xmldoc.xpathEval('//body//div[@id="portlet-subscribers"]//div/ul'), url=self.__url) self.__mentor = Mentoring(connection=self.__connection, xml=self.xmldoc.xpathEval('//body//img [@src="/@@/mentoring"]/parent::p//a'), url=self.__url) self.__activity = ActivityLog(connection=self.__connection, url=self.__url) + self.__branches = Branches(connection=self.__connection, url=self.__url, xml=self.xmldoc.xpathEval('//body//div[@class="bug-branch-summary"]')) Bug._container_refs[id(self.__attachments)] = self Bug._container_refs[id(self.__comments)] = self @@ -1299,6 +1357,8 @@ if not self.__subscribers.parsed: self.__subscribers.parse() return self.__subscribers.get_subscriptions(type) + + get_branches = _gen_getter("__branches")