Cleanup profile-formats code. v2.2.0_alpha104
authorZac Medico <zmedico@gentoo.org>
Fri, 11 May 2012 23:39:06 +0000 (16:39 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 11 May 2012 23:39:06 +0000 (16:39 -0700)
pym/portage/package/ebuild/_config/LocationsManager.py
pym/portage/repository/config.py

index 368c0dd159d0e355e273c0dc50acea16d48a98e2..337edc4ce18120ae985ca06d4e86d0d79b989ad8 100644 (file)
@@ -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',)
 
index 71aefde1e22469e3ddc9837a311b78ece3e40ac6..872c189443d63a66036f26ed37829f72f948850d 100644 (file)
@@ -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