From 22996b1d7c7214da8f0bff76d9f814a00f58fdce Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 11 May 2012 16:39:06 -0700 Subject: Cleanup profile-formats code. --- pym/portage/package/ebuild/_config/LocationsManager.py | 5 ++++- pym/portage/repository/config.py | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'pym') diff --git a/pym/portage/package/ebuild/_config/LocationsManager.py b/pym/portage/package/ebuild/_config/LocationsManager.py index 368c0dd15..337edc4ce 100644 --- a/pym/portage/package/ebuild/_config/LocationsManager.py +++ b/pym/portage/package/ebuild/_config/LocationsManager.py @@ -28,6 +28,9 @@ _PORTAGE1_DIRECTORIES = frozenset([ _profile_node = collections.namedtuple('_profile_node', 'location portage1_directories') +_allow_directories = frozenset( + ["portage-1-compat", "portage-1"]) + class LocationsManager(object): def __init__(self, config_root=None, eprefix=None, config_profile_path=None, local_config=True, \ @@ -130,7 +133,7 @@ class LocationsManager(object): # protect against nested repositories. Insane configuration, but the longest # path will be the correct one. repo_loc, layout_data = max(intersecting_repos, key=lambda x:len(x[0])) - allow_directories = any(x.startswith("portage-1") + allow_directories = any(x in _allow_directories for x in layout_data['profile-formats']) compat_mode = layout_data['profile-formats'] == ('portage-1-compat',) diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index 71aefde1e..872c18944 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -27,6 +27,9 @@ from portage import _unicode_encode from portage import _encodings from portage import manifest +_valid_profile_formats = frozenset( + ['pms', 'portage-1']) + _repo_name_sub_re = re.compile(r'[^\w-]') def _gen_valid_repo(name): @@ -754,7 +757,7 @@ def parse_layout_conf(repo_location, repo_name=None): raw_formats = ('portage-1-compat',) else: raw_formats = set(raw_formats.split()) - unknown = raw_formats.difference(['pms', 'portage-1']) + unknown = raw_formats.difference(_valid_profile_formats) if unknown: repo_name = _get_repo_name(repo_location, cached=repo_name) warnings.warn((_("Repository named '%(repo_name)s' has unsupported " @@ -764,7 +767,7 @@ def parse_layout_conf(repo_location, repo_name=None): layout_filename=layout_filename, unknown_fmts=" ".join(unknown))), DeprecationWarning) - raw_formats = tuple(raw_formats.intersection(['pms', 'portage-1'])) + raw_formats = tuple(raw_formats.intersection(_valid_profile_formats)) data['profile-formats'] = raw_formats return data, layout_errors -- cgit v1.2.3-1-g7c22