From: Ansgar Burchardt Date: Wed, 7 May 2014 17:57:29 +0000 (+0200) Subject: get_source_in_suite: return None if suite does not exist X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=bdd3bf92a9dbccf8313b7f0bad97381f5f51a189;p=dak.git get_source_in_suite: return None if suite does not exist --- diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 98830936..624ff8b5 100644 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -2089,27 +2089,28 @@ __all__.append('get_sources_from_name') # FIXME: This function fails badly if it finds more than 1 source package and # its implementation is trivial enough to be inlined. @session_wrapper -def get_source_in_suite(source, suite, session=None): +def get_source_in_suite(source, suite_name, session=None): """ - Returns a DBSource object for a combination of C{source} and C{suite}. + Returns a DBSource object for a combination of C{source} and C{suite_name}. - B{source} - source package name, eg. I{mailfilter}, I{bbdb}, I{glibc} - - B{suite} - a suite name, eg. I{unstable} + - B{suite_name} - a suite name, eg. I{unstable} @type source: string @param source: source package name - @type suite: string + @type suite_name: string @param suite: the suite name @rtype: string @return: the version for I{source} in I{suite} """ - - q = get_suite(suite, session).get_sources(source) + suite = get_suite(suite_name, session) + if suite is None: + return None try: - return q.one() + return suite.get_sources(source).one() except NoResultFound: return None