From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 9292B138CEE for ; Sun, 5 Jul 2015 12:04:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0630BE0827; Sun, 5 Jul 2015 12:04:05 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 812A6E0827 for ; Sun, 5 Jul 2015 12:04:04 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 183D73406DD for ; Sun, 5 Jul 2015 12:04:03 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 74379739 for ; Sun, 5 Jul 2015 12:04:01 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: <1436097987.f83f90394526e3568d73e4fe0057515725d1b53d.blueness@gentoo> Subject: [gentoo-commits] proj/grss:master commit in: grs/ X-VCS-Repository: proj/grss X-VCS-Files: grs/WorldConf.py X-VCS-Directories: grs/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: f83f90394526e3568d73e4fe0057515725d1b53d X-VCS-Branch: master Date: Sun, 5 Jul 2015 12:04:01 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 75e61675-968d-4718-bc4e-fa7073b4f3f0 X-Archives-Hash: c5a6e6401571c8d82ef6cd230a1b9ea9 commit: f83f90394526e3568d73e4fe0057515725d1b53d Author: Anthony G. Basile gentoo org> AuthorDate: Sun Jul 5 12:06:27 2015 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Sun Jul 5 12:06:27 2015 +0000 URL: https://gitweb.gentoo.org/proj/grss.git/commit/?id=f83f9039 grs/WorldConf.py: make sure package.env exists. grs/WorldConf.py | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/grs/WorldConf.py b/grs/WorldConf.py index d8140d8..b9e9be9 100644 --- a/grs/WorldConf.py +++ b/grs/WorldConf.py @@ -65,9 +65,7 @@ class WorldConf(): try: uninstalled.remove(p) except ValueError: - # These packages are installed on the local system - # but not in the portage tree anymore. - print(p) + print('%s installed on local system, but not in portage repo anymore.' % p) slot_atoms = [] for p in uninstalled: @@ -83,11 +81,9 @@ class WorldConf(): env_slot_atoms = [] for dirpath, dirnames, filenames in os.walk(CONST.PORTAGE_CONFIGDIR): # Only look at select files and directories. - # TODO: This needs to be expanded as we come up - # with a central class to deal with the internal - # structure of /etc/portage. + # TODO: This needs to be expanded. skip = True - for p in ['env', 'package.accept_keywords', 'package.use']: + for p in ['env', 'package.accept_keywords', 'package.use', 'package.mask', 'package.unmask']: if os.path.basename(dirpath) == p: skip = False if skip: @@ -102,18 +98,19 @@ class WorldConf(): continue fpath = os.path.join(CONST.PORTAGE_CONFIGDIR, 'package.env') - update = False - with open(fpath, 'r') as g: - lines = g.readlines() - mylines = copy.deepcopy(lines) - for l in lines: - for slot_atom in env_slot_atoms: - if re.search(re.escape(slot_atom), l): - try: - mylines.remove(l) - update = True - except ValueError: - pass - if update: - with open(fpath, 'w') as g: - g.writelines(mylines) + if os.path.isile(fpath): + update = False + with open(fpath, 'r') as g: + lines = g.readlines() + mylines = copy.deepcopy(lines) + for l in lines: + for slot_atom in env_slot_atoms: + if re.search(re.escape(slot_atom), l): + try: + mylines.remove(l) + update = True + except ValueError: + pass + if update: + with open(fpath, 'w') as g: + g.writelines(mylines)