]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/database.py
Add check_transitions so the yaml file can easily be checked. Make it known to dak
[dak.git] / daklib / database.py
old mode 100644 (file)
new mode 100755 (executable)
index 2aad601..3a6c9ae
@@ -34,6 +34,7 @@ archive_id_cache = {}
 component_id_cache = {}
 location_id_cache = {}
 maintainer_id_cache = {}
+keyring_id_cache = {}
 source_id_cache = {}
 files_id_cache = {}
 maintainer_cache = {}
@@ -222,6 +223,28 @@ def get_source_id (source, version):
 
     return source_id
 
+def get_testing_version(source):
+    global testing_version_cache
+
+    if testing_version_cache.has_key(source):
+        return testing_version_cache[source]
+
+    q = Upload.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='testing'
+      AND s.source='%s'"""
+                              % (source))
+
+    if not q.getresult():
+        return None
+
+    version = q.getresult()[0][0]
+    testing_version_cache[source] = version
+
+    return version
+
 ################################################################################
 
 def get_or_set_maintainer_id (maintainer):
@@ -241,6 +264,23 @@ def get_or_set_maintainer_id (maintainer):
 
 ################################################################################
 
+def get_or_set_keyring_id (keyring):
+    global keyring_id_cache
+
+    if keyring_id_cache.has_key(keyring):
+        return keyring_id_cache[keyring]
+
+    q = projectB.query("SELECT id FROM keyrings WHERE name = '%s'" % (keyring))
+    if not q.getresult():
+        projectB.query("INSERT INTO keyrings (name) VALUES ('%s')" % (keyring))
+        q = projectB.query("SELECT id FROM keyrings WHERE name = '%s'" % (keyring))
+    keyring_id = q.getresult()[0][0]
+    keyring_id_cache[keyring] = keyring_id
+
+    return keyring_id
+
+################################################################################
+
 def get_or_set_uid_id (uid):
     global uid_id_cache