From 430ce6fed697eea6c68b13ecdcad14bc6fdac01d Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Sat, 24 Sep 2005 17:54:05 +0000 Subject: EAPI awareness, and flat_hash/flat_list autodetection for rysnc cache. svn path=/main/branches/2.0/; revision=2022 --- pym/portage_db_flat_hash.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 pym/portage_db_flat_hash.py (limited to 'pym/portage_db_flat_hash.py') diff --git a/pym/portage_db_flat_hash.py b/pym/portage_db_flat_hash.py new file mode 100644 index 000000000..8ee7661ff --- /dev/null +++ b/pym/portage_db_flat_hash.py @@ -0,0 +1,38 @@ +# Copyright 2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-src/portage/pym/Attic/portage_db_flat.py,v 1.13.2.6 2005/04/19 07:14:17 ferringb Exp $ +cvs_id_string="$Id: portage_db_flat.py,v 1.13.2.6 2005/04/19 07:14:17 ferringb Exp $"[5:-2] + +import portage_db_flat, os + +class database(portage_db_flat.database): + + def get_values(self, key, data=None): + """ do not specify data unless you know what it does""" + if not key: + raise KeyError("key is not valid") + + if data == None: + try: + myf = open(self.fullpath + key, "r") + except OSError: + raise KeyError("failed pulling key") + + data = dict(map(lambda x: x.split("=",1), myf.read().splitlines())) + data["_mtime_"] = os.fstat(myf.fileno()).st_mtime + myf.close() + + mydict = {} + for x in self.dbkeys: + mydict[x] = data.get(x, "") + mydict["_mtime_"] = long(data["_mtime_"]) + return mydict + + def set_values(self, key, values): + l = [] + for x in values.keys(): + if values[x] and x != "_mtime_": + l.append("%s=%s\n" % (x, values[x])) + l.append(values["_mtime_"]) + portage_db_flat.database.set_values(self, key, l, raw=True) + -- cgit v1.2.3-1-g7c22