[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] add suite_arch routine



Signed-off-by: Mark Hymers <mhy@debian.org>
---
 daklib/dbconn.py |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/daklib/dbconn.py b/daklib/dbconn.py
index 423e026..5a7dc52 100755
--- a/daklib/dbconn.py
+++ b/daklib/dbconn.py
@@ -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}.
-- 
1.5.6.5



Reply to: