From: Alec Warner Date: Mon, 26 Mar 2007 05:25:01 +0000 (-0000) Subject: clean up some init functions, add PortageModules class X-Git-Tag: v2.2_pre1~1535 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d80792f4c02169178cbf0885b19c7948e5648758;p=portage.git clean up some init functions, add PortageModules class svn path=/main/trunk/; revision=6288 --- diff --git a/pym/portage/env/config.py b/pym/portage/env/config.py index 4af7ac47b..127e906d5 100644 --- a/pym/portage/env/config.py +++ b/pym/portage/env/config.py @@ -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))