summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'portage/cache/flat_list.py')
-rw-r--r--portage/cache/flat_list.py114
1 files changed, 0 insertions, 114 deletions
diff --git a/portage/cache/flat_list.py b/portage/cache/flat_list.py
deleted file mode 100644
index d9b23a8..0000000
--- a/portage/cache/flat_list.py
+++ /dev/null
@@ -1,114 +0,0 @@
-# Copyright: 2005 Gentoo Foundation
-# Author(s): Brian Harring (ferringb@gentoo.org)
-# License: GPL2
-# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/cache/flat_list.py,v 1.2 2005/07/13 05:51:35 ferringb Exp $
-
-import fs_template
-import cache_errors
-import os, stat
-
-# store the current key order *here*.
-class database(fs_template.FsBased):
-
- autocommits = True
-
- # do not screw with this ordering. _eclasses_ needs to be last
- auxdbkey_order=('DEPEND', 'RDEPEND', 'SLOT', 'SRC_URI',
- 'RESTRICT', 'HOMEPAGE', 'LICENSE', 'DESCRIPTION',
- 'KEYWORDS', 'IUSE', 'CDEPEND',
- 'PDEPEND', 'PROVIDE','_eclasses_')
-
- def __init__(self, *args, **config):
- super(database,self).__init__(*args, **config)
- self.location = os.path.join(self.location,
- self.label.lstrip(os.path.sep).rstrip(os.path.sep))
-
- if len(self._known_keys) > len(self.auxdbkey_order) + 2:
- raise Exception("less ordered keys then auxdbkeys")
- if not os.path.exists(self.location):
- self._ensure_dirs()
-
-
- def _getitem(self, cpv):
- d = {}
- try:
- myf = open(os.path.join(self.location, cpv),"r")
- for k,v in zip(self.auxdbkey_order, myf):
- d[k] = v.rstrip("\n")
- except (OSError, IOError),e:
- if isinstance(e,IOError) and e.errno == 2:
-# print "caught for %s" % cpv, e
-# l=os.listdir(os.path.dirname(os.path.join(self.location,cpv)))
-# l.sort()
-# print l
- raise KeyError(cpv)
- raise cache_errors.CacheCorruption(cpv, e)
-
- try: d["_mtime_"] = os.fstat(myf.fileno()).st_mtime
- except OSError, e:
- myf.close()
- raise cache_errors.CacheCorruption(cpv, e)
- myf.close()
- return d
-
-
- def _setitem(self, cpv, values):
- s = cpv.rfind("/")
- fp=os.path.join(self.location,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:]))
- try: myf=open(fp, "w")
- except (OSError, IOError), e:
- if e.errno == 2:
- try:
- self._ensure_dirs(cpv)
- myf=open(fp,"w")
- except (OSError, IOError),e:
- raise cache_errors.CacheCorruption(cpv, e)
- else:
- raise cache_errors.CacheCorruption(cpv, e)
-
-
- for x in self.auxdbkey_order:
- myf.write(values.get(x,"")+"\n")
-
- myf.close()
- self._ensure_access(fp, mtime=values["_mtime_"])
- #update written. now we move it.
- new_fp = os.path.join(self.location,cpv)
- try: os.rename(fp, new_fp)
- except (OSError, IOError), e:
- os.remove(fp)
- raise cache_errors.CacheCorruption(cpv, e)
-
-
- def _delitem(self, cpv):
- try:
- os.remove(os.path.join(self.location,cpv))
- except OSError, e:
- if e.errno == 2:
- raise KeyError(cpv)
- else:
- raise cache_errors.CacheCorruption(cpv, e)
-
-
- def has_key(self, cpv):
- return os.path.exists(os.path.join(self.location, cpv))
-
-
- def iterkeys(self):
- """generator for walking the dir struct"""
- dirs = [self.location]
- len_base = len(self.location)
- while len(dirs):
- for l in os.listdir(dirs[0]):
- if l.endswith(".cpickle"):
- continue
- p = os.path.join(dirs[0],l)
- st = os.lstat(p)
- if stat.S_ISDIR(st.st_mode):
- dirs.append(p)
- continue
- yield p[len_base+1:]
- dirs.pop(0)
-
-
- def commit(self): pass