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 1Saa5A-0002tu-P5 for garchives@archives.gentoo.org; Fri, 01 Jun 2012 22:12:33 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 43CDCE04F2; Fri, 1 Jun 2012 22:12:20 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id F0152E04F2 for ; Fri, 1 Jun 2012 22:12:19 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 323671B4011 for ; Fri, 1 Jun 2012 22:12:19 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id E61CBE5428 for ; Fri, 1 Jun 2012 22:12:17 +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: <1338588722.b03ed0de134456870c0361dd573e18830c45fa49.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/package/ebuild/config.py X-VCS-Directories: pym/portage/package/ebuild/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: b03ed0de134456870c0361dd573e18830c45fa49 X-VCS-Branch: master Date: Fri, 1 Jun 2012 22:12:17 +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: ea355b80-1227-4fc6-b3c5-970450673ac4 X-Archives-Hash: ac86eb40e9bc5b0afd642fc33ba1def2 commit: b03ed0de134456870c0361dd573e18830c45fa49 Author: Zac Medico gentoo org> AuthorDate: Fri Jun 1 22:12:02 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Jun 1 22:12:02 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Db03ed0de config: lazy KeywordsManager instantiation This allows a config instance to be instantiated by portageq, while accessing /etc/portage/package.keywords only on demand, solving bug #418475 by avoiding PermissionDenied exceptions when possible. --- pym/portage/package/ebuild/config.py | 23 ++++++++++++++++++----- 1 files changed, 18 insertions(+), 5 deletions(-) diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/e= build/config.py index 97cbd99..6f5680b 100644 --- a/pym/portage/package/ebuild/config.py +++ b/pym/portage/package/ebuild/config.py @@ -227,9 +227,12 @@ class config(object): self._setcpv_args_hash =3D clone._setcpv_args_hash =20 # immutable attributes (internal policy ensures lack of mutation) - self._keywords_manager =3D clone._keywords_manager + self._locations_manager =3D clone._locations_manager self._use_manager =3D clone._use_manager self._mask_manager =3D clone._mask_manager + # force instantiation of lazy immutable objects when cloning, so + # that they're not instantiated more than once + self._keywords_manager_obj =3D clone._keywords_manager =20 # shared mutable attributes self._unknown_features =3D clone._unknown_features @@ -274,9 +277,13 @@ class config(object): self._expand_map =3D copy.deepcopy(clone._expand_map) =20 else: + # lazily instantiated objects + self._keywords_manager_obj =3D None + locations_manager =3D LocationsManager(config_root=3Dconfig_root, config_profile_path=3Dconfig_profile_path, eprefix=3Deprefix, local_config=3Dlocal_config, target_root=3Dtarget_root) + self._locations_manager =3D locations_manager =20 eprefix =3D locations_manager.eprefix config_root =3D locations_manager.config_root @@ -574,10 +581,6 @@ class config(object): d.pop(k, None) self._repo_make_defaults[repo.name] =3D d =20 - #Read package.keywords and package.accept_keywords. - self._keywords_manager =3D KeywordsManager(profiles_complex, abs_user= _config, \ - local_config, global_accept_keywords=3Dself.configdict["defaults"].g= et("ACCEPT_KEYWORDS", "")) - #Read all USE related files from profiles and optionally from user co= nfig. self._use_manager =3D UseManager(self.repositories, profiles_complex,= abs_user_config, user_config=3Dlocal_config) #Initialize all USE related variables we track ourselves. @@ -882,6 +885,16 @@ class config(object): noiselevel=3D-1) =20 @property + def _keywords_manager(self): + if self._keywords_manager_obj is None: + self._keywords_manager_obj =3D KeywordsManager( + self._locations_manager.profiles_complex, + self._locations_manager.abs_user_config, + self.local_config, + global_accept_keywords=3Dself.configdict["defaults"].get("ACCEPT_KEY= WORDS", "")) + return self._keywords_manager_obj + + @property def pkeywordsdict(self): result =3D self._keywords_manager.pkeywordsdict.copy() for k, v in result.items():