From: Anthony Towns Date: Wed, 5 Dec 2007 07:06:17 +0000 (+0000) Subject: add get_or_set_keyring_id for import-keyring X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9583602d5fa14f016ddf3f09b3ddf2d515e19768;p=dak add get_or_set_keyring_id for import-keyring --- diff --git a/daklib/database.py b/daklib/database.py index 2aad6017..a40696e2 100644 --- a/daklib/database.py +++ b/daklib/database.py @@ -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 = {} @@ -241,6 +242,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