Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/grss:master commit in: grs/
Date: Sun, 05 Jul 2015 12:04:10
Message-Id: 1436097987.f83f90394526e3568d73e4fe0057515725d1b53d.blueness@gentoo
1 commit: f83f90394526e3568d73e4fe0057515725d1b53d
2 Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jul 5 12:06:27 2015 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Sun Jul 5 12:06:27 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/grss.git/commit/?id=f83f9039
7
8 grs/WorldConf.py: make sure package.env exists.
9
10 grs/WorldConf.py | 41 +++++++++++++++++++----------------------
11 1 file changed, 19 insertions(+), 22 deletions(-)
12
13 diff --git a/grs/WorldConf.py b/grs/WorldConf.py
14 index d8140d8..b9e9be9 100644
15 --- a/grs/WorldConf.py
16 +++ b/grs/WorldConf.py
17 @@ -65,9 +65,7 @@ class WorldConf():
18 try:
19 uninstalled.remove(p)
20 except ValueError:
21 - # These packages are installed on the local system
22 - # but not in the portage tree anymore.
23 - print(p)
24 + print('%s installed on local system, but not in portage repo anymore.' % p)
25
26 slot_atoms = []
27 for p in uninstalled:
28 @@ -83,11 +81,9 @@ class WorldConf():
29 env_slot_atoms = []
30 for dirpath, dirnames, filenames in os.walk(CONST.PORTAGE_CONFIGDIR):
31 # Only look at select files and directories.
32 - # TODO: This needs to be expanded as we come up
33 - # with a central class to deal with the internal
34 - # structure of /etc/portage.
35 + # TODO: This needs to be expanded.
36 skip = True
37 - for p in ['env', 'package.accept_keywords', 'package.use']:
38 + for p in ['env', 'package.accept_keywords', 'package.use', 'package.mask', 'package.unmask']:
39 if os.path.basename(dirpath) == p:
40 skip = False
41 if skip:
42 @@ -102,18 +98,19 @@ class WorldConf():
43 continue
44
45 fpath = os.path.join(CONST.PORTAGE_CONFIGDIR, 'package.env')
46 - update = False
47 - with open(fpath, 'r') as g:
48 - lines = g.readlines()
49 - mylines = copy.deepcopy(lines)
50 - for l in lines:
51 - for slot_atom in env_slot_atoms:
52 - if re.search(re.escape(slot_atom), l):
53 - try:
54 - mylines.remove(l)
55 - update = True
56 - except ValueError:
57 - pass
58 - if update:
59 - with open(fpath, 'w') as g:
60 - g.writelines(mylines)
61 + if os.path.isile(fpath):
62 + update = False
63 + with open(fpath, 'r') as g:
64 + lines = g.readlines()
65 + mylines = copy.deepcopy(lines)
66 + for l in lines:
67 + for slot_atom in env_slot_atoms:
68 + if re.search(re.escape(slot_atom), l):
69 + try:
70 + mylines.remove(l)
71 + update = True
72 + except ValueError:
73 + pass
74 + if update:
75 + with open(fpath, 'w') as g:
76 + g.writelines(mylines)