summaryrefslogtreecommitdiffstats
path: root/pym/cache/anydbm.py
diff options
context:
space:
mode:
authorMarius Mauch <genone@gentoo.org>2007-01-25 15:49:26 +0000
committerMarius Mauch <genone@gentoo.org>2007-01-25 15:49:26 +0000
commit3b08c21101b0801d7c5d6c145a27bef5cd42078c (patch)
tree2eea73b311d67b567410670630335796bf0a272c /pym/cache/anydbm.py
parentb4eed9540e19ee7038ac875f0e084f8256675580 (diff)
downloadportage-3b08c21101b0801d7c5d6c145a27bef5cd42078c.tar.gz
portage-3b08c21101b0801d7c5d6c145a27bef5cd42078c.tar.bz2
portage-3b08c21101b0801d7c5d6c145a27bef5cd42078c.zip
Namespace sanitizing, step 1
svn path=/main/trunk/; revision=5778
Diffstat (limited to 'pym/cache/anydbm.py')
-rw-r--r--pym/cache/anydbm.py72
1 files changed, 0 insertions, 72 deletions
diff --git a/pym/cache/anydbm.py b/pym/cache/anydbm.py
deleted file mode 100644
index a4e0003d4..000000000
--- a/pym/cache/anydbm.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# Copyright: 2005 Gentoo Foundation
-# Author(s): Brian Harring (ferringb@gentoo.org)
-# License: GPL2
-# $Id$
-
-anydbm_module = __import__("anydbm")
-try:
- import cPickle as pickle
-except ImportError:
- import pickle
-import os
-from cache import fs_template
-from cache import cache_errors
-
-
-class database(fs_template.FsBased):
-
- autocommits = True
- cleanse_keys = True
- serialize_eclasses = False
-
- def __init__(self, *args, **config):
- super(database,self).__init__(*args, **config)
-
- default_db = config.get("dbtype","anydbm")
- if not default_db.startswith("."):
- default_db = '.' + default_db
-
- self._db_path = os.path.join(self.location, fs_template.gen_label(self.location, self.label)+default_db)
- self.__db = None
- try:
- self.__db = anydbm_module.open(self._db_path, "w", self._perms)
-
- except anydbm_module.error:
- # XXX handle this at some point
- try:
- self._ensure_dirs()
- self._ensure_dirs(self._db_path)
- except (OSError, IOError), e:
- raise cache_errors.InitializationError(self.__class__, e)
-
- # try again if failed
- try:
- if self.__db == None:
- self.__db = anydbm_module.open(self._db_path, "c", self._perms)
- except anydbm_module.error, e:
- raise cache_errors.InitializationError(self.__class__, e)
- self._ensure_access(self._db_path)
-
- def iteritems(self):
- return self.__db.iteritems()
-
- def _getitem(self, cpv):
- # we override getitem because it's just a cpickling of the data handed in.
- return pickle.loads(self.__db[cpv])
-
- def _setitem(self, cpv, values):
- self.__db[cpv] = pickle.dumps(values,pickle.HIGHEST_PROTOCOL)
-
- def _delitem(self, cpv):
- del self.__db[cpv]
-
- def iterkeys(self):
- return iter(self.__db.keys())
-
- def __contains__(self, cpv):
- return cpv in self.__db
-
- def __del__(self):
- if "__db" in self.__dict__ and self.__db != None:
- self.__db.sync()
- self.__db.close()