blob: 44ed59da69a3f4ee9eac044a7a93a09186a3bf7e [file] [log] [blame]
# Copyright 2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-src/portage/pym/Attic/,v 2005/04/19 07:14:17 ferringb Exp $
cvs_id_string="$Id:,v 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:
myf = open(self.fullpath + key, "r")
except OSError:
raise KeyError("failed pulling key")
data = dict(map(lambda x: x.split("=",1),
data["_mtime_"] = os.fstat(myf.fileno()).st_mtime
mydict = {}
for x in self.dbkeys:
mydict[x] = str(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] not in (None, '') and x != "_mtime_":
l.append("%s=%s\n" % (x, values[x]))
portage_db_flat.database.set_values(self, key, l, raw=True)