summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2007-07-23 07:26:18 +0000
committerAlec Warner <antarus@gentoo.org>2007-07-23 07:26:18 +0000
commitff9402db196bb97d86adf670318aa69967b258eb (patch)
tree82f2603047535e1dbab1625f4f5f7943db6efd7f
parent35f99427b08e8b6de7d039ea2d48a6bd75252ef5 (diff)
downloadportage-ff9402db196bb97d86adf670318aa69967b258eb.tar.gz
portage-ff9402db196bb97d86adf670318aa69967b258eb.tar.bz2
portage-ff9402db196bb97d86adf670318aa69967b258eb.zip
Fix imports for style, deprecate grab*, what is foo.metadata and what does it contain
svn path=/main/trunk/; revision=7367
-rw-r--r--pym/portage/sets/files.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/pym/portage/sets/files.py b/pym/portage/sets/files.py
index 5e478fdad..f5884eea7 100644
--- a/pym/portage/sets/files.py
+++ b/pym/portage/sets/files.py
@@ -2,22 +2,28 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
-from portage.util import grabfile, grabfile_package, grabdict_package, write_atomic, ensure_dirs
+import os
+
+from portage.util import grabfile, write_atomic, ensure_dirs
from portage.const import PRIVATE_PATH
from portage.locks import lockfile, unlockfile
from portage import portage_gid
-import os
-
-from portage.sets import PackageSet, EditablePackageSet
+from portage.sets.dbapi import PackageSet, EditablePackageSet
+from portage.env.config import ConfigLoaderKlass, GenericFile
+from portage.env.loaders import ItemFileLoader, KeyListFileLoader
+from portage.env.validators import PackagesFileValidator, ValidAtomValidator
class StaticFileSet(EditablePackageSet):
_operations = ["merge", "unmerge"]
- def __init__(self, name, filename):
+ def __init__(self, name, filename, loader=None):
super(StaticFileSet, self).__init__(name)
self._filename = filename
self._mtime = None
self.description = "Package set loaded from file %s" % self._filename
+ if loader is None:
+ self.loader = ConfigLoaderKlass(ItemFileLoader(filename=self._filename,
+ validator=PackagesFileValidator))
metadata = grabfile(self._filename + ".metadata")
key = None
value = []
@@ -46,17 +52,23 @@ class StaticFileSet(EditablePackageSet):
except (OSError, IOError):
mtime = None
if (not self._loaded or self._mtime != mtime):
- self._setAtoms(grabfile_package(self._filename, recursive=True))
+ self.loader.load()
+ self._setAtoms(self.loader.keys())
self._mtime = mtime
class ConfigFileSet(PackageSet):
- def __init__(self, name, filename):
+ def __init__(self, name, filename, loader=None, validator=None):
super(ConfigFileSet, self).__init__(name)
self._filename = filename
self.description = "Package set generated from %s" % self._filename
+ if loader is None:
+ self.loader = GenericFile(filename=self._filename)
+ else:
+ self.loader = loader(filename, validator)
def load(self):
- self._setAtoms(grabdict_package(self._filename, recursive=True).keys())
+ self.loader.load()
+ self._setAtoms(self.loader.keys())
class WorldSet(StaticFileSet):
description = "Set of packages that were directly installed by the user"