From 3aaef9d2b20417a631d59a990dfdfb188cf3f102 Mon Sep 17 00:00:00 2001 From: Mark Hymers Date: Sat, 25 Apr 2009 19:44:41 +0100 Subject: [PATCH] add suite_arch routine Signed-off-by: Mark Hymers --- daklib/dbconn.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 423e0260..5a7dc52d 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -467,6 +467,36 @@ class Suite(object): def __repr__(self): return '' % self.suite_name +def get_suite_architecture(suite, architecture, session=None): + """ + Returns a SuiteArchitecture object given C{suite} and ${arch} or None if it + doesn't exist + + @type suite: str + @param suite: Suite name to search for + + @type architecture: str + @param architecture: Architecture name to search for + + @type session: Session + @param session: Optional SQL session object (a temporary one will be + generated if not supplied) + + @rtype: SuiteArchitecture + @return: the SuiteArchitecture object or None + """ + + if session is None: + session = DBConn().session() + + q = session.query(SuiteArchitecture) + q = q.join(Architecture).filter_by(arch_string=architecture) + q = q.join(Suite).filter_by(suite_name=suite) + if q.count() == 0: + return None + return q.one() + + def get_suite(suite, session=None): """ Returns Suite object for given C{suite name}. -- 2.39.5