From d86deb6427c2cb171d65fa4d887782ec8ab821b7 Mon Sep 17 00:00:00 2001 From: Mark Hymers Date: Fri, 24 Jul 2009 22:01:21 +0100 Subject: [PATCH] add methods for easily finding suites for src/bin packages Signed-off-by: Mark Hymers --- daklib/dbconn.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 66921b85..7d460760 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -171,6 +171,24 @@ class DBBinary(object): __all__.append('DBBinary') +def get_suites_binary_in(package, session=None): + """ + Returns list of Suite objects which given C{package} name is in + + @type source: str + @param source: DBBinary package name to search for + + @rtype: list + @return: list of Suite objects for the given package + """ + + if session is None: + session = DBConn().session() + + return session.query(Suite).join(BinAssociation).join(DBBinary).filter_by(package=package).all() + +__all__.append('get_suites_binary_in') + def get_binary_from_id(id, session=None): """ Returns DBBinary object for given C{id} @@ -1288,6 +1306,24 @@ def source_exists(source, source_version, suites = ["any"], session=None): __all__.append('source_exists') +def get_suites_source_in(source, session=None): + """ + Returns list of Suite objects which given C{source} name is in + + @type source: str + @param source: DBSource package name to search for + + @rtype: list + @return: list of Suite objects for the given source + """ + + if session is None: + session = DBConn().session() + + return session.query(Suite).join(SrcAssociation).join(DBSource).filter_by(source=source).all() + +__all__.append('get_suites_source_in') + def get_sources_from_name(source, version=None, dm_upload_allowed=None, session=None): """ Returns list of DBSource objects for given C{source} name and other parameters -- 2.39.5