diff options
author | Zac Medico <zmedico@gentoo.org> | 2012-09-23 15:43:04 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2012-09-23 15:43:04 -0700 |
commit | 6d8d0c02457c2e94c759fe89db0bef196b78158a (patch) | |
tree | 70dd61dca7eb0d7a57cd382f68b5e1860e9ffb28 /pym/portage/repository | |
parent | 0d5b0fbd79ba8b2e7dd5d2f2db7d69cad3e56766 (diff) | |
download | portage-6d8d0c02457c2e94c759fe89db0bef196b78158a.tar.gz portage-6d8d0c02457c2e94c759fe89db0bef196b78158a.tar.bz2 portage-6d8d0c02457c2e94c759fe89db0bef196b78158a.zip |
RepoConfig: add find_invalid_path_char method
This binds filename validation to the RepoConfig, so that eventually
we'll be able to control it via a layout.conf setting as discussed in
bug #435934.
Diffstat (limited to 'pym/portage/repository')
-rw-r--r-- | pym/portage/repository/config.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index 77b016d0c..83018b8a6 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -28,6 +28,9 @@ from portage import _unicode_encode from portage import _encodings from portage import manifest +# Characters prohibited by repoman's file.name check. +_invalid_path_char_re = re.compile(r'[^a-zA-Z0-9._\-+:/]') + _valid_profile_formats = frozenset( ['pms', 'portage-1', 'portage-2']) @@ -49,12 +52,27 @@ def _gen_valid_repo(name): name = None return name +def _find_invalid_path_char(path, pos=0, endpos=None): + """ + Returns the position of the first invalid character found in basename, + or -1 if no invalid characters are found. + """ + if endpos is None: + endpos = len(path) + + m = _invalid_path_char_re.search(path, pos=pos, endpos=endpos) + if m is not None: + return m.start() + + return -1 + class RepoConfig(object): """Stores config of one repository""" __slots__ = ('aliases', 'allow_missing_manifest', 'allow_provide_virtual', 'cache_formats', 'create_manifest', 'disable_manifest', 'eapi', - 'eclass_db', 'eclass_locations', 'eclass_overrides', 'format', 'location', + 'eclass_db', 'eclass_locations', 'eclass_overrides', + 'find_invalid_path_char', 'format', 'location', 'main_repo', 'manifest_hashes', 'masters', 'missing_repo_name', 'name', 'portage1_profiles', 'portage1_profiles_compat', 'priority', 'profile_formats', 'sign_commit', 'sign_manifest', 'sync', @@ -138,6 +156,7 @@ class RepoConfig(object): self.cache_formats = None self.portage1_profiles = True self.portage1_profiles_compat = False + self.find_invalid_path_char = _find_invalid_path_char # Parse layout.conf. if self.location: @@ -211,6 +230,7 @@ class RepoConfig(object): kwds['hashes'] = self.manifest_hashes if self.disable_manifest: kwds['from_scratch'] = True + kwds['find_invalid_path_char'] = self.find_invalid_path_char return manifest.Manifest(*args, **kwds) def update(self, new_repo): |