+def get_suite_version(source, suite):
+ """
+ Returns database id for a combination of C{source} and C{suite}.
+
+ - B{source} - source package name, eg. I{mailfilter}, I{bbdb}, I{glibc}
+ - B{suite} - a suite name, eg. I{unstable}
+
+ Results are kept in a cache during runtime to minimize database queries.
+
+ @type source: string
+ @param source: source package name
+
+ @type suite: string
+ @param suite: the suite name
+
+ @rtype: string
+ @return: the version for I{source} in I{suite}
+
+ """
+ global suite_version_cache
+ cache_key = "%s_%s" % (source, suite)
+
+ if suite_version_cache.has_key(cache_key):
+ return suite_version_cache[cache_key]
+
+ q = projectB.query("""
+ SELECT s.version FROM source s, suite su, src_associations sa
+ WHERE sa.source=s.id
+ AND sa.suite=su.id
+ AND su.suite_name='%s'
+ AND s.source='%s'"""
+ % (suite, source))
+
+ if not q.getresult():
+ return None
+
+ version = q.getresult()[0][0]
+ suite_version_cache[cache_key] = version
+
+ return version
+
+def get_suite_architectures(suite):
+ """
+ Returns list of architectures for C{suite}.
+
+ @type suite: string, int
+ @param suite: the suite name or the suite_id
+
+ @rtype: list
+ @return: the list of architectures for I{suite}
+ """
+
+ suite_id = None
+ if type(suite) == str:
+ suite_id = get_suite_id(suite)
+ elif type(suite) == int:
+ suite_id = suite
+ else:
+ return None
+
+ sql = """ SELECT a.arch_string FROM suite_architectures sa
+ JOIN architecture a ON (a.id = sa.architecture)
+ WHERE suite='%s' """ % (suite_id)
+
+ q = projectB.query(sql)
+ return map(lambda x: x[0], q.getresult())
+
+