[dak/master] add get_sections and get_priorities
Signed-off-by: Mark Hymers <mhy@debian.org>
---
daklib/dbconn.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/daklib/dbconn.py b/daklib/dbconn.py
index 43c0b69..22fa262 100755
--- a/daklib/dbconn.py
+++ b/daklib/dbconn.py
@@ -1233,6 +1233,29 @@ def get_priority(priority, session=None):
__all__.append('get_priority')
+def get_priorities(session=None):
+ """
+ Returns dictionary of priority names -> id mappings
+
+ @type session: Session
+ @param session: Optional SQL session object (a temporary one will be
+ generated if not supplied)
+
+ @rtype: dictionary
+ @return: dictionary of priority names -> id mappings
+ """
+ if session is None:
+ session = DBConn().session()
+
+ ret = {}
+ q = session.query(Priority)
+ for x in q.all():
+ ret[x.priority] = x.priority_id
+
+ return ret
+
+__all__.append('get_priorities')
+
################################################################################
class Queue(object):
@@ -1469,6 +1492,29 @@ def get_section(section, session=None):
__all__.append('get_section')
+def get_sections(session=None):
+ """
+ Returns dictionary of section names -> id mappings
+
+ @type session: Session
+ @param session: Optional SQL session object (a temporary one will be
+ generated if not supplied)
+
+ @rtype: dictionary
+ @return: dictionary of section names -> id mappings
+ """
+ if session is None:
+ session = DBConn().session()
+
+ ret = {}
+ q = session.query(Section)
+ for x in q.all():
+ ret[x.section] = x.section_id
+
+ return ret
+
+__all__.append('get_sections')
+
################################################################################
class DBSource(object):
--
1.5.6.5
Reply to: