From: Zac Medico Date: Thu, 27 Oct 2011 20:49:40 +0000 (-0700) Subject: LocationsManager: extensible _profile_node object X-Git-Tag: v2.2.0_alpha72~52 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=10202ff80ebd212457db95d76ca1fbc79567bf8d;p=portage.git LocationsManager: extensible _profile_node object Use immutable object attrubutes instead of tuples, for extensibility. --- diff --git a/pym/portage/package/ebuild/_config/KeywordsManager.py b/pym/portage/package/ebuild/_config/KeywordsManager.py index 704ddca70..2f9f7b305 100644 --- a/pym/portage/package/ebuild/_config/KeywordsManager.py +++ b/pym/portage/package/ebuild/_config/KeywordsManager.py @@ -20,7 +20,8 @@ class KeywordsManager(object): global_accept_keywords=""): self._pkeywords_list = [] rawpkeywords = [grabdict_package( - os.path.join(x[0], "package.keywords"), recursive=x[1], + os.path.join(x.location, "package.keywords"), + recursive=x.portage1_directories, verify_eapi=True) \ for x in profiles] for pkeyworddict in rawpkeywords: @@ -35,7 +36,8 @@ class KeywordsManager(object): self._p_accept_keywords = [] raw_p_accept_keywords = [grabdict_package( - os.path.join(x[0], "package.accept_keywords"), recursive=x[1], + os.path.join(x.location, "package.accept_keywords"), + recursive=x.portage1_directories, verify_eapi=True) \ for x in profiles] for d in raw_p_accept_keywords: diff --git a/pym/portage/package/ebuild/_config/LocationsManager.py b/pym/portage/package/ebuild/_config/LocationsManager.py index d79362542..ec3f0035f 100644 --- a/pym/portage/package/ebuild/_config/LocationsManager.py +++ b/pym/portage/package/ebuild/_config/LocationsManager.py @@ -23,6 +23,18 @@ _PORTAGE1_DIRECTORIES = frozenset([ 'package.use', 'package.use.mask', 'package.use.force', 'use.mask', 'use.force']) +class _profile_node(object): + + __slots__ = ('location', 'portage1_directories') + + def __init__(self, location, portage1_directories): + object.__setattr__(self, 'location', location) + object.__setattr__(self, 'portage1_directories', portage1_directories) + + def __setattr__(self, name, value): + raise AttributeError("_profile_node instances are immutable", + self.__class__, name, value) + class LocationsManager(object): def __init__(self, config_root=None, eprefix=None, config_profile_path=None, local_config=True, \ @@ -92,7 +104,7 @@ class LocationsManager(object): if os.path.exists(custom_prof): self.user_profile_dir = custom_prof self.profiles.append(custom_prof) - self.profiles_complex.append((custom_prof, True)) + self.profiles_complex.append(_profile_node(custom_prof, True)) del custom_prof self.profiles = tuple(self.profiles) @@ -177,7 +189,8 @@ class LocationsManager(object): (parentPath, parentsFile)) self.profiles.append(currentPath) - self.profiles_complex.append((currentPath, allow_directories)) + self.profiles_complex.append( + _profile_node(currentPath, allow_directories)) def set_root_override(self, root_overwrite=None): # Allow ROOT setting to come from make.conf if it's not overridden diff --git a/pym/portage/package/ebuild/_config/MaskManager.py b/pym/portage/package/ebuild/_config/MaskManager.py index a2bfb19b1..6b0f1c32a 100644 --- a/pym/portage/package/ebuild/_config/MaskManager.py +++ b/pym/portage/package/ebuild/_config/MaskManager.py @@ -115,12 +115,16 @@ class MaskManager(object): #to allow profiles to override masks from their parent profiles. profile_pkgmasklines = [] profile_pkgunmasklines = [] - for x, portage1_mode in profiles: + for x in profiles: profile_pkgmasklines.append(grabfile_package( - os.path.join(x, "package.mask"), recursive=portage1_mode, remember_source_file=True, verify_eapi=True)) - if portage1_mode: + os.path.join(x.location, "package.mask"), + recursive=x.portage1_directories, + remember_source_file=True, verify_eapi=True)) + if x.portage1_directories: profile_pkgunmasklines.append(grabfile_package( - os.path.join(x, "package.unmask"), recursive=1, remember_source_file=True, verify_eapi=True)) + os.path.join(x.location, "package.unmask"), + recursive=x.portage1_directories, + remember_source_file=True, verify_eapi=True)) profile_pkgmasklines = stack_lists(profile_pkgmasklines, incremental=1, \ remember_source_file=True, warn_for_unmatched_removal=True, strict_warn_for_unmatched_removal=strict_umatched_removal) diff --git a/pym/portage/package/ebuild/_config/UseManager.py b/pym/portage/package/ebuild/_config/UseManager.py index bf06bd79d..0506af019 100644 --- a/pym/portage/package/ebuild/_config/UseManager.py +++ b/pym/portage/package/ebuild/_config/UseManager.py @@ -132,11 +132,15 @@ class UseManager(object): return ret def _parse_profile_files_to_tuple_of_tuples(self, file_name, locations): - return tuple(self._parse_file_to_tuple(os.path.join(profile[0], file_name), recursive=profile[1]) + return tuple(self._parse_file_to_tuple( + os.path.join(profile.location, file_name), + recursive=profile.portage1_directories) for profile in locations) def _parse_profile_files_to_tuple_of_dicts(self, file_name, locations, juststrings=False): - return tuple(self._parse_file_to_dict(os.path.join(profile[0], file_name), juststrings, recursive=profile[1]) + return tuple(self._parse_file_to_dict( + os.path.join(profile.location, file_name), juststrings, + recursive=profile.portage1_directories) for profile in locations) def getUseMask(self, pkg=None): diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py index 34a326e49..47ea7f828 100644 --- a/pym/portage/package/ebuild/config.py +++ b/pym/portage/package/ebuild/config.py @@ -637,8 +637,10 @@ class config(object): archlist = stack_lists(archlist, incremental=1) self.configdict["conf"]["PORTAGE_ARCHLIST"] = " ".join(archlist) - pkgprovidedlines = [grabfile(os.path.join(loc, "package.provided"), recursive=recursive) - for loc, recursive in self.profiles_complex] + pkgprovidedlines = [grabfile( + os.path.join(x.location, "package.provided"), + recursive=x.portage1_directories) + for x in self.profiles_complex] pkgprovidedlines = stack_lists(pkgprovidedlines, incremental=1) has_invalid_data = False for x in range(len(pkgprovidedlines)-1, -1, -1):