]> git.decadent.org.uk Git - dak.git/commitdiff
add suite_arch routine
authorMark Hymers <mhy@debian.org>
Sat, 25 Apr 2009 18:44:41 +0000 (19:44 +0100)
committerMark Hymers <mhy@debian.org>
Sun, 9 Aug 2009 15:49:20 +0000 (16:49 +0100)
Signed-off-by: Mark Hymers <mhy@debian.org>
daklib/dbconn.py

index 423e026081301ca627f8dc9978ce39afb6066ef5..5a7dc52dc1b183b7d32a60ef0004b94616f5e2b7 100755 (executable)
@@ -467,6 +467,36 @@ class Suite(object):
     def __repr__(self):
         return '<Suite %s>' % 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}.