From fed3b566846f78305cdec26640ca40e381f84fab Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Mon, 10 Mar 2008 09:17:34 +0000 Subject: [PATCH] sourcedb may not have it or packagedb may not have it --- pisi/db/componentdb.py | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/pisi/db/componentdb.py b/pisi/db/componentdb.py index 4c26aa3c..41221479 100644 --- a/pisi/db/componentdb.py +++ b/pisi/db/componentdb.py @@ -91,6 +91,10 @@ class ComponentDB(lazydb.LazyDB): try: component.packages = self.cpdb.get_item(component_name, repo) + except Exception: #FIXME: what exception could we catch here, replace with that. + pass + + try: component.sources = self.csdb.get_item(component_name, repo) except Exception: #FIXME: what exception could we catch here, replace with that. pass @@ -106,6 +110,10 @@ class ComponentDB(lazydb.LazyDB): for repo in self.repodb.list_repos(): try: component.packages.extend(self.cpdb.get_item(component_name, repo)) + except Exception: #FIXME: what exception could we catch here, replace with that. + pass + + try: component.sources.extend(self.csdb.get_item(component_name, repo)) except Exception: #FIXME: what exception could we catch here, replace with that. pass @@ -152,3 +160,45 @@ class ComponentDB(lazydb.LazyDB): pass return packages + + # Returns sources of given component from given repo or first found component's packages in repo + # order if repo is None. + # If walk is True than also the sub components' packages are returned + def get_sources(self, component_name, repo=None, walk=False): + + component = self.get_component(component_name, repo) + if not walk: + return component.sources + + sources = [] + sources.extend(component.sources) + + sub_components = filter(lambda x:x.startswith(component_name+"."), self.list_components(repo)) + for sub in sub_components: + try: + sources.extend(self.get_component(sub, repo).sources) + except Exception: #FIXME: what exception could we catch here, replace with that. + pass + + return sources + + # Returns the component with combined packages and sources from all repos that contain this component + # If walk is True than also the sub components' sources from all repos are returned + def get_union_sources(self, component_name, walk=False): + + component = self.get_union_component(component_name) + if not walk: + return component.sources + + sources = [] + sources.extend(component.sources) + + sub_components = filter(lambda x:x.startswith(component_name+"."), self.list_components()) + for sub in sub_components: + try: + sources.extend(self.get_union_component(sub).sources) + except Exception: #FIXME: what exception could we catch here, replace with that. + pass + + return sources +