From bdd3bf92a9dbccf8313b7f0bad97381f5f51a189 Mon Sep 17 00:00:00 2001 From: Ansgar Burchardt Date: Wed, 7 May 2014 19:57:29 +0200 Subject: [PATCH] get_source_in_suite: return None if suite does not exist --- daklib/dbconn.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 -- 2.39.5