From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RJVpz-0006tt-5C for garchives@archives.gentoo.org; Thu, 27 Oct 2011 19:42:06 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1C14B21C074; Thu, 27 Oct 2011 19:41:55 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id D003521C074 for ; Thu, 27 Oct 2011 19:41:54 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 05CBD1B403B for ; Thu, 27 Oct 2011 19:41:54 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 6F2BA80042 for ; Thu, 27 Oct 2011 19:41:53 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/repository/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/repository/config.py X-VCS-Directories: pym/portage/repository/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: a68a292f89aeea222421b8db5901bf0c5e7774a1 Date: Thu, 27 Oct 2011 19:41:53 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 421d6ad0db356b59e36244d873bab28f commit: a68a292f89aeea222421b8db5901bf0c5e7774a1 Author: Zac Medico gentoo org> AuthorDate: Thu Oct 27 19:41:42 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Thu Oct 27 19:41:42 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Da68a292f parse_layout_conf: grab repo_name for error msgs This allows us to avoid duplicate warnings for 'unspecified' repo since parse_layout_conf is initially called without specifying the repo in LocationsManager.load_profiles(). --- pym/portage/repository/config.py | 49 ++++++++++++++++++++++++--------= ----- 1 files changed, 32 insertions(+), 17 deletions(-) diff --git a/pym/portage/repository/config.py b/pym/portage/repository/co= nfig.py index f773ae0..d64ad4f 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -106,17 +106,7 @@ class RepoConfig(object): =20 missing =3D True if self.location is not None: - name, missing =3D self._read_repo_name(self.location) - # We must ensure that the name conforms to PMS 3.1.5 - # in order to avoid InvalidAtom exceptions when we - # use it to generate atoms. - name =3D _gen_valid_repo(name) - if not name: - # name only contains invalid characters - name =3D "x-" + os.path.basename(self.location) - name =3D _gen_valid_repo(name) - # If basename only contains whitespace then the - # end result is name =3D 'x-'. + name, missing =3D self._read_valid_repo_name(self.location) =20 elif name =3D=3D "DEFAULT":=20 missing =3D False @@ -189,7 +179,23 @@ class RepoConfig(object): if new_repo.sync is not None: self.sync =3D new_repo.sync =20 - def _read_repo_name(self, repo_path): + @staticmethod + def _read_valid_repo_name(repo_path): + name, missing =3D RepoConfig._read_repo_name(repo_path) + # We must ensure that the name conforms to PMS 3.1.5 + # in order to avoid InvalidAtom exceptions when we + # use it to generate atoms. + name =3D _gen_valid_repo(name) + if not name: + # name only contains invalid characters + name =3D "x-" + os.path.basename(repo_path) + name =3D _gen_valid_repo(name) + # If basename only contains whitespace then the + # end result is name =3D 'x-'. + return name, missing + + @staticmethod + def _read_repo_name(repo_path): """ Read repo_name from repo_path. Returns repo_name, missing. @@ -600,10 +606,15 @@ def load_repository_config(settings): USER_CONFIG_PATH, "repos.conf")) return RepoConfigLoader(repoconfigpaths, settings) =20 +def _get_repo_name(repo_location, cached=3DNone): + if cached is not None: + return cached + name, missing =3D RepoConfig._read_repo_name(repo_location) + if missing: + return None + return name =20 def parse_layout_conf(repo_location, repo_name=3DNone): - if repo_name is None: - repo_name =3D "unspecified" =20 layout_filename =3D os.path.join(repo_location, "metadata", "layout.con= f") layout_file =3D KeyValuePairFileLoader(layout_filename, None, None) @@ -642,26 +653,28 @@ def parse_layout_conf(repo_location, repo_name=3DNo= ne): if manifest_hashes is not None: manifest_hashes =3D frozenset(manifest_hashes.upper().split()) if MANIFEST2_REQUIRED_HASH not in manifest_hashes: + repo_name =3D _get_repo_name(repo_location, cached=3Drepo_name) warnings.warn((_("Repository named '%(repo_name)s' has a " "'manifest-hashes' setting that does not contain " "the '%(hash)s' hash which is required by this " "portage version. You will have to upgrade portage " "if you want to generate valid manifests for this " "repository: %(layout_filename)s") % - {"repo_name":repo.name, + {"repo_name": repo_name or 'unspecified', "hash":MANIFEST2_REQUIRED_HASH, "layout_filename":layout_filename}), DeprecationWarning) unsupported_hashes =3D manifest_hashes.difference( MANIFEST2_HASH_FUNCTIONS) if unsupported_hashes: + repo_name =3D _get_repo_name(repo_location, cached=3Drepo_name) warnings.warn((_("Repository named '%(repo_name)s' has a " "'manifest-hashes' setting that contains one " "or more hash types '%(hashes)s' which are not supported by " "this portage version. You will have to upgrade " "portage if you want to generate valid manifests for " "this repository: %(layout_filename)s") % - {"repo_name":repo_name, + {"repo_name": repo_name or 'unspecified', "hashes":" ".join(sorted(unsupported_hashes)), "layout_filename":layout_filename}), DeprecationWarning) @@ -677,10 +690,12 @@ def parse_layout_conf(repo_location, repo_name=3DNo= ne): raw_formats =3D set(raw_formats.split()) unknown =3D raw_formats.difference(['pms', 'portage-1']) if unknown: + repo_name =3D _get_repo_name(repo_location, cached=3Drepo_name) warnings.warn((_("Repository named '%(repo_name)s' has unsupported " "profiles in use ('profile-formats =3D %(unknown_fmts)s' setting in = " "'%(layout_filename)s; please upgrade portage.") % - dict(repo_name=3Drepo_name, layout_filename=3Dlayout_filename, + dict(repo_name=3Drepo_name or 'unspecified', + layout_filename=3Dlayout_filename, unknown_fmts=3D" ".join(unknown))), DeprecationWarning) raw_formats =3D tuple(raw_formats.intersection(['pms', 'portage-1']))