clean up some init functions, add PortageModules class
authorAlec Warner <antarus@gentoo.org>
Mon, 26 Mar 2007 05:25:01 +0000 (05:25 -0000)
committerAlec Warner <antarus@gentoo.org>
Mon, 26 Mar 2007 05:25:01 +0000 (05:25 -0000)
svn path=/main/trunk/; revision=6288

pym/portage/env/config.py

index 4af7ac47b233e13c2a295733d992a27a4e94e0a1..127e906d50e379f83fc7e0e4dfa41e8b5a4735bc 100644 (file)
@@ -42,8 +42,7 @@ class PackageKeywordsFile(PackageKeywords):
        default_loader = KeyListFileLoader
 
        def __init__(self, filename):
-               self.loader = self.default_loader(filename)
-               PackageKeywords.__init__(self, self.loader)
+               PackageKeywords.__init__(self, self.default_loader(filename))
        
 class PackageUse(UserDict):
        """
@@ -80,8 +79,7 @@ class PackageUseFile(PackageUse):
 
        default_loader = KeyListFileLoader
        def __init__(self, filename):
-               self.loader = self.default_loader(filename)
-               PackageUse.__init__(self, self.loader)
+               PackageUse.__init__(self, self.default_loader(filename))
        
 class PackageMask(UserDict):
        """
@@ -125,5 +123,40 @@ class PackageMaskFile(PackageMask):
        default_loader = AtomFileLoader
 
        def __init__(self, filename):
-               self.loader = self.default_loader(filename)
-               PackageMask.__init__(self, self.loader)
+               PackageMask.__init__(self, self.default_loader(filename))
+
+class PortageModules(UserDict):
+       """
+       Base Class for user level module over-rides
+       """
+
+       def __init__(self, loader):
+               self._loader = loader
+
+       def load(self):
+               self.data, self.errors = self._loader.load()
+
+       def iteritems(self):
+               return self.data.iteritems()
+       
+       def __hash__(self):
+               return self.data.__hash__()
+
+       def __contains__(self, key):
+               return key in self.data
+
+       def keys(self):
+               return self.data.keys()
+       
+       def iterkeys(self):
+               return self.data.iterkeys()
+
+class PortageModulesFile(PortageModules):
+       """
+       File Class for /etc/portage/modules
+       """
+       
+       default_loader = KeyValuePairFileLoader
+       
+       def __init__(self, filename):
+               PortageModules.__init__(self, default_loader(filename))