From: Mark Hymers Date: Sat, 25 Apr 2009 18:44:41 +0000 (+0100) Subject: add suite_arch routine X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3aaef9d2b20417a631d59a990dfdfb188cf3f102;p=dak add suite_arch routine Signed-off-by: Mark Hymers --- 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}.